Repository navigation
v0.1.11 — security + supply-chain hardening + perf - #184
Merged
Merged
Conversation
…aks (#75) Adds branding_lint_clap_doc_comments_fail_on_rtk — explicit FORBIDDEN_TOKENS list (RTK savings/adoption/equivalent/artifacts/etc.) for clap doc-comments. New rule passes; merging. Note: the existing branding_lint_no_unrecognised_rtk_references_in_src failure on develop is unrelated (pre-existing leaks in src/hooks/init.rs:28,3031,3051,5125).
…ated decisions Design-only PR — 4 new files under docs/contributing/. No production code.
Fixes 4 RTK leaks in src/hooks/init.rs. 5/5 branding_lint tests green; 160/160 init tests still green.
PEP 508 extras stripped; # inline comments terminate args; full pip value-flag set consumed. 18 new tests.
Depth-cap synthetic now labelled Unknown instead of hardcoded Npm. Cascade arms added in 3 existing matches.
HashSet-based dedup + BTreeMap-based claimed-span overlap-check.
…#180) Both gates serialised the raw shell command verbatim into JSONL on disk. Last-24h scan of a single user's downgrades.jsonl found 27 40-hex tokens and 15 `Authorization: token <hex>` headers captured in cleartext at a predictable path. Add `core::secret_redact::redact` and apply it at both write sites (`tirith_gate::log_downgrade`, `supply_chain_gate::log_event`). Covered patterns: - URL basic-auth (`https://user:pw@host`) - `Authorization: token|Bearer <value>` headers - GitHub PAT prefixes (gho_/ghp_/ghs_/ghu_/github_pat_) - Env-var assignments to credential-shaped names (matches `*_TOKEN`/`*_KEY`/`*_SECRET`/`*_PASSWORD`/`*_PAT`/`*_APIKEY`/`*_AUTH` and bare equivalents; leaves PATH/HOME/etc. alone) - CLI flags `--token`/`--auth-token`/`--password`/`--api-key`/`--secret`, space-separated or `=`-attached Conservative scrubber: prefer false negatives over corrupting the diagnostic value of the log. Zero-copy fast path (`Cow::Borrowed`) when the cmd has nothing to scrub. Idempotent. 15 unit tests cover each pattern + idempotency + the PATH-must-not-be-redacted invariant. Out of scope: backfill scrub utility for existing logs (follow-up), log rotation, encryption at rest. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…#180) Two follow-ups after a real-world scrub of one user's existing logs found 30 surviving secret-shaped strings: 1) The `tirith` field in downgrades.jsonl is spliced in verbatim from the tirith subprocess output. That blob frequently echoes the original command (and any inline credentials) back inside its findings. Apply the same redactor to it before splicing. 2) git-credential-helper feeds creds over a pipe as `protocol=...\nhost=...\nusername=...\npassword=<TOKEN>` where the `\n` is a literal two-char escape. From the regex engine's POV, `password` lives mid-word and `\b` doesn't anchor. Add a targeted pattern that matches `(\\n|\\r)(password|token|secret|auth)=...` and preserves the escape prefix in the replacement. Add a unit test for the git-credential-helper case + document the one remaining known limitation (`T=<40-hex>` one-letter aliases can't be safely caught by name-shape alone without false-positiving git SHAs). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
#180) Closes the final acceptance item on #180. The redactor lives in core::secret_redact; this exposes it as a one-shot CLI action that deep-walks every string in both audit JSONL files and rewrites them atomically through a temp file, with a timestamped backup left alongside. Behaviour: - `contextcrawler security --scrub-logs` — live rewrite, prints per-file stats (lines / changed / unparseable) and backup path. - `contextcrawler security --scrub-logs --dry-run` — same scan + report, no files touched. Useful before committing to a rewrite. - Unparseable lines (e.g. heredoc-with-embedded-newlines records that broke JSONL framing) get a raw-line redaction fallback so noise can't smuggle secrets through. Refactored the I/O core into `scrub_logs_in(&Path, dry_run)` so it's unit-testable against a tempdir. Public `ScrubReport` / `ScrubFileReport` structs expose per-file counts for callers that want to drive it programmatically. Three new tests: - credentials in both cmd AND nested tirith blob are stripped + backup written - dry-run reports counts without mutating files - missing files are skipped gracefully Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ff bypass (#181) The gate's own error messages explicitly tell users: Overrides: rerun with CONTEXTCRAWLER_SUPPLY_CHAIN=off, or add the package … But that hint is misleading. `CONTEXTCRAWLER_SUPPLY_CHAIN=off pip install …` scopes the assignment to the `pip install` subprocess — the gate has already run by then and only reads its own process env. So the user follows the documented bypass, is still blocked, and concludes the gate is buggy. Add `cmd_has_leading_assignment(cmd, name, allowed)` and call it from `check()` after the existing `std::env::var` branch. It parses leading POSIX-style `NAME=VALUE` tokens in the cmd string, stops at the first non-assignment token (so mid-cmd `&& FOO=bar` does not bypass), and returns true if `name` appears with one of the allowed values. Conservative on value parsing — bareword values only. The bypass values we care about are short (`off`/`0`/`false`/`no`), and supporting shell quoting here would just create a different surprise. Tests: 8 unit tests cover the documented form, sibling assignments, value variants, the must-be-prefix invariant, defensive `=on` rejection, exact-value-match guard, invalid identifiers, and empty cmd. The existing `std::env::var` bypass path is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…'t blackout the gate (#182) Five `Verdict::Unavailable` events in one user's 24h logs traced to a single failed registry/OSV call early in the package loop. Once the first transient error fires, `transient_err.get_or_insert(e)` captures it, the loop moves on without further upstream calls succeeding into findings, and `check()` falls through to `Verdict::Unavailable` even though a retry would have cleared it. Add a retry-with-backoff to `http_get_json` and `http_post_json`: - 1 retry max (2 attempts total) to keep the worst-case per-call within the CHECK_WALL_BUDGET = 25s. - Per-attempt timeout dropped from 8s to 5s. Total per-call worst case: 5s + 250ms backoff + 5s = ~10.25s. Two slow packages still fit. - Retry only on retryable error shapes: * `ureq::Error::Transport(_)` — DNS hiccup, connection reset, read timeout. Exactly the class that produced the user's blackouts. * `ureq::Error::Status(500..600, _)` — registry unhealthy / transient overload. Worth a single retry. - 4xx is terminal — `404` (no such package), `401/403` (auth), `422` (malformed), `429` (rate-limit) all need *something other than immediate retry*. Bouncing harder against a rate-limiter just makes it worse. The retry-or-not policy is lifted into a `HttpErrTag`-keyed pure function (`is_retryable_http_err_tag`) so it can be unit-tested without constructing a real `ureq::Response`/`ureq::Transport`. Six new tests: 5xx-retryable, 4xx-not-retryable, 2xx/3xx-not-retryable defensive case, transport-retryable, and a budget-arithmetic guard that ensures the retry math always fits inside CHECK_WALL_BUDGET — so a future loosening of the constants can't silently push worst-case beyond the deadline. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 26, 2026
Closed
Closed
Closed
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.
v0.1.11 — security + supply-chain hardening + perf
Bundles 7 closed issues across 3 PR clusters from one heavy hardening day.
What's in this release
🔒 Security (#180, #181, #182)
security(supply-chain): downgrades.jsonl + supply_chain.jsonl capture inline credentials #180 — credentials no longer captured in audit logs. Both
downgrades.jsonlandsupply_chain.jsonlpreviously serialised the raw shell command verbatim, capturing inline tokens (curlAuthorizationheaders, env-var assignments to*_TOKEN/*_KEY/*_SECRET, GitHub PAT prefixes, URL basic-auth, git-credential-helper\npassword=…, CLI flag values). A real-world 24h scan of one user's log surfaced 27 unique 40-hex tokens + 15Authorization: token <hex>headers in cleartext. Fixed at the log-write boundary in both gates + the tirith blob (which echoes cmd back in findings). Ships a newcontextcrawler security --scrub-logs [--dry-run]CLI that retroactively cleans existing on-disk logs (deep-walks every string, atomic rewrite via temp file, timestamped backup).fix(supply-chain): honour inline-prefix CONTEXTCRAWLER_SUPPLY_CHAIN=off bypass #181 —
CONTEXTCRAWLER_SUPPLY_CHAIN=offnow honoured as an inline prefix. The gate's own error messages tell users:but the gate only checked the shell environment, not the inline-prefix form (
CONTEXTCRAWLER_SUPPLY_CHAIN=off pip install xscopes the assignment to the subprocess, not the hook). Users followed the documented bypass and were still blocked. Now parses leading POSIX-style assignments off the cmd and honours=off,=0,=false,=no. Must be a prefix (mid-cmd&& FOO=bardoes not bypass).fix(supply-chain): retry transient HTTP errors so a single blip doesn't blackout the gate #182 — retry on transient HTTP errors. A single transient registry/OSV blip previously turned the whole install into
Verdict::Unavailable(no retry, first error wins). 5 unavailable verdicts in 24h on one user, all onpip installfor normal packages with the network up. Now: 1 retry, 5s per-attempt timeout, 250ms backoff. Retried only onTransport(_)andStatus(500..600, _). 4xx is terminal — don't punish a rate-limiter with another request. Worst-case 10.25s/call, well underCHECK_WALL_BUDGET = 25s.🛠 Supply-chain hardening (#145, #147, #149)
fix(supply-chain): parse_package_args robustness (PEP 508 extras, inline #, flag values) #145 —
parse_package_argsrobustness. Three orthogonal false-positives fixed:pip install celery[redis]— PEP 508 extras suffix now stripped before PyPI lookup (was 404 → Unavailable).pip install flask # production— inline#comment now terminates the args loop (was slurping#andproductionas packages, both 404'd, cascading to Ask).--platform linux_x86_64,--python-version 3.11,--trusted-host pypi.org, etc. — full pip value-consuming flag set extracted into a namedPIP_VALUE_CONSUMING_FLAGSconst; previously only-t/--target/--index-urlwere known and other values were misclassified as packages.harden(supply-chain): add Ecosystem::Unknown variant for depth-cap synthetic Unvettable #147 —
Ecosystem::Unknownvariant for depth-cap synthetic. When recursion hitsMAX_RECURSION_DEPTHand surfaces an unvettable, it was hardcoded toEcosystem::Npm— a deep-nested PyPI/mixed-shell payload was labelled[npm]in the surfaced finding. Verdict was always correct; label is now too. Cascade arms added in 3 existing matches (lockfile unvettable text, config lookup, registry routing) all paired withunvettable: Some(...)so unreachable in practice; structured for compile-time exhaustiveness.perf(supply-chain): O(n^2) hot paths in claimed-span dedup and dedup_installs #149 — O(n²) → O(n) dedup + O(log n) claimed-span check. Mechanical refactor, no behaviour change.
dedup_installsnow uses a HashSet keyed on a stable canonical signature (sorted packages for order-independence). Claimed-span overlap-check usesBTreeMap<usize, usize>withrange(..=start).next_back(). Stress test: 5,000 dedup completes in single-digit ms (was 25M pairwise comparisons); 200-segment install detect in <250ms.🧹 CI (#183)
branding_lintred on develop. The lint added in test(branding): replace regression-style FORBIDDEN_TOKENS with broad allowlist-based scan #67 to prevent v0.1.8→v0.1.9 branding whack-a-mole has been failing ondevelopsince pre-existing leaks slipped in (src/hooks/init.rs:28,3031,3051,5125). Three user-visible "RTK guidance block" rebrands + one// branding-lint: allow legacymarker on the rtk-extension.ts include_str path. Lint is green again.📐 Process / docs
FORBIDDEN_TOKENSrule catchesRTK savings/adoption/equivalent/artifacts/etc.in clap doc-comments where the rustdoc-broad allowlist (test(branding): replace regression-style FORBIDDEN_TOKENS with broad allowlist-based scan #67) would otherwise let them slip.docs/contributing/(architecture diagram, decisions log, Codex review, Gemini review). No production code touched.Test coverage
core::secret_redacthooks::tirith_gatescrub_logs_in(full + dry-run + missing-files)hooks::supply_chain_gatetests::branding_lint200+ tests green across the touched stack. No regressions.
Upgrade notes
contextcrawler security --scrub-logs [--dry-run].#182retry change reduces per-attempt HTTP timeout from 8s → 5s; worst case per call (with 1 retry) is now 10.25s vs the previous 8s single-shot. WithinCHECK_WALL_BUDGET = 25seither way; expect slightly more resilience under flaky upstream registries.contextcrawler security --scrub-logsonce after install if you've used inline credentials in shell commands (curl headers, env-var literals,gh auth login --with-token, etc.).Empirical proof — real-world 24h scan
Authorization: token <hex>in audit logsCloses
#75, #77, #145, #147, #149, #180, #181, #182, #183