Skip to content

ci(security): allow the model-name and runtime-key test fixtures gitleaks reports as API keys - #1001

Closed
jussielo-amd wants to merge 1 commit into
mainfrom
ci-gitleaks-ignore-test-fixtures
Closed

jussielo-amd wants to merge 1 commit into
mainfrom
ci-gitleaks-ignore-test-fixtures

Conversation

@jussielo-amd

Copy link
Copy Markdown
Collaborator

Summary

The Security scan / gitleaks check, and its aggregate Security scan / Security scanners, fail on most open pull requests with three generic-api-key findings that are not secrets. This adds one allowlist entry to .github/scan_tools_configs/gitleaks.toml so they are no longer reported. No workflow file is touched.

What fails and why

The findings are unit-test fixture lines in two files, for example run 42698640628 on #984:

File and line (at commit 17f655d) Line What it is
apps/rocm/src/runtime_install_finalize.rs:1315 runtime_key: "wheel-gfx942-7.13.0".to_owned(), the key that names an installed runtime, in a test fixture
apps/rocm/src/serve_summary.rs:521 lemonade.api_model = "Qwen3-0.6B-GGUF".to_owned(); a model name in a unit test
apps/rocm/src/serve_summary.rs:549 summary.api_model = "Qwen3-4B-Instruct-2507-GGUF".to_owned(); a model name in a unit test

The generic-api-key rule fires on any identifier that contains key and is followed by a value that looks random. These values are model names and a runtime key, not credentials. The same three lines were flagged in 9 different PR runs, and on current main the two serve_summary.rs lines have moved to 557 and 585.

Why a fingerprint list in .gitleaksignore would not work

The scan range explains it. The reusable security workflow checks the pull request out with fetch-depth set to the number of PR commits plus two, fetches the PR base with depth 1, and runs gitleaks detect --log-opts base..head. The checkout is shallow, so gitleaks cannot see that the commit the branch started from is an ancestor of the base. That branch-point commit is therefore treated as a root commit that adds its whole tree, and every generic-api-key look-alike in that tree is reported, under a fingerprint that contains that commit's sha. In the runs I read, nine different branch-point commits produced the same three findings, so each new pull request would need its own fingerprints. A fingerprint entry would fix only the runs already seen and none that follow, which is why this uses the allowlist mechanism the config file describes for recurring patterns.

The change

One entry in the existing style of "Test fixtures using well-known dummy variable names": it is matched against the rule match, anchored on the identifier and the assignment, and covers only the field names runtime_key and api_model. A name such as api_key, OPENAI_API_KEY, secret_key or runtime_key_secret is still reported. Both field names hold identifiers by definition: api_model is a model name and runtime_key names an installed runtime.

What I verified and what only CI can show

  • The TOML parses, and the new regular expression matches the three flagged lines (and their moved copies on current main) and does not match api_key = "...", OPENAI_API_KEY = "...", secret_key: "..." or runtime_key_secret = "...".
  • I read the three lines at the commit the scanner reports and they are test fixtures.
  • gitleaks is not installed where I worked, so I could not run the scanner. Whether the check turns green is shown only by the security scan on this pull request, which reads the config from the scanned checkout. Note that this pull request's own scan runs with the config of its own head, so it is a direct test of the change.
  • Trivy, bandit and zizmor pass on the current runs; only gitleaks and the aggregate fail, so nothing else is changed.

Follow-up

If other generic-api-key look-alikes appear in later changes, extend the same allowlist entry with the identifier, not with fingerprints. The scan-range behaviour above belongs in the reusable security workflow; I did not change it here.

…eaks reports as API keys

The generic-api-key rule fires on identifiers that contain the word key. The unit tests of serve_summary.rs and runtime_install_finalize.rs assign model names and a made-up runtime key to runtime_key and api_model, and gitleaks reports them on every pull request whose branch point contains those lines. Allowlist the two field names, anchored on the assignment, in the same way as the existing entries for dummy variable names.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
@github-actions

Copy link
Copy Markdown
Contributor
Security scan found no critical or high findings on lines changed by this pull request

View the security scan run for complete reports.

“New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta.

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the gitleaks allowlist change targeting recurring test-fixture false positives.

No open issues 🎉

What changed in this PR

This PR adds a gitleaks allowlist entry to suppress recurring false positives for model-name and runtime-key test fixtures in security scans.

Changes:

  • Matches assignments to the exact identifiers runtime_key and api_model, rather than commit-specific fingerprints.
  • Documents the exception without changing security workflows or other scanner configurations.
File Description
.github/​scan_tools_configs/​gitleaks.toml Adds and explains the identifier-based allowlist entry.

Review effort: Balanced

@jussielo-amd

Copy link
Copy Markdown
Collaborator Author

Closing as a duplicate of #1000, which opened three minutes earlier and is the narrower change (Rust files only, exact assignment shape). The points from this PR that are worth taking over, including a wider pattern that also covers nine sibling lines on main, are in a comment on #1000: #1000 (comment)

@jussielo-amd
jussielo-amd deleted the ci-gitleaks-ignore-test-fixtures branch November 10, 2026 10:33
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