Repository navigation
feat(cli): add a local secrets scan-file command - #166
Draft
tim-thacker-nullify wants to merge 1 commit into
Draft
tim-thacker-nullify wants to merge 1 commit into
tim-thacker-nullify wants to merge 1 commit into
Conversation
The IDE extension's on-save scanner defaults to `nullify secrets scan-file`, which only ever existed in the internal monorepo CLI. The public, OSS-distributed CLI that install.sh actually ships has no local scanning at all, so the extension's only feature was broken out of the box (FDE-1721). Adds `nullify secrets scan-file` as a hand-written command alongside the generated ones, backed by a new internal/scanfile package: a from-scratch, stdlib-only regex+entropy detector (zero new dependencies), porting Nullify's own custom rule set verbatim plus a curated baseline of common public secret formats. See internal/scanfile's package doc for why this doesn't vendor the internal engine's github.com/zricethezav/gitleaks/v8 dependency directly, and the PR description for the full trade-off. Output matches secrets/internal/scanfile.NormalizedFinding field-for-field so the extension's existing parsing needs no changes. Test fixtures build AWS/Anthropic-key-shaped strings via concatenation rather than as one literal, so this repo's own commit doesn't trip a secret scanner on its own detector's test data. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
ide/nullify-vscode's on-save scanner shells out tonullify secrets scan-fileon every save, and this public CLI had no such command. Fixes FDE-1721.install.shinstalls had no local scanning at all, so the extension's only feature failed out of the box.internal/scanfile/: new package, a from-scratch regex+entropy secret detector. Zero new third-party dependencies — stdlibregexp/crypto/sha256/mathonly.internal/scanfile/nullify_rules.go: Nullify's own custom rules, ported verbatim (same IDs/regexes/keywords/entropy floors) fromsecrets/internal/scanners/gitleaks/nullify-config.goin the monorepo. That function is plain data with no engine dependency, so it crosses into this repo cleanly.internal/scanfile/baseline_rules.go: 18 hand-written rules for common public formats (AWS keys, GitHub/GitLab PATs, Slack, Stripe, PEM blocks, a generic high-entropy heuristic) not already covered by the Nullify set.internal/scanfile/rules.go: the same entropy-threshold and test/placeholder filtering the internal engine uses, ported verbatim.internal/commands/scanfile.go+cmd/cli/cmd/secrets.go: hand-writtennullify secrets scan-file [path] [--stdin] [--path] [--repository], matching the internal command's flags. Registered at the top level, not underapi secrets(generated, API-backed, stays untouched), since scan-file never calls the platform API.Engine decision: did not port
secrets/internal/scanners/gitleaks.github.com/zricethezav/gitleaks/v8(MIT, clean license by itself).detect/sources/reportpackages are not a small addition.sourcesunconditionally pulls inmholt/archives(7z/rar/brotli/lzip/xz support, a dozen further modules).report/detectpull incharmbracelet/lipglossandMasterminds/sprig, used only for gitleaks' own CLI/report rendering.tetratelabs/wazero/wasilibs/go-re2(a WASM regex runtime) also enter the module graph, gated behind an opt-in build tag so not linked into the default binary.go.sum: on the order of 60 new transitive modules, none exercised by a single-file/stdin scan.go builda 60-modulego.mod/go.sumchange to verify it. Hand-editing that blind is the "partial/broken port" this kind of task should not force — built the minimal detector above instead.Licensing/packaging — flagging for a human to double-check even though I believe it's clean:
nullify_rules.go) move from a private monorepo into this public repo's source. Not a licensing issue, but a visibility change worth a second look — rule names/regexes become public; no secret values or customer data are involved.Output contract, checked against
ide/nullify-vscode/src/extension.ts'sscan():NormalizedFindingmatchessecrets/internal/scanfile.NormalizedFindingfield-for-field (detectorClass,severity,file,startLine/endLine/startColumn/endColumn,cwe,message,fingerprint), soparseFindings/applyFindingsneed no changes.Known gap, disclosed rather than hidden: the fingerprint hash scheme matches the platform's dedup key, but the secret-type values come from this package's own rule IDs, not the platform's internal
rules.csvclassification — correlation with pre-existing platform findings for the same secret isn't guaranteed. This rule set also does not claim parity with gitleaks' several-hundred-rule default set.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.