Skip to content

Rename _kics_* AST keys to _dd_* with backward-compatible shim#176

Merged
whitemerch merged 1 commit into
mainfrom
chakib.hamie/rename_kics_ast_keys
Jun 3, 2026
Merged

Rename _kics_* AST keys to _dd_* with backward-compatible shim#176
whitemerch merged 1 commit into
mainfrom
chakib.hamie/rename_kics_ast_keys

Conversation

@whitemerch

Copy link
Copy Markdown
Contributor

Motivation

The parsed document AST uses _kics_line, _kics_lines, _kics_filter_expr etc. as field names, inherited from KICS. Nine rules in datadog-iac-scanner-default-rules reference these keys directly in Rego. This renames them to _dd_* while keeping both old and new fields emitted during migration so the two repos can be deployed independently.

Changes

Parsers (retrocompat — both keys emitted)

docker.Command and buildah.Command now emit both _kics_line (legacy) and _dd_line. jsonfilter.AWSJSONFilter emits both _kics_filter_expr (legacy) and _dd_filter_expr. Old rules using the legacy keys continue to produce findings.

Parsers (direct rename — internal keys, no rego visibility)

_kics_lines_dd_lines, _kics__default_dd__default, _kics_arr_dd_arr across all converters (Terraform, gRPC, JSON, YAML, Bicep) and model.LineObject JSON tags.

Detector

All _kics_* path strings in pkg/detector/search_line_detector.go updated to _dd_*.

Tests

Test fixtures and inline assertions updated to reflect both old and new keys where retrocompat applies; struct and marshal tests updated to compare only the canonical new field.

QA Instruction

  1. go test ./pkg/parser/... ./pkg/detector/... ./pkg/model/... ./pkg/kics/...
  2. Run a full scan against a Terraform + Dockerfile fixture and confirm line numbers are reported correctly.
  3. To verify backward compat: temporarily revert one Dockerfile rego rule to _kics_line and confirm findings still appear.

Impact

Affects every parser's document output. No change in scan findings — both field names are present in the document during migration. The companion rules PR updates the 9 rego rules that reference these keys directly.

@datadog-datadog-prod-us1-2

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

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 92.78%
Overall Coverage: 47.85% (-0.03%)

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

@whitemerch
whitemerch marked this pull request as ready for review June 3, 2026 12:04
@whitemerch
whitemerch requested a review from a team as a code owner June 3, 2026 12:04
Comment thread pkg/parser/bicep/parser.go Outdated
Comment thread pkg/parser/bicep/parser.go Outdated
Comment thread pkg/parser/buildah/parser_test.go
Comment thread pkg/parser/buildah/parser.go Outdated
Comment thread pkg/parser/docker/parser.go Outdated
Comment thread pkg/parser/jsonfilter/json_filter_test.go Outdated
Comment thread pkg/parser/jsonfilter/parser/jsonfilter_tree_visitor.go Outdated
@whitemerch
whitemerch force-pushed the chakib.hamie/rename_kics_ast_keys branch 3 times, most recently from de60e79 to dd82617 Compare June 3, 2026 12:52
@whitemerch
whitemerch force-pushed the chakib.hamie/rename_kics_ast_keys branch from dd82617 to f8f0b22 Compare June 3, 2026 13:14
@whitemerch
whitemerch merged commit 52452dc into main Jun 3, 2026
18 checks passed
@whitemerch
whitemerch deleted the chakib.hamie/rename_kics_ast_keys branch June 3, 2026 13:49
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