Skip to content

Relax test-rules required field contract for presentation-only fields#220

Merged
whitemerch merged 1 commit into
mainfrom
chakib.hamie/relax_test_rules_required_fields
Jun 30, 2026
Merged

Relax test-rules required field contract for presentation-only fields#220
whitemerch merged 1 commit into
mainfrom
chakib.hamie/relax_test_rules_required_fields

Conversation

@whitemerch

Copy link
Copy Markdown
Contributor

Motivation

Rule results no longer emit issueType, keyExpectedValue, or keyActualValue as of a schema relaxation applied to the rule assets (equivalent of the contract change already shipped in the rule-assets repo). The test-rules validator still listed them as required fields, causing every test-rules CI run to fail for Ansible and other rules that dropped those optional presentation fields.

Changes

Rule test validator

Removed issueType, keyExpectedValue, and keyActualValue from the resultShape.Required list in cmd/scanner/test_rules.go. The allowedIssueTypes guard on the issueType value is kept, so results that do include the field are still validated; only the presence check is relaxed.

Author Checklist

  • I have reviewed my own PR.
  • I have added or updated relevant unit tests where necessary. If no tests are added, I've explained why.
  • All new and existing tests pass.
  • I have tested my changes on staging (if applicable).
  • I have updated any relevant documentation (if applicable).

QA Instruction

Run ./bin/datadog-iac-scanner test-rules (with a valid API key) and confirm that Ansible AWS rules no longer produce Result missing required field failures. Alternatively, let the test-rules CI job on this PR go green.

Blast Radius

Only the test-rules command is affected. No change to scan output, findings, SARIF, or any runtime path.

Additional Notes

N/A

I submit this contribution under the Apache-2.0 license.

…les required-field contract to match the relaxed rule output schema.
@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Jun 29, 2026

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

test-rules | test-rules   View in Datadog   GitHub Actions

ℹ️ Info

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 49.95% (+0.00%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: dff4b4f | Docs | Datadog PR Page | Give us feedback!

@whitemerch
whitemerch marked this pull request as ready for review June 29, 2026 22:15
@whitemerch
whitemerch requested a review from a team as a code owner June 29, 2026 22:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dff4b4fe46

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/scanner/test_rules.go
"issueType",
"keyExpectedValue",
"keyActualValue",
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep validating report-backed fields

When backend rules omit these fields (the schema-relaxation case this change is intended to allow), runtime output is not actually fieldless: a missing issueType is defaulted to IncorrectValue (pkg/engine/inspector.go:55, pkg/engine/vulnerability_builder.go:175-177), and missing expected/actual values become empty strings that reports render directly (for example pkg/report/template/html/report.tmpl:104-105 and pkg/report/model/csv.go:59-64). Relaxing the test-rules contract here lets rules pass CI while producing mislabeled issue types and blank Expected/Found text in scanner outputs, so keep these required for report-backed outputs or add builder/report fallbacks before removing the validation.

Useful? React with 👍 / 👎.

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.

we are removing them, and we actually removed them from the rules so it's alright

@ChouraquiBen ChouraquiBen 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!

@whitemerch
whitemerch merged commit a038543 into main Jun 30, 2026
19 of 20 checks passed
@whitemerch
whitemerch deleted the chakib.hamie/relax_test_rules_required_fields branch June 30, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants