Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cli/tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,15 @@ def test_scan_org_policies_treat_foreign_custom_as_undeclared(repo):


_MODERATE_GATED = "compute.managed.restrictProtocolForwardingCreationForTypes"
_IL_GATED = "compute.requireOsLogin"


def test_declared_org_policies_follow_the_regime(repo):
every = set(repo.declared_org_policies())
moderate = set(repo.declared_org_policies("FEDRAMP_MODERATE"))
assert set(repo.declared_org_policies("IL5")) == every
assert set(repo.declared_org_policies("FEDRAMP_HIGH")) == every
assert set(repo.declared_org_policies("IL4")) == every - {_IL_GATED}
assert set(repo.declared_org_policies("IL5")) == every - {_IL_GATED}
assert _MODERATE_GATED in every - moderate
# The FedRAMP Moderate branch of an if and else pair still counts.
assert "gcp.resourceLocations" in moderate
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
%{ if !contains(["IL4", "IL5"], regime) ~}
# This boolean constraint, when set to true, enables OS Login on all newly
# created Projects. All VM instances created in new projects will have OS Login
# enabled. On new and existing projects, this constraint prevents metadata
# updates that disable OS Login at the project or instance level. By default,
# the OS Login feature is disabled on Compute Engine projects.GKE instances in
# private clusters running node pool versions 1.20.5-gke.2000 and later support
# OS Login. GKE instances in public clusters do not currently support OS Login.
# If this constraint is applied to a Project running public clusters, GKE
# instances running in that Project may not function properly.
# COULD HAVE
compute.requireOsLogin:
rules:
- enforce: true
%{ else ~}
{}
%{ endif ~}
15 changes: 0 additions & 15 deletions fast/stages-aw/0-bootstrap/data/org-policies/compute_policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,6 @@ compute.disableSerialPortAccess:
# - enforce: false


# This boolean constraint, when set to true, enables OS Login on all newly
# created Projects. All VM instances created in new projects will have OS Login
# enabled. On new and existing projects, this constraint prevents metadata
# updates that disable OS Login at the project or instance level. By default,
# the OS Login feature is disabled on Compute Engine projects.GKE instances in
# private clusters running node pool versions 1.20.5-gke.2000 and later support
# OS Login. GKE instances in public clusters do not currently support OS Login.
# If this constraint is applied to a Project running public clusters, GKE
# instances running in that Project may not function properly.
# COULD HAVE
compute.requireOsLogin:
rules:
- enforce: true


# This boolean constraint, when set to True, requires that all new Compute
# Engine VM instances use Shielded disk images with Secure Boot, vTPM, and
# Integrity Monitoring options enabled. Secure Boot can be disabled after
Expand Down
3 changes: 2 additions & 1 deletion fast/stages-aw/0-bootstrap/import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fi

echo "Fetching current Terraform state list..."
state_list=$(terraform state list 2>/dev/null)
declared_policies=$(echo 'keys(local.org_policies)' | terraform console 2>/dev/null)

rm -f imports.tf
import_count=0
Expand All @@ -55,7 +56,7 @@ while IFS= read -r constraint_path; do
target_resource="module.organization.google_org_policy_policy.default[\"${constraint_name}\"]"

# Check if constraint is declared in local configuration files
if ! grep -rq "^${constraint_name}:" ./data/org-policies/ ./data/custom-org-policies/ 2>/dev/null; then
if ! echo "${declared_policies}" | grep -qF "\"${constraint_name}\""; then
continue
fi

Expand Down
Loading