Parse a new "arguments" keyword in new IaC v1.4 config#206
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9c11854 to
d441bb4
Compare
|
🎯 Code Coverage (details) 🔗 Commit SHA: 8eeff26 | Docs | Datadog PR Page | Give us feedback! |
4ce283c to
120ef4c
Compare
fced47c to
c1a0cdc
Compare
120ef4c to
d32f8f8
Compare
c1a0cdc to
ab97dfd
Compare
d32f8f8 to
7b56423
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b5642387b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
7b56423 to
b8cb162
Compare
ab97dfd to
8637be8
Compare
b8cb162 to
16344df
Compare
8637be8 to
fd6d7a5
Compare
16344df to
adf4194
Compare
fd6d7a5 to
fb2dff3
Compare
30a3d63 to
85756c2
Compare
39aba83 to
da03d70
Compare
85756c2 to
0767aa5
Compare
da03d70 to
f4324d9
Compare
380edfd to
b815bee
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
@barbiergaspard While reviewing this change, I noticed a potential issue around how override arguments are resolved for aggregate rules. I used AI to help review this, so I may be missing some domain context; please treat this as something to validate rather than a definitive blocker. Bug: single-override arguments are injected globally across all aggregate branchesThe argument-lookup logic has a cross-contamination problem for aggregate rules with multiple overrides. What happens today
// inspector.go ~785
if rc, found := lookupRuleConfig(ruleConfigs, *overrideID, ""); found && rc.Arguments != nil {
if matched != nil {
return nil, false, fmt.Errorf("multiple override argument configs match aggregated rule %s", queryID)
}
matched = rc.Arguments
}When exactly one override ID has arguments in its rule config, those arguments are returned without error and injected globally. Every branch in the Rego evaluation — AWS, Azure, GCP, etc. — then sees the same The Concrete impactGiven an aggregate rule with overrides
The ambiguity guard doesn't helpThe error on "multiple override argument configs" (line ~787) actually makes things worse: it prevents the correct fix (per-override arguments) while still silently allowing single-override cross-contamination. Two clean remediesOption A — restrict to aggregate-level only: Reject arguments configured under any individual override ID at lookup time and require them to be on the aggregate rule ID. Cross-contamination becomes impossible by construction. Option B — key arguments by override: Instead of a flat |
b815bee to
3d9d724
Compare
|
@robertohuertasm-datadog Yes, this bug was a real issue. Looking into it, I have a better understanding of how overrides work, and if my understanding is correct, overrides should not contain arguments. so I removed my last commit, that was related to overrides. Just to be sure we are on the same page, here is my current understanding of the overrides :
Since the override key depends on the result of the scan, and the result of the scan depends on arguments, we can't have arguments in the override or that would lead to circular dependancies. This is why I removed the override commit. I also added a commit to fix some e2e tests |
2fd85fd to
c4b827a
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4b827a2ad
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| queryID, legacyQueryID := queryIDsFromMetadata(ctx, &qCtx.Query.Metadata) | ||
| if rc, found := lookupRuleConfig(c.ruleConfigs, queryID, legacyQueryID); found { |
There was a problem hiding this comment.
Apply rule arguments to override IDs
When a rule has Datadog metadata overrides, configs are keyed by the effective override ID: the builder later resolves vulnerability.QueryID from overrideKey (pkg/engine/vulnerability_builder.go:170), and ConvertRule stores override IDs in metadata (pkg/engine/source/datadog.go:255-270). This lookup only checks the base metadata ID before evaluation, so rule-configs:<override-id>: arguments: is ignored and the rule sees no input.arguments, even though severity/path configs for the same override ID still work after decode.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The override values depend on the rule's overrideKey, which depends on the result of the query. This results depends on the arguments. Arguments are not and should not be included in overrides
There was a problem hiding this comment.
NIT: Shouldn't this be v1.4 features?
c4b827a to
8536c42
Compare
1a59a55 to
6a630a1
Compare
6a630a1 to
1cc8ea0
Compare
Bump all tests to version 1.4. This implies renaming functions as well as files. Add a new TestV14_RuleConfig_Arguments_ArePassedToRule to the e2e tests.
1cc8ea0 to
8eeff26
Compare

Motivation
As seen in the linked Jira ticket, there is customer demand for adding arguments to the rule-configs. Currently, the rule-configs only allow to change which files and severities are read or ignored by a certain rules. Rule-specific arguments management would allow customers to fine-tune how they use the different rules.
JIRA Ticket : https://datadoghq.atlassian.net/browse/K9CODESEC-1940
Changes
This PR adds support for rule-specific
argumentsin IaC rule configs.It bumps the emitted IaC config schema version to
v1.4, parses and unparses anargumentsblock underiac.rule-configs.<rule-id>, stores those arguments onIacRuleConfig, and passes them to the policy input so rules can use customer-provided values at evaluation time.It also adds/updates tests for:
argumentsin rule configs.argumentsis accepted in the right config section.required_tags.Author Checklist
These changes have been tested on a real repository (except for the override support)
QA Instruction
You can verify that all tests currently pass. You can verify that if you tweak the values in TestV14_RuleConfig_Arguments_ArePassedToRule as well as in TestParseUnparseRoundTripV14 for the arguments, those tests should fail.
If you wish to go further, you can clone my branch of the datadoc-iac-scanner-default-rules repo, linked to this PR with a POC for arguments in 2 rules, and use the -q flag to specify a path to the rules directory. Arguments have been implemented for the
cicd-github-unpinned-actions-full-length-commit-shaand thedockerfile-use-only-an-allowed-registry-in-the-from-imagerules. You can test those changes by looking up which repo contains violations of those rules, and using the "allow" argument to reduce the number of findings.Blast Radius
This change impacts only Datadog IaC Scanner configuration parsing and rule evaluation. It does not affect external services or infrastructure.
The main compatibility surface is the IaC config schema: existing configs should continue to work, while newly generated configs now use schema version v1.4.
Additional Notes
This PR introduces generic argument plumbing only. Each rule still needs to explicitly read and use the arguments it supports.
I submit this contribution under the Apache-2.0 license.