diff --git a/.github/scan_tools_configs/gitleaks.toml b/.github/scan_tools_configs/gitleaks.toml index f50c51eb9d..13c7b2f37f 100644 --- a/.github/scan_tools_configs/gitleaks.toml +++ b/.github/scan_tools_configs/gitleaks.toml @@ -80,3 +80,30 @@ 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. 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. +# 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`), 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._/:-]{1,64}"''', +] 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.