Skip to content

ci(security): allow model names and runtime keys assigned in Rust sources in gitleaks - #1000

Merged
jussielo-amd merged 4 commits into
mainfrom
ci-gitleaks-allow-model-and-runtime-names
Nov 10, 2026
Merged

jussielo-amd merged 4 commits into
mainfrom
ci-gitleaks-allow-model-and-runtime-names

Conversation

@jussielo-amd

@jussielo-amd jussielo-amd commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Stops the PR-time gitleaks scan from failing on two kinds of test fixture it misreads as credentials, which currently turns the Security scan / gitleaks and Security scanners checks red on any pull request whose scan window reaches a commit that contains them.

What fails and why

The generic-api-key rule matches api_model = "Qwen3-0.6B-GGUF" and runtime_key: "wheel-gfx942-7.13.0" because the variable name contains api or key and the value is a short mixed-case identifier. Both are public identifiers (a model repository name and a runtime install key), not credentials. They sit in unit-test fixtures in apps/rocm/src/serve_summary.rs and apps/rocm/src/runtime_install_finalize.rs.

The PRs that fail do not add those lines. The reusable security workflow (pinned at v1.0.8) checks the pull request out with a depth of the PR's commit count plus two, fetches the PR base with depth 1, and scans base..head. The head checkout is shallow, so gitleaks cannot see that the commit the branch started from is an ancestor of the base. That commit is read as a root commit that adds its whole tree, and every generic-api-key look-alike in it is reported under a fingerprint that contains that commit's sha. The findings therefore land on main commits and never on the PR's own diff. In the 29 runs read, nine different boundary commits produced the same three findings. A PR cut from the current main tip passes because its branch point is the base itself.

Why an allowlist entry and not fingerprints

A .gitleaksignore fingerprint contains the boundary commit's sha, which differs for each pull request, so a list of fingerprints would only fix runs already seen. The config file describes [[allowlists]] for recurring patterns, which is what this is.

The change

One [[allowlists]] entry in .github/scan_tools_configs/gitleaks.toml, Rust files only, matched against the rule's own match (not the whole line) with \b(api_model|runtime_key)\s*[:=]\s*"[A-Za-z0-9._/:-]+". Matching the finding's own match means a real credential on the same line is still reported under its own match; regexTarget = "line" would have hidden it. Both : (struct field) and = (assignment) are accepted for both names, and the value may hold / and :, so every one of the 33 unquoted-key string-literal assignments of these two names in Rust sources on main is covered (an earlier version of this entry covered 24). JSON-style quoted keys such as "runtime_key": "..." (20 more literals on main, in test JSON) are not covered; the scan does not report them today and the entry does not claim them. The value is capped at 64 characters (the longest value on main is 39), so a long token assigned to one of the two names is still reported. api_key, OPENAI_API_KEY, secret_key, runtime_key_secret, my_api_model, a value with a space and token = "Qwen3-0.6B-GGUF" are still reported.

What was checked and what only CI can show

The TOML parses. I ran the pattern over the 33 lines on main (all covered), over the look-alikes above (none allowed), and over the two matches of a mixed line holding a runtime_key field and an api_key field (only the runtime_key match is allowed). Gitleaks is not available where this was written and downloading it was not possible, so the scanner was not run locally. condition = "AND" (the path and the pattern must both match) is checked empirically: a throwaway draft PR (#1008, closed) ran the repository scan with this config on a probe file holding a random api_key literal, an api_model line and a mixed line with a runtime_key field next to a second api_key; gitleaks reported exactly the two api_key findings and neither the api_model line nor the runtime_key field. This PR's own scan passes trivially, because its branch point is the base, so it does not exercise the entry; the first real check is the scan on a pull request that carries this entry and whose window reaches an older commit.

Follow-up outside this repository

Scanning only the lines a pull request adds, instead of the whole tree at the boundary commit, would end this class of false alarm. That belongs in the reusable security workflow, so this entry is the local fix for now. No user-observable CLI behaviour changes, so there is no scenario.

…rces in gitleaks

The generic-api-key rule flags test fixtures such as an api_model assignment of a model repository name and a runtime_key of a wheel install key, because the variable name contains api or key. Both are public identifiers. A pull request whose scan window reaches a commit containing them (the scan checks out a depth-limited merge ref, so history that includes merges from main or a stale base puts such commits at the window boundary, where the whole tree reads as added) fails the scan though it touches neither line. Allow exactly those two assignment shapes in Rust files, anchored on the line, so api_key assignments are still scanned.

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

github-actions Bot commented Nov 10, 2026 •

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.

🟡 Changes recommended

The line-scoped Gitleaks exception can suppress unrelated real credentials on the same Rust line; it needs match-level scoping and mixed-line negative checks.

1 open issue
What changed in this PR

This PR adjusts the repository’s Gitleaks configuration to reduce false positives for public model names and runtime install keys in Rust fixtures.

Changes:

  • Adds a Rust-only allowlist for api_model assignments and runtime_key fields.
  • Documents why these identifiers are not credentials.

Verification was limited to configuration inspection; Gitleaks was not run.

File Description
.github/​scan_tools_configs/​gitleaks.toml Adds model/runtime identifier exceptions and explanatory comments.

Review effort: Balanced

@jussielo-amd

This comment was marked as resolved.

…he match, and cover both field shapes

Match against the rule's own match instead of the whole line, so a real credential on the same line is still reported under its own match. Accept both : and = for api_model and runtime_key, and a value character set that includes / and :, which covers all 33 assignments of these names in Rust sources on main instead of 24.

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

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.

🔵 Needs a closer look

The allowlist needs validation with pinned Gitleaks 8.30.1 on an affected historical scan window to confirm intended suppressions and detection of mixed-line credentials.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

…vides

The comment attributed the api_key exclusion to the Rust-only path limit; it comes from the two names the pattern lists. Also say that a JSON-style quoted key is not covered.

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

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.

🔵 Needs a closer look

The global allowlist still needs an end-to-end scan with pinned Gitleaks 8.30.1 to confirm fixture suppression without masking real credentials on the same line or in other files.

No open issues 🎉

Review effort: Balanced

@jussielo-amd
jussielo-amd marked this pull request as ready for review November 10, 2026 08:09
@jussielo-amd
jussielo-amd requested a review from a team as a code owner November 10, 2026 08:09

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. The exception is tightly scoped: exactly two names (api_model, runtime_key), .rs files only, matched against the rule's own match, and api_key assignments are still scanned. I ran the regex over the tree at this commit: all 33 unquoted api_model/runtime_key string literals in .rs files match, none are missed. CI is green, though the gitleaks job doesn't exercise the new entry.

Non-blocking:

  • condition = "AND" is what keeps this to Rust files (under the default OR the path alone would allowlist every rule in .rs files), and it hasn't been run against the pinned gitleaks 8.30.1. A one-off scan of a throwaway .rs with a random api_key next to an api_model line before merge would confirm it.
  • The value class has no length cap (acknowledged in the PR body).
  • gitleaks' generic-api-key capture may exclude :, so values like therock-release:gfx120X-all might not match the allowlist; that fails safe (the false alarm stays).

# characters a model name or a runtime key uses (`Qwen3-0.6B-GGUF`,
# `therock-release:gfx120X-all`). A JSON-style quoted key such as
# `"runtime_key": "..."` is not covered.
condition = "AND"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

condition = "AND" is what keeps this to Rust files; under the default OR the path alone would allowlist every rule in .rs files. Please run gitleaks 8.30.1 on a throwaway .rs holding a random api_key next to an api_model line before merge, and consider noting in the comment that AND is load-bearing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, and the comment above the entry now says plainly that condition = "AND" is load-bearing: under the default OR the paths entry alone would allowlist every rule in every .rs file, so it must not be removed. I could not run gitleaks 8.30.1 locally, because the binary is not installed in my environment and I was not able to fetch it. Instead the check is being run through the CI scan on a throwaway probe branch holding a .rs file with a random api_key next to an api_model line and a mixed line with both a runtime_key and a random api_key; the result will be posted here, and the probe branch will never be merged.

Result of the check: I ran the repository's PR-time scan, with this branch's config, on a throwaway draft pull request (#1008, closed after reading it) whose probe file holds a random 40-character api_key literal, an api_model = "Qwen3-0.6B-GGUF" line, and a mixed line with a runtime_key field next to a second random api_key. gitleaks reported exactly two findings, both generic-api-key: the standalone api_key literal and the api_key on the mixed line. The api_model line and the runtime_key field were not reported. So the path and pattern are combined with AND (a Rust file with a real-looking key is still scanned) and the match-level scoping holds on a mixed line.

]
regexTarget = "match"
regexes = [
'''\b(api_model|runtime_key)\s*[:=]\s*"[A-Za-z0-9._/:-]+"''',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Value class has no length bound; a long token assigned to exactly api_model/runtime_key in a .rs would be allowed (acknowledged in the PR body). Optional: cap the length.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done: the value class is now capped at 64 characters ([A-Za-z0-9._/:-]{1,64}), and the comment mentions the cap. The longest value assigned to api_model or runtime_key as a string literal in a .rs file on main is 39 characters, and all 33 such assignments are still matched by the capped pattern, while a 65-character value is not. Thanks for the suggestion.

…d-bearing

Review follow-up. Bound the allowlisted value to 64 characters so a long token assigned to api_model or runtime_key in a Rust file is still reported; the longest value assigned to either name on main is 39 characters. Also state in the comment that condition = AND is load-bearing: under the default OR the paths entry alone would allowlist every rule in every .rs file.

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

@nowycondro nowycondro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Automated review · review-code · head 00bad5e2

Review — no blocking findings

Full review of the whole change (single file, .github/scan_tools_configs/gitleaks.toml, +27/-0 lines). No ticket named.

Blocking

None

Non-blocking

None

Decisions for the author

  • The allowlist is scoped by field name across all .rs files, not just test code — tradeoff
    Both api_model and runtime_key are also used as struct field names in production (non-test) code, so narrowing the paths entry to test directories wasn't an option; the entry instead bounds its blast radius with a fixed two-name alternation and a 64-character value cap. A future real secret assigned to a field literally named api_model or runtime_key, fitting the character class and under 64 characters, anywhere in a .rs file, would be silently suppressed. This is the same shape of risk every other entry in this file already accepts (dummy-token names, SHA-suffix variable names) — confirm this tradeoff is intended rather than an oversight.

Positive signals

  • The regex, length cap, and condition = "AND" scoping were independently re-derived and traced by hand (word-boundary behavior against compound identifiers like my_api_model, RE2 anchoring of .*\.rs$, non-capture of JSON-style quoted keys) and all match what the entry's own comments claim.
  • Running the stated allowlist regex against every .rs file in the PR-head tree reproduces the PR body's own numbers exactly: 33 covered literals, longest value 39 characters, zero misses.

Deployment notes

None

What this covered

Read the single changed file in full, the complete gitleaks.toml (all four [[allowlists]] blocks) for consistency with existing entries, and the referenced Rust fixtures plus a repo-wide grep for every api_model/runtime_key string-literal assignment in .rs files, against bf8c334c13b80c41f002521630a5be6609e90326...00bad5e2aea069778ad0cb093b58e2dc47592c18. Independently reran the allowlist regex over the full tree and confirmed the PR body's quantitative claims (33 literals, max length 39, 0 missed). Checked AGENTS.md/CONTRIBUTING.md for conventions specific to security-scan config changes (none found), this file's complete git history (one prior commit, which created it wholesale), and GitHub PR search for earlier changes to this file (none merged; found two related closed PRs — #1001, a superseded duplicate attempt, and #1008, a throwaway probe the author used to validate condition = "AND" behavior empirically). CI is green on the reviewed commit, including Security scan / gitleaks, though as the PR body itself discloses, this PR's own scan run doesn't exercise the new entry since its branch point is the base commit.

Did not run: gitleaks itself (not available in this environment; verified by direct regex tracing instead, the same method the author used). The prior-changes pass found no merged precedent to compare against beyond the two closed/superseded PRs noted above.

Not reconciled against this PR's open review threads (existing bot and human comments) — this review was conducted blind to them, per the review-code methodology.


Not a human review. This is an automated code review; please verify findings independently before acting on them.

Merged via the queue into main with commit 2ce639b Nov 10, 2026
46 checks passed
@jussielo-amd
jussielo-amd deleted the ci-gitleaks-allow-model-and-runtime-names branch November 10, 2026 10:54
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.

4 participants