fix(plugins/gcpaudit): route gcp.policyDelta by IAM proto, not gcs_bucket allowlist#1355
Open
raajheshkannaa wants to merge 1 commit into
Open
Conversation
…cket allowlist
Before, gcp.policyDelta sent every resource type except gcs_bucket
through protoPayload.metadata.datasetChange.bindingDeltas. That path
only exists for BigQuery dataset.setIamPolicy. Every other GCP IAM
SetIamPolicy event emits the deltas under
protoPayload.serviceData.policyDelta.bindingDeltas (the generic
google.iam.v1.PolicyDelta proto), so project, folder, organization,
service_account, and any future IAM-using resource type returned an
empty field, breaking rules that match on %gcp.policyDelta.
Route bigquery_dataset to the metadata.datasetChange path and default
every other resource type to the generic serviceData.policyDelta
path. This matches both the GCP audit log schema and the reporter's
description ("the else path is really only used by bigquery_dataset
type"). Unknown future resource types now resolve correctly without
another code change.
Extract the routing into a small policyDeltaPath helper so the policy
is unit-testable; the gcpaudit package previously had no tests.
Closes falcosecurity#1351
Signed-off-by: Raajhesh Kannaa Chidambaram <[email protected]>
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: raajheshkannaa The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area plugins
What this PR does / why we need it:
Before this change, `gcp.policyDelta` only returned the correct value for `gcs_bucket` resources. Every other resource type fell through to `protoPayload.metadata.datasetChange.bindingDeltas`, which only exists on BigQuery `dataset.setIamPolicy` events. `project`, `folder`, `organization`, `service_account`, and any other GCP resource that uses the generic IAM SetIamPolicy flow returned an empty field, breaking Falco rules that match on `%gcp.policyDelta`.
The generic IAM proto (`google.iam.v1.PolicyDelta`) is emitted under `protoPayload.serviceData.policyDelta.bindingDeltas` for every service that uses the shared IAM `SetIamPolicy` endpoint. BigQuery is the documented outlier and emits its deltas under `protoPayload.metadata.datasetChange` as part of `BigQueryAuditMetadata`.
Route `bigquery_dataset` explicitly to the `metadata.datasetChange` path and default every other resource type to the `serviceData.policyDelta` path. This matches both the reporter's description ("the else path is really only used by `bigquery_dataset` type") and the published GCP audit log schema, and it stays correct for any future IAM-using resource type without further code changes.
Routing is extracted into a `policyDeltaPath` helper so the policy is unit-testable. The `gcpaudit` package had no test file before this change.
Test:
Added `extract_test.go` with 8 cases asserting the path for `gcs_bucket`, `project`, `folder`, `organization`, `service_account`, an unknown resource type, an empty string (all serviceData), and `bigquery_dataset` (datasetChange).
Which issue(s) this PR fixes:
Fixes #1351
Special notes for your reviewer:
The reporter suggested an additive fix (add the new resource types to the existing `gcs_bucket` allowlist). I inverted the default instead so unenumerated resource types like `gae_app`, `pubsub_topic`, etc. resolve correctly. The behavior change for unenumerated resources moves them from returning empty (current bug) to the generic IAM path (expected per GCP docs).
`gofmt` reports one whitespace nit on `extract.go` line 173 (`req.SetValueOffset(sdk.PluginEventPayloadOffset + uint32(...))`). This is pre-existing on upstream/main at `5855f3e`, not introduced by this PR. Happy to fold a gofmt fix in if you'd prefer.
Does this PR introduce a user-facing change?:
```release-note
fix(plugins/gcpaudit): `gcp.policyDelta` now resolves for project, folder, organization, service_account, and other IAM resource types instead of returning empty.
```