fix(queries): better interpreter for gcp queries#7912
Merged
cx-ricardo-jesus merged 48 commits intoMar 3, 2026
Merged
Conversation
Contributor
…ve' of https://github.com/Checkmarx/kics into AST-126467-update-metric-log-filter-to-be-more-permissive
…26467-update-metric-log-filter-to-be-more-permissive
…26467-update-metric-log-filter-to-be-more-permissive
…26467-update-metric-log-filter-to-be-more-permissive
cx-miguel-dasilva
suggested changes
Feb 11, 2026
cx-miguel-dasilva
left a comment
Contributor
There was a problem hiding this comment.
Since the 3 queries rely basically on the same logic to check the Log query, align them as much as possible to make them easier to maintain in the future. Add some function to rego libraries if you believe that can be achieved.
…ve' of https://github.com/Checkmarx/kics into AST-126467-update-metric-log-filter-to-be-more-permissive
…ve' of https://github.com/Checkmarx/kics into AST-126467-update-metric-log-filter-to-be-more-permissive
cx-miguel-dasilva
previously approved these changes
Feb 24, 2026
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.








Closes #
Reason for Proposed Changes
CIS_Google_Cloud_Platform_Foundation_Benchmark_v4.0.0.Proposed Changes
All the three queries, does the same verifications:
The queries
Beta - Logs And Alerts Missing Project Ownership Assignement And ChangesandBeta - Logs And Alerts Missing Audit Configuration Changesare using a really similar approach each one to handle the filter field, taking into account the following filters present in the respective CIS Benchmark page:Beta - Logs And Alerts Missing Project Ownershio Assignement And ChangesBeta - Logs And Alerts Missing Audit Configuration Changes:Both of them have at the beginning of the query the patterns that the queries are covering. The filter field is analysed using the single_match helper function that firstly removes the white spaces from the filter and then lowers all the characters within. After that, the filter does the verification that is has to do using the
is_valid_filterhelper function.On the
Beta - Logs And Alerts Missing Project Ownershio Assignement And Changes, this helper functions returns true if the service name is valid (defined tocloudresourcemanager.googleapis.com), if(ProjectOwnership OR projectOwnerInvitee), if (action="REMOVE" AND role="roles/owner") is present and if(action="ADD" AND role="roles/owner"). All these verifications take into account that the conditions can change places and the cases when a NOT is used in the filter.For the query
Beta - Logs And Alerts Missing Audit Configuration Changesis more simple, as it firstly only checks if the following cases happen:SetIamPolicyANDauditConfigDeltas="*"NOT(NOT A OR NOT B) == A AND B.The query
Beta - Logs And Alerts Missing Custom Role Changestook a different approach regarding the way it handles the filter field.It uses the single_match helper function that firstly processes the filter by splitting it into an array with each element beginning with AND or OR operations, and then it checks if the field filter uses an improper filter using the
is_improper_filterhelper function.This is_impproper_filter helper function firstly checks if the resource.type is not defined to
iam.roleusing thecorrect_resource_typehelper function, and then, if the resource type is correctly defined, it checks the other methodNames using thecontains_methodhelper function.That
contains_methodhelper function firstly checks if there are not NOT statements in the methodNames being tackled by this query, and then it gathers a list of methodNames in the filters and checks if all of the four methodNames(CreateRole, DeleteRole, UpdateRole and UndeleteRole) are defined.If all the method names aren't defined, it checks if a wildcard(
protoPayload.nethodName="*") for the methodName is present in the filter.I submit this contribution under the Apache-2.0 license.