Skip to content

feat(query): implements "Beta - Logs And Alerts Missing Project Ownership Assignment And Changes"#7804

Merged
cx-andre-pereira merged 9 commits into
masterfrom
AST-116616_3_2-Logging_and_Monitoring_ensure_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes
Dec 9, 2025
Merged

feat(query): implements "Beta - Logs And Alerts Missing Project Ownership Assignment And Changes"#7804
cx-andre-pereira merged 9 commits into
masterfrom
AST-116616_3_2-Logging_and_Monitoring_ensure_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes

Conversation

@cx-andre-pereira

@cx-andre-pereira cx-andre-pereira commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Reason for Proposed Changes

  • Currently there are no queries addressing the Terraform/gcp "google_logging_metric" and "google_monitoring_alert_policy" resources's "filter" fields. This query is meant to ensure those resources's filters properly check for roles/Owner assignments.

  • Quoting CIS_Google_Cloud_Platform_Foundation_Benchmark_v4.0.0 page 81: "Project ownership has the highest level of privileges on a project. To avoid misuse of project resources, the project ownership assignment/change actions mentioned above should be monitored and alerted to concerned recipients. • Sending project ownership invites • Acceptance/Rejection of project ownership invite by user • Adding role\Owner to a user/service-account • Removing a user/Service account from role\Owner"

  • Additionally page 82 states the specific filter that should be present :

(protoPayload.serviceName="cloudresourcemanager.googleapis.com")
AND (ProjectOwnership OR projectOwnerInvitee)
OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="REMOVE"
AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner")
OR (protoPayload.serviceData.policyDelta.bindingDeltas.action="ADD"
AND protoPayload.serviceData.policyDelta.bindingDeltas.role="roles/owner")

Proposed Changes

  • Developed an initial implementation for a query that ensures "roles/Owner assignments" are accounted for by a given filter.

  • Based on the audit described by the CIS entry the query will flag if :

    • There is at least one"google_logging_metric" resource in the project and none contain the correct filter
    • There is at least one "google_monitoring_alert_policy" resource in the project and none contain the filter/reference a logging metric that contains the correct filter
    • There is at least one "google_monitoring_alert_policy" resource that contains the filter but none of them declare "notification_channels".

Note: there are currently issues with the search values, i could not get them to point to the "filter" field for either of the target resources in the scan results.

Tenable Reference

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions Bot added feature New feature query New query feature labels Oct 31, 2025
@github-actions

github-actions Bot commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.17

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@github-actions github-actions Bot added terraform Terraform query gcp PR related with GCP Cloud azure PR related with Azure Cloud labels Oct 31, 2025
…re_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes
@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review October 31, 2025 12:37
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner October 31, 2025 12:37
@github-actions github-actions Bot removed the azure PR related with Azure Cloud label Oct 31, 2025

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just quality of life changes, everything looks okay besides that!
We could also improve the variables naming (i2, x...) but I leave it to you to decide.

…_filter_and_alerts_exist_for_project_ownership_assignments/changes' of https://github.com/Checkmarx/kics into AST-116616_3_2-Logging_and_Monitoring_ensure_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes
@gitguardian

gitguardian Bot commented Nov 17, 2025

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
21271469 Triggered Generic Password 72ca9f3 assets/queries/terraform/azure/unrestricted_sql_server_access/test/negative6.tf View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

…re_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes
cx-artur-ribeiro and others added 2 commits December 5, 2025 15:34
…re_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes
…re_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes
@cx-andre-pereira cx-andre-pereira merged commit 92aba94 into master Dec 9, 2025
29 checks passed
@cx-andre-pereira cx-andre-pereira deleted the AST-116616_3_2-Logging_and_Monitoring_ensure_log_metric_filter_and_alerts_exist_for_project_ownership_assignments/changes branch December 9, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature gcp PR related with GCP Cloud query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants