From 691a2aec22a8286e67fb585c3da3be2a9ebf6ecb Mon Sep 17 00:00:00 2001 From: Jussi Elo Date: Tue, 10 Nov 2026 05:40:46 +0000 Subject: [PATCH 1/4] 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/4] 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/4] 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/4] 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}"''', ]