Skip to content

fix(scanner): fail on invalid input and anchor baselines to the repo - #111

Closed
pixincreate wants to merge 2 commits into
fix/detector-formatsfrom
fix/scanner-strictness
Closed

pixincreate wants to merge 2 commits into
fix/detector-formatsfrom
fix/scanner-strictness

Conversation

@pixincreate

Copy link
Copy Markdown
Owner

Stacked PR 3 of 5 (base: fix/detector-formats).

Input strictness: a scan operand that does not exist, is a symlink, is not a regular file or directory, or is an unlistable directory now exits 2 instead of reporting a silent clean pass. Nested unlistable directories are reported as unscannable so --fail-on-unscannable catches them. The same file passed under two spellings scans once.

History scans: --git-history walks every ref (git log --all), so side-branch secrets are found; a new --rev-range flag restricts the walk and rejects flag-shaped values. Failed git invocations report one summarized stderr line, drained on its own thread.

Baselines: fingerprint paths anchor to the repository root, so a baseline created in a subdirectory (or from outside the repository) suppresses the same finding in staged and history scans.

Config and reporting: unknown config keys are rejected; stderr warnings when a repository-supplied detectors.toml replaces the embedded set, when overrides disable detectors, or when KEYWATCH_CONFIG_PATH is ignored; non-verbose scans print finding locations with redacted matches; SARIF drops the blanket precision: very-high claim.

A scan that cannot read its input must not report a clean pass, and a
baseline must suppress the same finding no matter which directory or
scan mode produced it.

Input strictness:
- A scan operand that does not exist, is a symlink, or is not a
  regular file or directory is a hard error (exit 2) instead of a
  silent "No secrets found". An explicitly named directory that cannot
  be listed errors the same way; a nested unlistable directory is
  reported as unscannable so --fail-on-unscannable catches it.
- The same file passed under two spellings (dup.txt ./dup.txt) scans
  once. The dedup key is lexically normalized without ever turning a
  relative path absolute, and backslash folding is Windows-only since
  a backslash is an ordinary unix filename character.
- --fail-on-unscannable names the unscannable files in its summary
  instead of printing "No secrets found." next to exit code 1.

History scans:
- scan --git-history walks every ref (git log --all); a secret on a
  side branch was previously invisible.
- A new --rev-range flag restricts the walk to a revision range. The
  value is rejected if it looks like a flag, since it lands on the git
  command line.
- Failed git diff/log invocations report one summarized stderr line
  instead of dumping pages of git usage text; stderr is drained on its
  own thread so a large dump cannot deadlock the scan.

Baselines:
- Fingerprint paths anchor to the repository root, probed at the scan
  operand, so a baseline created in a subdirectory (or from outside
  the repository) suppresses the same finding in staged and history
  scans. Entries are stored root-relative going forward; baselines
  written at the repository root keep matching unchanged.

Configuration and reporting:
- Unknown keys in .keywatch.toml and detector files are rejected
  instead of silently ignored; CustomRule keeps accepting the inert
  description key for compatibility.
- KeyWatch warns on stderr when a repository-supplied detectors.toml
  replaces the embedded set, when config overrides disable detectors,
  and when KEYWATCH_CONFIG_PATH is set but ignored. Operator channels
  (the env var, user config dir) stay quiet so the repository warning
  keeps meaning something.
- Non-verbose scans print the location, type and redacted match of
  every finding instead of only a severity count.
- SARIF output drops the blanket precision: very-high claim and omits
  semanticVersion when unknown.

Assisted-by: Claude Fable 5
Signed-off-by: PiX <69745008+pixincreate@users.noreply.github.com>
The deny_unknown_fields comment used a deliberately misspelled config
key as its example, which the typos CI job rejects. Use the
[[custom_rules]] example alone.

Assisted-by: Claude Fable 5
Signed-off-by: PiX <69745008+pixincreate@users.noreply.github.com>
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.

1 participant