From 691a2aec22a8286e67fb585c3da3be2a9ebf6ecb Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Tue, 10 Nov 2026 05:40:46 +0000 Subject: [PATCH 1/5] ci(security): allow model names and runtime keys assigned in Rust sources 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 --- .github/scan_tools_configs/gitleaks.toml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/scan_tools_configs/gitleaks.toml b/.github/scan_tools_configs/gitleaks.toml index f50c51eb9d..c37cacf8b1 100644 --- a/.github/scan_tools_configs/gitleaks.toml +++ b/.github/scan_tools_configs/gitleaks.toml @@ -80,3 +80,21 @@ regexes = [ '''[A-Z][A-Z0-9_]*SHA512\s*[=:]''', '''[A-Z][A-Z0-9_]*MD5\s*[=:]''', ] + +[[allowlists]] +description = "Model names and runtime keys assigned in first-party Rust code" +# The generic-api-key rule fires on `api_model = "Qwen3-0.6B-GGUF"` and +# `runtime_key: "wheel-gfx942-7.13.0"` because the variable name contains +# "key" or "api" and the value is a short mixed-case identifier. Both are +# public identifiers (a model repository name, a runtime install key), not +# credentials. Anchored on the whole line and limited to Rust sources so an +# `api_key = "..."` assignment is still scanned. +condition = "AND" +paths = [ + '''.*\.rs$''', +] +regexTarget = "line" +regexes = [ + '''\bapi_model\s*=\s*"[A-Za-z0-9._/:-]+"''', + '''\bruntime_key:\s*"[A-Za-z0-9._-]+"''', +] From c1947589cc8069ddd164755f8a2f296764125e97 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Tue, 10 Nov 2026 05:58:56 +0000 Subject: [PATCH 2/5] ci(security): scope the gitleaks model and runtime-key exception to the 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 --- .github/scan_tools_configs/gitleaks.toml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/scan_tools_configs/gitleaks.toml b/.github/scan_tools_configs/gitleaks.toml index c37cacf8b1..1ab27dbc1f 100644 --- a/.github/scan_tools_configs/gitleaks.toml +++ b/.github/scan_tools_configs/gitleaks.toml @@ -87,14 +87,17 @@ description = "Model names and runtime keys assigned in first-party Rust code" # `runtime_key: "wheel-gfx942-7.13.0"` because the variable name contains # "key" or "api" and the value is a short mixed-case identifier. Both are # public identifiers (a model repository name, a runtime install key), not -# credentials. Anchored on the whole line and limited to Rust sources so an -# `api_key = "..."` assignment is still scanned. +# credentials. Matched against the rule's own match, not the whole line, so +# a real credential on the same line is still reported under its own match, +# and limited to Rust sources so an `api_key = "..."` assignment is still +# scanned. Both `:` (struct field) and `=` (assignment) are accepted for both +# names, and the value may hold the characters a model name or a runtime key +# uses (`Qwen3-0.6B-GGUF`, `therock-release:gfx120X-all`). condition = "AND" paths = [ '''.*\.rs$''', ] -regexTarget = "line" +regexTarget = "match" regexes = [ - '''\bapi_model\s*=\s*"[A-Za-z0-9._/:-]+"''', - '''\bruntime_key:\s*"[A-Za-z0-9._-]+"''', + '''\b(api_model|runtime_key)\s*[:=]\s*"[A-Za-z0-9._/:-]+"''', ] From 036df7780d533bb5247a21ccc3b4756c41d96803 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Tue, 10 Nov 2026 06:27:50 +0000 Subject: [PATCH 3/5] ci(security): say which scope each part of the gitleaks exception provides 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 --- .github/scan_tools_configs/gitleaks.toml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/scan_tools_configs/gitleaks.toml b/.github/scan_tools_configs/gitleaks.toml index 1ab27dbc1f..269d77d3bc 100644 --- a/.github/scan_tools_configs/gitleaks.toml +++ b/.github/scan_tools_configs/gitleaks.toml @@ -88,11 +88,14 @@ description = "Model names and runtime keys assigned in first-party Rust code" # "key" or "api" and the value is a short mixed-case identifier. Both are # public identifiers (a model repository name, a runtime install key), not # credentials. Matched against the rule's own match, not the whole line, so -# a real credential on the same line is still reported under its own match, -# and limited to Rust sources so an `api_key = "..."` assignment is still -# scanned. Both `:` (struct field) and `=` (assignment) are accepted for both -# names, and the value may hold the characters a model name or a runtime key -# uses (`Qwen3-0.6B-GGUF`, `therock-release:gfx120X-all`). +# a real credential on the same line is still reported under its own match. +# Only the two names `api_model` and `runtime_key` are listed, so an +# `api_key = "..."` assignment is still scanned; the Rust-only path limit keeps +# the exception out of other file types. Both `:` (struct field) and `=` +# (assignment) are accepted for both names, and the value may hold the +# 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" paths = [ '''.*\.rs$''', From 00bad5e2aea069778ad0cb093b58e2dc47592c18 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Tue, 10 Nov 2026 09:53:05 +0000 Subject: [PATCH 4/5] ci(gitleaks): cap model and runtime key value length, note AND is load-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 --- .github/scan_tools_configs/gitleaks.toml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/scan_tools_configs/gitleaks.toml b/.github/scan_tools_configs/gitleaks.toml index 269d77d3bc..13c7b2f37f 100644 --- a/.github/scan_tools_configs/gitleaks.toml +++ b/.github/scan_tools_configs/gitleaks.toml @@ -94,13 +94,16 @@ description = "Model names and runtime keys assigned in first-party Rust code" # the exception out of other file types. Both `:` (struct field) and `=` # (assignment) are accepted for both names, and the value may hold the # 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. +# `therock-release:gfx120X-all`), up to 64 characters, so a long token +# assigned to one of the two names is still reported. A JSON-style quoted key +# such as `"runtime_key": "..."` is not covered. +# `condition = "AND"` is load-bearing: under the default OR, the `paths` entry +# alone would allowlist every rule in every `.rs` file. Do not remove it. condition = "AND" paths = [ '''.*\.rs$''', ] regexTarget = "match" regexes = [ - '''\b(api_model|runtime_key)\s*[:=]\s*"[A-Za-z0-9._/:-]+"''', + '''\b(api_model|runtime_key)\s*[:=]\s*"[A-Za-z0-9._/:-]{1,64}"''', ] From d33e550af1153cc1280980de3bda099546531401 Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Tue, 10 Nov 2026 09:59:05 +0000 Subject: [PATCH 5/5] probe: throwaway gitleaks scan fixture, never merge Random strings only, for a CI scan experiment on the allowlist entry. Not declared as a module. Signed-off-by: Jussi Elo --- crates/rocm-core/src/gitleaks_probe_throwaway.rs | 13 +++++++++++++ docs/architecture.md | 1 + 2 files changed, 14 insertions(+) create mode 100644 crates/rocm-core/src/gitleaks_probe_throwaway.rs diff --git a/crates/rocm-core/src/gitleaks_probe_throwaway.rs b/crates/rocm-core/src/gitleaks_probe_throwaway.rs new file mode 100644 index 0000000000..ff47fac220 --- /dev/null +++ b/crates/rocm-core/src/gitleaks_probe_throwaway.rs @@ -0,0 +1,13 @@ +// Copyright © Advanced Micro Devices, Inc., or its affiliates. +// +// SPDX-License-Identifier: MIT + +// THROWAWAY PROBE FILE for a CI gitleaks scan experiment. It must never be +// merged and is deliberately not declared as a module. The strings below are +// random and are not real credentials. + +fn probe() { + let api_key = "iN4wMf5AlkBS2eu9rzFIJd5inK3bAGpVYGAPnhI3"; + let model = ModelCfg { api_model: "Qwen3-0.6B-GGUF" }; + let cfg = Cfg { runtime_key: "wheel-gfx942-7.13.0", api_key: "k6HFrDPZBnWYsceBbtddCkDdh1m7D6N2VJUUGgmL" }; +} diff --git a/docs/architecture.md b/docs/architecture.md index 93dca4dc8d..e5bffb69f8 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -238,6 +238,7 @@ Further `rocm-core` modules, each with its own doc comment except where noted: - [`browser.rs`](../crates/rocm-core/src/browser.rs) — handing a URL to the user's browser, behind a trait so the opening can be replaced in tests. - [`disk_space.rs`](../crates/rocm-core/src/disk_space.rs) — free-space preflight checks and out-of-space error reporting. - [`fake_executable.rs`](../crates/rocm-core/src/fake_executable.rs) — writing stand-in executables that tests across the workspace then run. +- [`gitleaks_probe_throwaway.rs`](../crates/rocm-core/src/gitleaks_probe_throwaway.rs) — a throwaway fixture for a CI gitleaks scan experiment on the `.github/scan_tools_configs/gitleaks.toml` allowlist; it holds random strings, is not declared as a module, and must never be merged. - [`fix.rs`](../crates/rocm-core/src/fix.rs) — `rocm fix`: remediations for diagnosed failure modes. Its `RECIPES` list (in [`fix/catalog.rs`](../crates/rocm-core/src/fix/catalog.rs)), together with the checkers under `diagnose/` (their table is [`catalog.rs`](../crates/rocm-core/src/diagnose/catalog.rs)), is the authoritative failure catalog. [`fix.rs`](../crates/rocm-core/src/fix.rs) stays the module root, as [`examine.rs`](../crates/rocm-core/src/examine.rs) does for `examine/`, so links to it stay valid, with its children in `fix/`; it keeps the dispatch (`apply`, `Plan`, `plan_of`, `act_on`) and re-exports the names the rest of the crate and the apps use, so `crate::fix::exit`, `rocm_core::fix_exit`, `rocm_core::fix::FixClass` and the `crate::fix::` oracles that the tests under `diagnose/` call keep resolving. The children are private modules: [`fix/options.rs`](../crates/rocm-core/src/fix/options.rs) (the named exit codes, `FixOptions` and `FixClass`); [`fix/consent.rs`](../crates/rocm-core/src/fix/consent.rs) (the consent decision and `confirm`, the run and query timeouts, `current_os`, and the `fail!` helper, which it re-exports by path for its siblings); [`fix/runners.rs`](../crates/rocm-core/src/fix/runners.rs) (the host-mutating runners, one per auto-applicable fix, with their rc-file, PATH and device-pin helpers; only the four entry points the catalog names are visible to the root, and the `*_windows` variants are ordinary functions that every platform compiles); [`fix/catalog.rs`](../crates/rocm-core/src/fix/catalog.rs) (`FixRecipe`, the per-platform class table, `RECIPES`, the lookups by fix-id, and the `cfg(test)` oracles [`diagnose.rs`](../crates/rocm-core/src/diagnose.rs) and the e2e crate hold their own copies to); [`fix/render.rs`](../crates/rocm-core/src/fix/render.rs) (`list_recipes`, a recipe's plan and verify lines, `format_flags`, and the refusal for a diagnosis position passed as a fix-id); and [`fix/manifest.rs`](../crates/rocm-core/src/fix/manifest.rs) (the published JSON contract, `CATALOG_CONTRACT_VERSION` and `catalog_manifest`). `render` and `manifest` read `RECIPES` from `catalog`; nothing in `catalog` reads either. - [`foreign_temp_probe.rs`](../crates/rocm-core/src/foreign_temp_probe.rs) — a test probe, compiled only for this crate's tests and under the `test-support` feature, that checks a writer leaves another writer's temp files alone; shared by this crate's tests and the tests of the crates that publish through `atomic_write.rs`. - [`hardware_root.rs`](../crates/rocm-core/src/hardware_root.rs) — the root the hardware probes resolve host paths through (`host_path`): the real host in a normal build, a simulated host tree for the E2E suite in an `e2e-test-hooks` build. It also owns `read_os_release` (the `/etc/os-release` read with its `/usr/lib/os-release` fallback) and `real_os_release`, the one reader every package-manager plan and install hint uses, which always reads the real host even under a simulated root; the resolver it passes is private, so a second copy of that reader cannot be written outside this module.