Skip to content

fix(sanitize): don't reverse-flag path/URL env values as leaks (unblock main CI)#568

Merged
autogame-17 merged 1 commit into
mainfrom
fix/sanitize-skip-github-workspace-env-scan
Jun 11, 2026
Merged

fix(sanitize): don't reverse-flag path/URL env values as leaks (unblock main CI)#568
autogame-17 merged 1 commit into
mainfrom
fix/sanitize-skip-github-workspace-env-scan

Conversation

@autogame-17

@autogame-17 autogame-17 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

main CI (test.ymlnpm test) has been red since at least v1.88.3 (2026-06-06) — always failing the same way:

not ok 130 - test/sanitize.test.js   (exitCode 1, location :1:1, no failing subtest)

It fails even on docs-only commits that never touched sanitize, and node --test test/sanitize.test.js passes locally. So the break is environmental, not a code regression. (macOS/Windows test-cross jobs pass — only the ubuntu test job is red.)

Root cause

sanitize.test.js asserts (top-level, not inside a test() block, so any throw exits the whole file):

fullLeakCheck('build trace from /home/runner/work/evolver/evolver/src/foo.js …').found === false

fullLeakCheckdetectEnvValueLeaks reverse-scans every process.env value 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:

  • the runner sets GITHUB_WORKSPACE, RUNNER_WORKSPACE
  • because the suite runs via npm test, npm also sets INIT_CWD, npm_config_local_prefix, npm_package_json, PWD

Any 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 --test won't set INIT_CWD):

INIT_CWD=/home/runner/work/evolver/evolver node --test test/sanitize.test.js
# AssertionError at test/sanitize.test.js:280 — actual: true, expected: false

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):

if (/^(\/|[A-Za-z]:\\|[a-z][a-z0-9+.-]*:\/\/)/i.test(val)) continue;

Filesystem paths and URLs are not secrets. 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 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 asserts fullLeakCheck stays clean, and asserts a non-path secret env value is still reverse-detected — so the security guarantee is locked in.

Verification

  • full CI-env simulation (INIT_CWD=… GITHUB_WORKSPACE=… npm_config_local_prefix=… npm_package_json=… RUNNER_WORKSPACE=… node --test test/sanitize.test.js) → pass (70 assertions) (was failing)
  • plain node --test test/sanitize.test.jspass (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
detectEnvValueLeaks no longer reverse-matches env values that look like filesystem paths or URLs (Unix /…, Windows C:\…, or scheme://…). That stops CI/npm checkout paths in vars like GITHUB_WORKSPACE, INIT_CWD, and npm_config_local_prefix from being treated as hardcoded secrets when capsule text mentions the same path—fixing CI-only failures in test/sanitize.test.js and avoiding self-PR blocks on legitimate build traces.

test/sanitize.test.js adds a regression block that sets those env vars to a runner-style path, asserts fullLeakCheck stays 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.

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>
@autogame-17 autogame-17 force-pushed the fix/sanitize-skip-github-workspace-env-scan branch from 0b1a62a to 6e5bc12 Compare June 10, 2026 18:16
@autogame-17 autogame-17 changed the title fix(sanitize): skip GITHUB_WORKSPACE in env-value leak scan (unblock main CI) fix(sanitize): don't reverse-flag path/URL env values as leaks (unblock main CI) Jun 10, 2026
@autogame-17 autogame-17 merged commit 8355370 into main Jun 11, 2026
5 checks passed
@autogame-17 autogame-17 deleted the fix/sanitize-skip-github-workspace-env-scan branch June 11, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant