fix(scripts): extend the packaged-secret detector to the 12 hard-block formats#7508
Conversation
…k formats scripts/forbidden-content.mjs's FORBIDDEN_CONTENT -- the single source of truth the miner/mcp package checkers and the AMS MCP contract test use to reject a packed file or tool response embedding a secret -- only matched PEM private-key headers, github_pat_/gh[pousr]_/gts_ tokens, and a generic <NAME>_SECRET= assignment. It missed 12 concrete formats that this repo's own src/review/secret-patterns.ts already hard-blocks (HARD_SECRET_KINDS): AWS access keys, Slack/GitLab/npm/Stripe/SendGrid/Hugging Face/Voyage/ Firecrawl tokens, Google API keys, and watermark-anchored OpenAI/Anthropic keys -- so any of those baked into a packed miner/mcp npm file was shipped undetected. Widen FORBIDDEN_CONTENT to also match those 12, using the exact regex bodies from SECRET_PATTERNS. Approach: hand-copied (not imported) -- forbidden- content.mjs is loaded by plain `node scripts/check-*.mjs` in ci.yml and publish-miner.yml, not tsx, so it cannot import the .ts source at runtime (check-engine-parity.ts can only because it is itself run via tsx); a comment points back to the source of truth. Deliberately excluded: jwt (out of scope for this detector -- considered and left out), and seed_or_mnemonic / bittensor_key (documented there as weak, false-positive-prone heuristics kept out of HARD_SECRET_KINDS). The three call sites are unchanged -- this only widens what the shared constant matches; miner-mcp-contract.test.ts still passes (no tool-response fixture trips a new pattern). Closes JSONbored#7433
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7508 +/- ##
=======================================
Coverage 91.41% 91.41%
=======================================
Files 717 717
Lines 73038 73038
Branches 21635 21635
=======================================
Hits 66768 66768
Misses 5227 5227
Partials 1043 1043
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
Caution 🛑 LoopOver review result - reject/close recommendedReview updated: 2026-07-20 15:38:47 UTC
Review summary Nits — 3 non-blocking
Why this is blocked
📋 Copy for AI agents — paste into your coding agentDecision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
LoopOver is closing this pull request on the maintainer's behalf (Linked issue overlaps another open PR; Possible leaked secret in the diff (private_key_block); duplicate of open PR #7499). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Closes #7433
Problem
scripts/forbidden-content.mjs'sFORBIDDEN_CONTENT— the single source of truth the miner/mcp package checkers (check-miner-package.mjs/check-mcp-package.mjs, run in CI + at publish) and the AMS MCP contract test use to reject a packed file or tool response containing a secret — only matched PEM private-key headers,github_pat_/gh[pousr]_/gts_tokens, and a generic<NAME>_SECRET=assignment. It missed 12 concrete formats that this repo's ownsrc/review/secret-patterns.tsalready hard-blocks (HARD_SECRET_KINDS), so e.g. an AWS/Slack/OpenAI/Anthropic key baked into a packed npm file shipped undetected.Change
Widen
FORBIDDEN_CONTENTto also match all 12 (aws_access_key,slack_token,google_api_key,gitlab_token,npm_token,stripe_secret_key,sendgrid_key,huggingface_token,voyage_api_key,firecrawl_api_key,openai_api_key,anthropic_api_key) using the exact regex bodies fromSECRET_PATTERNS.Approach — hand-copied, not imported. I checked the import route first (the issue notes
check-engine-parity.tsimports across thescripts/→src/boundary), but that script is run viatsx;forbidden-content.mjsis loaded by plainnode scripts/check-*.mjsinci.ymlandpublish-miner.yml, which cannot import a.tssource at runtime. So per the issue's fallback,FORBIDDEN_CONTENTstays a single literalRegExpwith the bodies hand-copied and a comment pointing back to the source of truth.Deliberately excluded:
jwt(out of scope for this packaged-secret detector — considered and left out, not silently added), andseed_or_mnemonic/bittensor_key(documented insecret-patterns.tsas weak, false-positive-prone heuristics kept out ofHARD_SECRET_KINDS— ahotkey =line or the word "mnemonic" in ordinary docs is not a leaked secret).Zero call-site changes
check-miner-package.mjs,check-mcp-package.mjs, andminer-mcp-contract.test.tsare untouched — this only widens what the shared constant matches. Verified locally: the fulltest/unit/forbidden-content.test.ts(extended with per-format coverage — all 12 new + 4 original shapes flagged, and jwt / mnemonic / Bittensor-key / plain text correctly not flagged; probes fragment-assembled so the file holds no contiguous credential literal) andtest/unit/miner-mcp-contract.test.ts(33 tests) both pass.