Skip to content

🐛 Fix 21 incorrect GCP IAM permissions in auto-generated manifest#7080

Merged
tas50 merged 7 commits intomainfrom
fix/gcp-permissions-validation
Apr 2, 2026
Merged

🐛 Fix 21 incorrect GCP IAM permissions in auto-generated manifest#7080
tas50 merged 7 commits intomainfrom
fix/gcp-permissions-validation

Conversation

@vjeffrey
Copy link
Copy Markdown
Contributor

Summary

  • Fixed the GCP permission extraction generator to produce correct IAM permission strings
  • 21 permissions were invalid: wrong service prefixes, incorrect resource names, non-existent permissions from protobuf getters
  • All fixes verified against official GCP IAM documentation

Service name prefix fixes (gcpServiceNameMap):

Before After Count
cloudresourcemanager.* resourcemanager.* 9
sqladmin.* cloudsql.* 2
security.* privateca.* 3

Method-to-permission overrides (new table):

Before (invalid) After (correct)
accessapproval.accessApprovalSettings.get accessapproval.settings.get
binaryauthorization.systemPolicy.get binaryauthorization.policy.get
cloudkms.cryptoKey.get cloudkms.cryptoKeys.get
cloudkms.iamPolicy.get cloudkms.cryptoKeys.getIamPolicy
secretmanager.iamPolicy.get secretmanager.secrets.getIamPolicy
secretmanager.secretVersions.list secretmanager.versions.list
artifactregistry.iamPolicy.get artifactregistry.repositories.getIamPolicy
serviceusage.service.get serviceusage.services.get

Removed fake permissions:

  • monitoring.conditionAbsent.get, monitoring.conditionThreshold.get, monitoring.conditionMatchedLog.get, monitoring.conditionMonitoringQueryLanguage.get — protobuf getters, not API calls

Other generator fixes:

  • Strip Iter suffix from gRPC iterator methods (iam.rolesIter.listiam.roles.list)
  • Map REST Aggregated verb to list (dataflow.jobs.aggregateddataflow.jobs.list)
  • Skip bare gRPC Get() calls with no resource qualifier (compute.compute.get)

Test plan

  • Verified each corrected permission against GCP IAM permissions reference and service-specific docs
  • Run make providers/build/gcp to confirm build succeeds
  • Verify regeneration is idempotent: go run providers-sdk/v1/util/permissions/permissions.go providers/gcp produces no diff

🤖 Generated with Claude Code

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes incorrect GCP IAM permission strings in the auto-generated manifest, improving accuracy of permission documentation.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

Test Results

5 779 tests  ±0   5 775 ✅ ±0   2m 10s ⏱️ -3s
  433 suites ±0       4 💤 ±0 
   34 files   ±0       0 ❌ ±0 

Results for commit a34dc39. ± Comparison against base commit c82dbc8.

♻️ This comment has been updated with latest results.

"redis.instances.list",
"resourcemanager.folders.get",
"resourcemanager.folders.list",
"resourcemanager.folders.search",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resourcemanager.folders.search and resourcemanager.projects.search are not valid permissions

@vjeffrey
Copy link
Copy Markdown
Contributor Author

backupdr.dataSources.list -> Not a real permission. Should be backupdr.bvdataSources.list (backup vault data sources).
recommender.recommendations.list -> Not a real permission. Recommender uses type-specific permissions like recommender.iamPolicyRecommendations.list, recommender.computeInstanceMachineTypeRecommendations.list, etc. There is no generic recommender.recommendations.list.

@mondoo-code-review
Copy link
Copy Markdown

Unable to complete the code review.

Reason: The AI service is temporarily overloaded. Please retry in a few minutes.

You can try /review again or reduce the PR size.

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCP IAM permission manifest corrected to use real permission names, preventing permission errors when deploying least-privilege roles.

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a Python validation script for GCP permissions; previous suggestions about comments and tests remain unaddressed.

@vjeffrey
Copy link
Copy Markdown
Contributor Author

vjeffrey commented Apr 2, 2026

Permission compute.networkFirewallPolicies.get is not valid
Permission compute.networkFirewallPolicies.list is not valid
Permission resourcemanager.folders.get is not valid
Permission resourcemanager.folders.list is not valid
Permission resourcemanager.organizations.get is not valid
resourcemanager.organizations.getIamPolicy is not valid
Permission resourcemanager.projects.list is not valid.

@vjeffrey
Copy link
Copy Markdown
Contributor Author

vjeffrey commented Apr 2, 2026

Additional findings from role creation testing

After testing role creation, 7 permissions were flagged as invalid. Two categories:

Fixed: Wrong IAM permission names (this commit)

  • compute.networkFirewallPolicies.getcompute.firewallPolicies.get
  • compute.networkFirewallPolicies.listcompute.firewallPolicies.list

The REST API resource is networkFirewallPolicies but the IAM permission uses the shorter firewallPolicies namespace.

Also added resourcemanager.folders.list to the flat permissions list (was present in details but missing from the top-level array).

Not fixable in manifest: Org-level only permissions

These 5 permissions are valid GCP IAM permissions but cannot be used in project-level custom roles — they require an organization-level custom role:

  • resourcemanager.folders.get
  • resourcemanager.folders.list
  • resourcemanager.organizations.get
  • resourcemanager.organizations.getIamPolicy
  • resourcemanager.projects.list

If consumers are creating project-level roles, these need to be excluded. We may want to add a "scope": "org" field to the details to distinguish them, or split into separate permission sets.

vjeffrey and others added 6 commits April 2, 2026 12:38
The permission extraction heuristics produced several invalid GCP IAM
permission strings. This fixes the generator and regenerates the manifest.

**Service name prefix fixes (gcpServiceNameMap):**
- cloudresourcemanager.* → resourcemanager.* (9 permissions)
- sqladmin.* → cloudsql.* (2 permissions)
- security.* → privateca.* (3 permissions)

**Method-to-permission override table (new):**
- accessapproval.accessApprovalSettings.get → accessapproval.settings.get
- binaryauthorization.systemPolicy.get → binaryauthorization.policy.get
- cloudkms.cryptoKey.get → cloudkms.cryptoKeys.get
- cloudkms.iamPolicy.get → cloudkms.cryptoKeys.getIamPolicy
- secretmanager.iamPolicy.get → secretmanager.secrets.getIamPolicy
- secretmanager.secretVersions.list → secretmanager.versions.list
- artifactregistry.iamPolicy.get → artifactregistry.repositories.getIamPolicy
- serviceusage.service.get → serviceusage.services.get

**Non-API method filtering (new skip list):**
- monitoring.conditionAbsent.get, monitoring.conditionThreshold.get,
  monitoring.conditionMatchedLog.get, monitoring.conditionMonitoringQueryLanguage.get
  (protobuf getters, not real API calls)

**Other generator fixes:**
- Strip "Iter" suffix from gRPC iterator methods (iam.rolesIter.list → iam.roles.list)
- Map REST "Aggregated" verb to "list" (dataflow.jobs.aggregated → dataflow.jobs.list)
- Skip bare gRPC Get() calls with no resource qualifier (compute.compute.get)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ssions

resourcemanager.folders.search and resourcemanager.projects.search are
not valid GCP IAM permissions. The Search API requires the .list
permission, so map the REST "Search" method to the "list" verb.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- backupdr.dataSources.list → backupdr.bvdataSources.list (backup vault
  data sources use the bvdataSources resource type)
- Remove recommender.recommendations.list — not a real permission; the
  Recommender API uses type-specific permissions that can't be
  auto-derived from the code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Queries the queryTestablePermissions IAM API at both project and org
levels to catch all valid permissions, then compares against our
generated gcp.permissions.json file and reports any invalid entries
with fuzzy-match suggestions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Separate permissions that can only be used in org-level custom roles
(resourcemanager.folders.*, organizations.*, projects.list) into a
dedicated org_level_permissions array. Add scope: "org" to matching
detail entries. Update validation script to check both lists.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vjeffrey vjeffrey force-pushed the fix/gcp-permissions-validation branch from decd71a to a34dc39 Compare April 2, 2026 18:43
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License header updated; no functional changes.

@@ -0,0 +1,271 @@
# Copyright Mondoo, Inc. 2024, 2026
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 suggestion — The shebang (#!/usr/bin/env python3) on line 4 should be the very first line of the file for the OS to recognize it as a Python script when executed directly (./validate_permissions.py). Move the copyright/license comment block below the shebang line.

@tas50 tas50 merged commit a6f7b39 into main Apr 2, 2026
12 checks passed
@tas50 tas50 deleted the fix/gcp-permissions-validation branch April 2, 2026 19:24
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants