Skip to content

Commit 94674a3

Browse files
author
OpenCode Agent
committed
fix(validators): don't flag runtime secret assignments; fix openchamber MD028
Two CI failures on the openchamber kit PR: - Markdown Lint (MD028): a blank line between two blockquotes in the kit README joined them into one block. Replace the blank line with a '>' continuation line. - Pattern Validation (sensitive terms): the hardcoded-secret regexes flagged shell assignments whose value is a command substitution or variable reference (e.g. OPENCODE_SERVER_PASSWORD="$(cat ...)"). Those read a secret at runtime, they don't embed a literal, so this was a false positive. Add a negative lookahead so values starting with $ or backtick (after an optional quote) are not treated as hardcoded. A real literal (password="...") is still flagged. Adds unit tests for both the still-flagged and no-longer-flagged cases.
1 parent 18375d9 commit 94674a3

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

‎integrations/isolation/sbx-kits/openchamber/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ sbx run opencode --kit "git+https://github.com/GSA-TTS/agentic-coding-patterns.g
6363
> created. `sbx kit add` on a *running* sandbox skips the port mapping, so add
6464
> this kit with `--kit` at create time (recreate the sandbox if it already
6565
> exists).
66-
66+
>
6767
> **On HTTPS-inspected networks (e.g. Zscaler).** OpenChamber's first-boot
6868
> install downloads a prebuilt native binary; behind an inspecting proxy that
6969
> download only validates if the inspection CA is in the sandbox's system trust

‎scripts/tests/test_validate_sensitive_terms.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,31 @@ def test_tier1_always_blocking(self, tmp_path):
255255

256256
# Private keys should be detected even in SECURITY.md
257257
assert len(tier1_matches) > 0
258+
259+
def test_hardcoded_password_still_flagged(self, tmp_path):
260+
"""A literal hardcoded password value is still a blocking Tier 1 match."""
261+
file_path = tmp_path / "app.sh"
262+
file_path.write_text('password="hunter2hardcoded"\n')
263+
264+
tier1_matches, _ = scan_file(file_path)
265+
266+
assert any("password" in desc.lower() for _, desc, _ in tier1_matches)
267+
268+
def test_runtime_password_assignment_not_flagged(self, tmp_path):
269+
"""Assigning a secret from a command substitution / var ref is not hardcoding.
270+
271+
These read the value at runtime (they don't embed a literal), so flagging
272+
them is a false positive. Covers the openchamber kit's
273+
OPENCODE_SERVER_PASSWORD="$(cat ...)" style.
274+
"""
275+
file_path = tmp_path / "startup.sh"
276+
file_path.write_text(
277+
'OPENCODE_SERVER_PASSWORD="$(cat "$PW_FILE")"\n'
278+
'PASSWORD="$PW"\n'
279+
"password=${SOME_VAR}\n"
280+
"password=`cat /run/secret`\n"
281+
)
282+
283+
tier1_matches, _ = scan_file(file_path)
284+
285+
assert tier1_matches == [], f"unexpected matches: {tier1_matches}"

‎scripts/validate_sensitive_terms.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@
2424
(r"BEGIN.*PRIVATE KEY", "Private key detected"),
2525
(r"AWS_SECRET_ACCESS_KEY", "AWS secret key"),
2626
(r"AWS_ACCESS_KEY_ID", "AWS access key"),
27-
(r"(?:password|passwd|pwd)\s*=\s*['\"]?[^'\"\\s]{8,}", "Hardcoded password"),
28-
(r"(?:api_key|apikey)\s*=\s*['\"]?[^'\"\\s]{16,}", "API key"),
29-
(r"(?:token|auth_token)\s*=\s*['\"]?[^'\"\\s]{16,}", "Auth token"),
30-
(r"secret\s*=\s*['\"]?[^'\"\\s]{16,}", "Secret value"),
27+
# Assignment patterns. The negative lookahead skips values that are shell
28+
# command substitutions ($(...), `...`) or variable references ($VAR,
29+
# ${VAR}) — those read a secret at runtime, they don't hardcode one, and
30+
# flagging them produces false positives on legitimate scripts.
31+
(r"(?:password|passwd|pwd)\s*=\s*['\"]?(?![`$])[^'\"\\s]{8,}", "Hardcoded password"),
32+
(r"(?:api_key|apikey)\s*=\s*['\"]?(?![`$])[^'\"\\s]{16,}", "API key"),
33+
(r"(?:token|auth_token)\s*=\s*['\"]?(?![`$])[^'\"\\s]{16,}", "Auth token"),
34+
(r"secret\s*=\s*['\"]?(?![`$])[^'\"\\s]{16,}", "Secret value"),
3135
(r"\.gov\s+internal-only", "Internal-only government content"),
3236
(r"do\s+not\s+distribute", "Distribution restriction marker"),
3337
]

0 commit comments

Comments
 (0)