Skip to content

scanner: Harden detection and scan coverage - #120

Open
pixincreate wants to merge 3 commits into
masterfrom
hardening/scanner-safety
Open

pixincreate wants to merge 3 commits into
masterfrom
hardening/scanner-safety

Conversation

@pixincreate

@pixincreate pixincreate commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Match complete credentials and remove unsafe exemptions, credit-card detection, and luhn validation.
  • Fix Git framing, historical blob scans, submodule handling, and filesystem visit limits.
  • Separate scan coverage from findings and enforce bounded inputs and output safety.
  • Fix CI fixtures, preserve portable filename decoding tests, and add paired false-positive regressions.
  • Shorten the README and remove the review documents.

Compatibility

Reports can return INCOMPLETE; --fail-on-unscannable applies in every exit mode.
Corrected matches can change baseline fingerprints, but the baseline schema stays unchanged.
Incomplete scans cannot update baselines.
Input, line, path, and finding limits can stop oversized scans.

Validation

  • Local debug and release suites each pass 320 tests.
  • Clippy with -D warnings, formatting, and Rust 1.85 checks pass.
  • Local self-scan passes with .DS_Store excluded; baseline regeneration produces no drift.
  • The synthetic corpus contains 39 cases: 20 credentials and 19 non-credentials.
  • The latest fixes leave the baseline unchanged.

Check the PR checks for cross-platform CI results.
The synthetic corpus does not establish production precision or recall.
Large workspace scans can reach the finding budget and exit 2 without a report.
Container execution and production runtime validation remain outside the tested scope.

Match complete credentials and make incomplete coverage explicit.
Bound scan resources, protect output writes, and validate configuration.

Add paired accuracy cases, regression tests, and workload measurements.
Baseline reviewed synthetic fixtures and document remaining CI and
large-repository scan limits.

Assisted-by: GPT-6.1 Sol
Signed-off-by: PiX <69745008+pixincreate@users.noreply.github.com>
@pixincreate
pixincreate requested a balanced review from Copilot October 7, 2026 06:56
@pixincreate pixincreate self-assigned this Oct 7, 2026
@pixincreate pixincreate added the bug Something isn't working label Oct 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Atomic writing, Git subprocess scaling, and staged line-limit handling have unresolved correctness and performance issues.

Review effort: Balanced
Findings: 2 High severity · 2 Medium severity

Open (4)
What changed in this PR

Hardens secret detection, scan coverage reporting, resource limits, configuration validation, and output safety across the CLI, hooks, and GitHub Action.

Changes:

  • Improves credential matching, Git scanning, coverage reporting, and SARIF output.
  • Adds bounded resource handling and safer report/baseline writes.
  • Expands regression, accuracy, integration, and workload validation.
File Description
tests/​scanner_tests.rs Tests complete credential matching.
tests/​report_tests.rs Tests coverage status and SARIF URIs.
tests/​hooks_tests.rs Tests fail-closed pre-push behavior.
tests/​hardening_tests.rs Adds end-to-end hardening regressions.
tests/​detector_tests.rs Updates detector accuracy expectations.
tests/​baseline_tests.rs Tests corrected baseline fingerprints.
tests/​accuracy_corpus.toml Defines synthetic accuracy cases.
tests/​accuracy_corpus_tests.rs Executes and measures the corpus.
templates/​pre-push.sh Blocks incomplete push scans.
src/​utils.rs Adds atomic protected file replacement.
src/​scanner/​staged.rs Hardens Git diff and blob scanning.
src/​scanner/​lines.rs Adds bounded complete-input scanning.
src/​scanner/​limits.rs Defines resource budgets.
src/​scanner/​files.rs Bounds traversal and reports skipped inputs.
src/​scanner/​error.rs Adds resource-limit errors.
src/​scanner.rs Integrates coverage, limits, and fingerprints.
src/​run_error.rs Rejects incomplete baseline updates.
src/​report/​sarif.rs Adds coverage fields and URI encoding.
src/​report.rs Separates findings from coverage status.
src/​lib.rs Enforces coverage exit policy.
src/​detector.rs Removes Luhn and validates entropy.
src/​config/​tests/​application.rs Updates validator configuration tests.
src/​config.rs Rejects invalid detector configuration.
src/​cli.rs Adds lockfile and coverage options.
src/​baseline.rs Uses atomic baseline writes.
scripts/​benchmark.py Measures bounded workloads.
scripts/​action_validation/​validate.py Validates Action coverage enforcement.
scripts/​action_validation/​keywatch_action_scenarios.py Adds incomplete-report scenarios.
README.md Documents compatibility and security changes.
docs/​security-and-validation.md Documents limits and validation evidence.
docs/​plans/​2026-10-06-hardening.md Records the hardening plan.
detectors.toml Refines built-in detection policy.
CHANGELOG.md Records breaking and behavioral changes.
action.yml Makes Action scans fail closed.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils.rs
Comment thread src/utils.rs
Comment thread src/scanner/lines.rs Outdated
Comment thread src/scanner/staged.rs Outdated
Use private test directories and match complete credential expressions.
Bound MongoDB matches and share Git object-size queries.
Apply line limits to file content, including final carriage returns.

Shorten the README and remove review documents.
Refresh the baseline with reviewed synthetic fixtures.

Assisted-by: GPT-6.1 Sol
Signed-off-by: PiX <69745008+pixincreate@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Valid submodule diffs can abort scanning, restrictive umasks break output permissions, and traversal can bypass the path budget.

5 open findings
2 resolved since last review

🧠 Review effort: Balanced

Comment thread src/scanner/files.rs
Comment thread src/scanner/staged.rs
Comment thread src/utils.rs
Count filesystem visits across all operands and preserve findings when
Git patches include gitlinks. Set output permissions before publication
so a restrictive umask cannot remove owner access.

Limit control-character filename fixtures to Unix and keep decoding
checks portable. Add paired regressions for reported false positives.

Assisted-by: GPT-6.1 Sol
Signed-off-by: PiX <69745008+pixincreate@users.noreply.github.com>
@pixincreate
pixincreate requested a balanced review from Copilot October 7, 2026 17:21
@pixincreate
pixincreate marked this pull request as ready for review October 7, 2026 17:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The shipped detector configuration is invalid TOML, and terminal control characters remain unsafe in human-readable output.

1 open finding
5 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Unescaped control characters in file paths can manipulate terminal output

src/​scanner/​staged.rs:241

These newly decoded control bytes are retained in Finding.file_path, while non-verbose output interpolates that path directly into the terminal. A repository-controlled filename containing BEL, backspace, form feed, or vertical tab can therefore manipulate console output; keep the decoded path for Git lookup/report identity, but escape control characters at every human-readable output boundary.

Low severity Documentation overstates secret redaction for verbose show-secrets output

README.md:27

This is not true for --verbose --show-secrets: verbose mode prints the generated report to the console, and --show-secrets leaves matched content unredacted. Qualify this guarantee as applying to non-verbose console summaries so users do not expose secrets based on the documentation.

🧠 Review effort: Balanced

Comment thread detectors.toml
# A PEM block in source starts its line or directly follows a string quote;
# a mention inside prose (a doc comment that describes the header) does not
# start a certificate.
pattern = "(?:^\\s*|[\"'\x60])-----BEGIN CERTIFICATE-----"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants