Skip to content

fix(scripts): extend the packaged-secret detector with the repo's other precise secret formats#7499

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/forbidden-content-secret-formats-7433
Jul 20, 2026
Merged

fix(scripts): extend the packaged-secret detector with the repo's other precise secret formats#7499
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/forbidden-content-secret-formats-7433

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What

Extends the packaged-secret detector FORBIDDEN_CONTENT (scripts/forbidden-content.mjs) — the single source of truth that check-miner-package.mjs / check-mcp-package.mjs use to reject secret-like content in packed npm files, and that miner-mcp-contract.test.ts uses to assert no MCP tool response leaks one — to also match the 12 concrete provider-key formats this repo already ships a tested regex for, but which this specific detector didn't cover.

Closes #7433

Details

Added the exact regex bodies from src/review/secret-patterns.ts's SECRET_PATTERNS entries that are in its HARD_SECRET_KINDS ("near-zero false-positive") set, in addition to the 4 shapes already covered:

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.

Import vs. hand-copy: the issue asked to first check whether scripts/** can import the patterns directly from secret-patterns.ts. It can't at runtime here — forbidden-content.mjs is a plain .mjs executed via node (test:miner-pack / test:mcp-pack), and secret-patterns.ts is TypeScript with no runtime .js sibling on that path, so a node import of it would fail. Per the issue's stated fallback, FORBIDDEN_CONTENT stays a single RegExp and the exact pattern bodies are hand-copied in (composed via new RegExp([...].join("|")) with a per-line comment naming each), with a header comment recording this reasoning.

Deliberately excluded (with a code comment recording it): jwt (out of scope for this issue) and seed_or_mnemonic / bittensor_key (documented in secret-patterns.ts as weak, false-positive-prone heuristics intentionally kept out of HARD_SECRET_KINDS — an ordinary coldkey: / hotkey = line or a "mnemonic" mention is not a leaked credential).

No consumer changed: check-miner-package.mjs, check-mcp-package.mjs, and miner-mcp-contract.test.ts need zero edits — this is purely a widening of what the shared constant matches.

Validation

  • New test/unit/forbidden-content.test.ts cases assert FORBIDDEN_CONTENT.test(...) is true for one representative fixture per newly-added format (all fixtures assembled from fragments so this file never contains a contiguous credential-shaped literal, the same convention secret-patterns.test.ts uses), that the 5 pre-existing shapes still match, and that the excluded jwt/seed/bittensor shapes are NOT hard-blocked. 20/20 pass, and the new-format assertions are a real regression guard (they return false against the pre-change regex, true after).
  • npm run test:miner-pack, npm run test:mcp-pack — pass. miner-mcp-contract.test.ts — 33/33 pass. git diff --check clean.

(scripts/** is excluded from Codecov's coverage list, so this carries no patch obligation, but the behavior is pinned by the assertions above per this repo's testing discipline.)

@shin-core
shin-core requested a review from JSONbored as a code owner July 20, 2026 13:10
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 20, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.41%. Comparing base (c18b123) to head (4f72948).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7499   +/-   ##
=======================================
  Coverage   91.41%   91.41%           
=======================================
  Files         717      717           
  Lines       73035    73035           
  Branches    21635    21635           
=======================================
  Hits        66765    66765           
  Misses       5227     5227           
  Partials     1043     1043           
Flag Coverage Δ
shard-1 31.93% <ø> (ø)
shard-2 35.97% <ø> (-0.01%) ⬇️
shard-3 31.44% <ø> (-0.01%) ⬇️
shard-4 43.92% <ø> (ø)
shard-5 37.05% <ø> (ø)
shard-6 35.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 20, 2026
@loopover-orb

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-20 13:57:16 UTC

2 files · 1 AI reviewer · no blockers · CI green · unstable

⏸️ Suggested Action - Manual Review

Review summary
The diff extends `FORBIDDEN_CONTENT` in forbidden-content.mjs from a bare regex literal to a `new RegExp([...].join("|"))` composed of the 12 HARD_SECRET_KINDS regex bodies hand-copied verbatim from src/review/secret-patterns.ts, preserving the 5 pre-existing shapes unchanged. Each copied pattern body matches its source exactly (checked against the provided secret-patterns.ts excerpt), and the accompanying test file adds one positive fixture per new format plus explicit negative tests for the deliberately-excluded jwt/seed/bittensor-key heuristics and a regression check on the pre-existing shapes. The comment block explaining why import isn't viable (plain `.mjs` via `node`, no runtime sibling for the `.ts` source) is consistent with the actual change and not contradicted by the diff.

Nits — 3 non-blocking
  • This hand-copy of secret-patterns.ts's regex bodies has no mechanical drift check the way REES's copy does (scripts/check-engine-parity.ts's SECRET_DETECTION_TWIN_PAIR per src/review/secret-patterns.ts's own header) — consider adding forbidden-content.mjs to that parity check so a future edit to HARD_SECRET_KINDS doesn't silently drift from this file.
  • The new top-level `RegExp` alternation relies on each copied pattern being fully self-contained (own `\b`/lookaheads) to avoid cross-alternative precedence bugs; this holds today but is worth a one-line comment noting the constraint for future additions to the array.
  • Add the new forbidden-content.mjs constant to scripts/check-engine-parity.ts's drift-checked set alongside REES, per the pattern already established in src/review/secret-patterns.ts's header comment.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7433
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 74 registered-repo PR(s), 45 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor shin-core; Gittensor profile; 74 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Review context
  • Author: shin-core
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript, JavaScript, Solidity, Dart, Python, CSS, PHP, Rust
  • Official Gittensor activity: 74 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

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.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@JSONbored
JSONbored merged commit 20d96d5 into JSONbored:main Jul 20, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scripts): extend the packaged-secret detector (forbidden-content.mjs) with the repo's other known-precise secret formats

2 participants