Skip to content

Scan for secrets faster with Secretlint v14 - #1359

Merged
Benjamin Christopher Simmonds (benibenj) merged 2 commits into
mainfrom
benibenj/agents/secretlint-v14
Nov 24, 2026
Merged

Benjamin Christopher Simmonds (benibenj) merged 2 commits into
mainfrom
benibenj/agents/secretlint-v14

Conversation

@benibenj

@benibenj Benjamin Christopher Simmonds (benibenj) commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Before: Secret scanning runs every Secretlint rule (27 since #1358) over the full text of every file vsce packages. Installing vsce also prints an npm deprecation warning for @secretlint/secretlint-rule-preset-recommend, which Secretlint no longer publishes.

After: vsce uses Secretlint v14. It first checks each file for the keywords its rules look for, and runs a rule only on files that contain one of them. Most files contain none, so they aren't even decoded. The detected secrets don't change, secret scanning uses about 4× less CPU, and the deprecated package is gone.

Measured locally (macOS, Apple Silicon, Node 24) with extensions made of VS Code source files, median of 5 runs. The table shows CPU time because the machine was under load and wall-clock times were noisy.

main this PR
Secret scan, 512 files 275 ms 80 ms
Secret scan, 8,192 files 4.5 s 0.7 s
Memory, scanning 8,192 files 263 MB 171 MB
Secret scan's share of vsce package, 2,048 files ~1.0 s ~0.1 s
Details

Changes

  • @secretlint/core, source-creator, types and secretlint-rule-no-dotenv go from 13.1.0 to 14.0.1. @secretlint/secretlint-rule-preset-recommend is removed; the preset now comes from @secretlint/core/builtin. Rule ids don't change, so vsce's per-rule options, the placeholder allowance from Detect more kinds of secrets when packaging (Secretlint 13.1.0 rules) #1358 and the --allow-package-secrets names keep working. The placeholder allowance now takes its list of rules from recommendedRules.
  • The profiler toggle from Speed up secret scanning by turning off Secretlint's profiler #1352 is removed. In v14 the profiler is off unless explicitly enabled, and lintSource skips all profiling work while it's off.
  • vsce's private-key rule from Detect more kinds of secrets when packaging (Secretlint 13.1.0 rules) #1358 stays, because v14's rule still skips EC, Ed25519 and encrypted keys. It now declares the keyword PRIVATE KEY. It was the only rule without keywords, so v14 still had to decode and check every file. With the keyword it skips files that can't contain a key, which alone saves about 27% CPU and 36% memory at 8,192 files.
  • The two profiling tests become plain scanning tests (in memory and on disk), since vsce no longer has profiler code to test.
  • 14.1.0 isn't used: it only adds opt-in rules, not recommended ones, and the repo's min-release-age=7 blocks it until Nov 29.

Side effects

  • Same findings as main on everything tested (below).
  • The first scan in a process takes about 40 ms longer to load (135 → 173 ms), because @secretlint/core now contains all built-in rules.
  • Future rule changes arrive with @secretlint/core updates. Secretlint only adds rules to the recommended preset in major versions, so ^14 stays stable.
  • v14 was released on Nov 15 and rewrites Secretlint's scanning internals. 14.0.1 fixed one false positive (a Slack token rule); no other bug reports so far.

Testing

  • npm test: 409 passing.
  • 42 hand-written samples (private keys in many formats, placeholder and real-looking tokens, database URLs, .env files): identical to main.
  • All 9,893 files of 31 marketplace and installed extensions: identical findings to main.
  • 14 edge cases, identical to main including line and column: GCP .p12 keys (default and legacy encryption) and a service-account JSON key, a file with a byte-order mark, Latin-1 bytes, UTF-16 (skipped by both), an EC key with CRLF line endings, a 4.6 MB minified file, an empty file, a binary .wasm file, a key inside Markdown, and a nested .env file.
  • dbgjs CPU profiles of a 2,048-file vsce package: time in Secretlint code went from about 870 ms to about 220 ms, of which regular expressions went from 391 ms to 4 ms. No profiling marks are recorded.

Upgrade @secretlint/core, source-creator, types and secretlint-rule-no-dotenv to 14.0.1 and use the recommended preset that v14 builds into @secretlint/core. This drops @secretlint/secretlint-rule-preset-recommend, which npm reports as deprecated at install.

v14 checks each file for the keywords of its rules before running them, so most files skip the rules entirely. Its profiler is off unless explicitly enabled, so vsce no longer needs to turn it off.

The recommended private-key rule in v14 has the same gaps as 13.1.0, so vsce keeps its own rule for EC, Ed25519 and encrypted keys.

Co-authored-by: Copilot <[email protected]>
Declare "PRIVATE KEY" as the keyword of vsce's private-key rule. Every key the rule reports contains it, so Secretlint v14 no longer decodes and scans files that don't, which was the case for every file before because this was the only recommended rule without keywords.

Co-authored-by: Copilot <[email protected]>
@benibenj Benjamin Christopher Simmonds (benibenj) changed the title Move secret scanning to Secretlint v14 Scan for secrets faster with Secretlint v14 Nov 24, 2026
@benibenj
Benjamin Christopher Simmonds (benibenj) marked this pull request as ready for review November 24, 2026 20:23

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the Secretlint v14 integration, scanner configuration, and tests. No blocking or important correctness or security findings.

Written by Connor's agent

@benibenj
Benjamin Christopher Simmonds (benibenj) merged commit 3c09c33 into main Nov 24, 2026
7 checks passed
@benibenj
Benjamin Christopher Simmonds (benibenj) deleted the benibenj/agents/secretlint-v14 branch November 24, 2026 20:55
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.

3 participants