fix(sanitize): don't reverse-flag path/URL env values as leaks (unblock main CI)#568
Merged
Merged
Conversation
detectEnvValueLeaks reverse-scans every process.env value and flags any that appears verbatim in content. CI tooling exports many env vars whose value is the repo checkout path: the runner sets GITHUB_WORKSPACE / RUNNER_WORKSPACE, and `npm test` additionally sets INIT_CWD / npm_config_local_prefix / npm_package_json / PWD — all = /home/runner/work/evolver/evolver. Each is a substring of capsule content that legitimately references the build path, so the reverse scan reported a false-positive leak. This (a) failed test/sanitize.test.js:280 on every CI run while passing locally, and (b) would block every self-PR created from CI over its own runner path. Filesystem paths and URLs are not secrets, so skip path/URL-shaped env values in the reverse scan. Genuine sensitive paths in content are still caught by the local_path pattern scanner and credentialed URLs by db_url / basic_auth — the reverse scan exists for non-pattern-matchable hardcoded secret values, which are never paths/URLs. Regression test sets the runner/npm checkout-path vars and asserts fullLeakCheck stays clean, plus asserts a non-path secret value is still reverse-detected so the security guarantee is locked in. main CI had been red since at least v1.88.3 (2026-06-06), including on docs-only commits that never touched sanitize — confirming an environmental (env-dependent) failure, not a code regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0b1a62a to
6e5bc12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mainCI (test.yml→npm test) has been red since at least v1.88.3 (2026-06-06) — always failing the same way:It fails even on docs-only commits that never touched sanitize, and
node --test test/sanitize.test.jspasses locally. So the break is environmental, not a code regression. (macOS/Windowstest-crossjobs pass — only the ubuntutestjob is red.)Root cause
sanitize.test.jsasserts (top-level, not inside atest()block, so any throw exits the whole file):fullLeakCheck→detectEnvValueLeaksreverse-scans everyprocess.envvalue and flags any (len ≥ 8) that appears verbatim in the content. The pattern scanner allowlists/home/runner/paths, but the env-value reverse scan bypassed that allowlist.In CI, several env vars equal the repo checkout path
/home/runner/work/evolver/evolver— a substring of the fixture:GITHUB_WORKSPACE,RUNNER_WORKSPACEnpm test, npm also setsINIT_CWD,npm_config_local_prefix,npm_package_json,PWDAny one of them trips the reverse scan →
found: true→ assertion fails → top-level throw → file exits 1. Locally these are unset (or point elsewhere), so it passes.Reproduce locally (note: must inject an npm-style var, since a bare
node --testwon't setINIT_CWD):This is also a real product bug: in genuine CI use, any self-PR whose capsule content references the runner workspace path would be blocked by its own leak check.
Fix
Skip path/URL-shaped env values in
detectEnvValueLeaks(one rule instead of chasing individual var names):Filesystem paths and URLs are not secrets. Genuine sensitive paths in content are still caught by the
local_pathpattern scanner, and credentialed URLs bydb_url/basic_auth. The reverse scan exists to catch non-pattern-matchable hardcoded secret values — which are never paths/URLs.Regression test sets the runner/npm checkout-path vars (
GITHUB_WORKSPACE,INIT_CWD,npm_config_local_prefix) and assertsfullLeakCheckstays clean, and asserts a non-path secret env value is still reverse-detected — so the security guarantee is locked in.Verification
INIT_CWD=… GITHUB_WORKSPACE=… npm_config_local_prefix=… npm_package_json=… RUNNER_WORKSPACE=… node --test test/sanitize.test.js) → pass (70 assertions) (was failing)node --test test/sanitize.test.js→ pass (70 assertions)🤖 Generated with Claude Code
Note
Medium Risk
Narrows env-value reverse detection for all path/URL-shaped vars; non-secret strings could slip through if they aren't caught by pattern scanners, though tests assert real secrets still fail.
Overview
detectEnvValueLeaksno longer reverse-matches env values that look like filesystem paths or URLs (Unix/…, WindowsC:\…, orscheme://…). That stops CI/npm checkout paths in vars likeGITHUB_WORKSPACE,INIT_CWD, andnpm_config_local_prefixfrom being treated as hardcoded secrets when capsule text mentions the same path—fixing CI-only failures intest/sanitize.test.jsand avoiding self-PR blocks on legitimate build traces.test/sanitize.test.jsadds a regression block that sets those env vars to a runner-style path, assertsfullLeakCheckstays clean on path-containing content, and asserts a non-path secret env value is still detected (70 assertions total).Reviewed by Cursor Bugbot for commit 6e5bc12. Bugbot is set up for automated code reviews on this repo. Configure here.