Skip to content

feat: implement missing features per gap analysis - #69

Merged
pixincreate merged 18 commits into
masterfrom
feat/missing-features
Aug 2, 2026
Merged

feat: implement missing features per gap analysis#69
pixincreate merged 18 commits into
masterfrom
feat/missing-features

Conversation

@pixincreate

@pixincreate pixincreate commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Documentation

Description

This PR implements missing features from the original gap analysis against gitleaks/detect-secrets. See #71 for the set of planned features.

New Features

  1. CRITICAL Severity Support — Added Critical variant to Severity enum (was silently downgraded to LOW)
  2. Baseline Suppression--baseline <path> suppresses known findings; --update-baseline merges new findings into existing baseline
  3. Inline Suppressionkeywatch:ignore comments suppress findings on that line
  4. Per-Detector Allowlistallowlist field with regex patterns to suppress false positives
  5. Keyword Prefilterkeywords field for fast content filtering before regex execution
  6. Entropy Thresholdentropy_threshold field to filter low-entropy matches on generic patterns
  7. Parallel Scanning — File scanning parallelized via rayon
  8. Stdin Scanning--stdin reads from stdin instead of files
  9. Git History Scanning--git-history runs git log -p and scans patch output

Review Fixes

  1. Baseline now merges on update (was replacing and losing history)
  2. Baseline stores matched_content_hash instead of raw secrets (security)
  3. Baseline fingerprint includes hash — changed secrets on same line now detected
  4. Scanner uses find_iter() instead of find() — catches all matches per detector
  5. PrivateKeyContentDetector fixed — uses (?s) flag for proper multiline matching
  6. Added keywords to ~85 detectors and entropy thresholds to 5 generic detectors
  7. Added 13 Indian fintech/brokerage detectors (Razorpay, Paystack, CRED, PhonePe, Paytm, Zerodha, Upstox, Groww, Angel Broking, ZebPay, CoinDCX, WazirX, Unocoin)

Code Quality

  • Zero clippy warnings (cargo clippy --all-targets --all-features)
  • Formatted with cargo +nightly fmt --all
  • Public API unit tests moved to tests/ integration tests
  • All 78 tests pass

Context

Closes #71.

How did you test it?

  • cargo test — all 78 tests pass
  • cargo clippy --all-targets --all-features — zero warnings
  • cargo +nightly fmt --all — clean
  • Manual testing of baseline workflow, stdin piping, and git history scanning

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@pixincreate
pixincreate force-pushed the feat/missing-features branch from a49af08 to 95aab1a Compare July 29, 2026 18:09
- Improve OpenAI API key regex (word boundaries, 48+ chars)
- Add OpenCode API key detector (context-based sk- prefix)
- Add 63+ new prefix-based detectors covering:
  - AI services (Anthropic, Cohere, HuggingFace, Mistral, Groq, Replicate, LangSmith)
  - Cloud/Infra (Vercel, Netlify, Supabase, Convex)
  - Monitoring (Datadog, New Relic, PagerDuty, Sentry, Elastic)
  - DevOps (GitLab PATs, Buildkite, TravisCI, Ngrok)
  - Messaging (Confluent)
  - Productivity (Airtable, HashiCorp Vault, Terraform)
- Remove redundant context-based 32-hex detectors (covered by GenericKeyValueDetector)
- Strip verbose descriptions from detectors.toml
- Fix justfile trailing newline

Refs: #57
- Add Critical variant to Severity enum
- Update from_string() to parse CRITICAL
- Update get_severity_counts() to return 4-tuple (critical, high, medium, low)
- Update calculate_exit_code() to treat Critical like High in critical mode
- Update severity display output to include CRITICAL count
- Update tests for new 4-tuple format

Fixes part of #68
- Add baseline module (src/baseline.rs) with JSON serialization
- Add --baseline <path> flag to suppress known findings
- Add --update-baseline flag to write baseline from current scan
- Baseline matching uses file_path + line_number + finding_type + plugin_name
- Integration tests for filtering, save/load, and from_findings

Refs #68
@pixincreate
pixincreate force-pushed the feat/missing-features branch from 95aab1a to 4a2bbdc Compare July 29, 2026 18:13
@pixincreate pixincreate self-assigned this Jul 29, 2026
@pixincreate pixincreate added the enhancement New feature or request label Jul 29, 2026
@pixincreate pixincreate changed the title feat: implement missing features per gap analysis (#68) feat: implement missing features per gap analysis Jul 30, 2026
@pixincreate
pixincreate marked this pull request as ready for review July 30, 2026 16:05
@pixincreate
pixincreate force-pushed the feat/missing-features branch from 30b8b56 to beee475 Compare July 30, 2026 16:32

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.

Pull request overview

Implements multiple “gap analysis” scanning capabilities in KeyWatch, expanding both the detection configuration model and scan execution modes (stdin, git history, parallel file scanning), while adding suppression workflows (baseline + inline ignore) and new detector metadata (keywords/allowlist/entropy).

Changes:

  • Added CRITICAL severity support end-to-end (parsing, reporting, exit code behavior, tests/docs).
  • Implemented baseline suppression/update, inline suppression (keywatch:ignore), and per-detector allowlist/keywords/entropy filtering.
  • Parallelized file scanning with rayon and added stdin + git history scanning paths.

Reviewed changes

Copilot reviewed 16 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
typos.toml Adds project-specific typos ignore rules.
tests/scanner_tests.rs Updates scan-args construction; adds new integration tests for inline suppression/stdin/git history.
tests/report_tests.rs Updates severity counting expectations for CRITICAL.
tests/detector_tests.rs Adds tests for allowlist, keyword prefilter, and entropy threshold behavior.
tests/baseline_tests.rs Adds baseline filtering/load/save/update tests (hash-based storage).
src/utils.rs Removes a doc comment.
src/scanner.rs Adds inline suppression, allowlist/keywords/entropy checks, chunked stream scanning, git history/stdin scanning, and rayon-based parallel file scanning.
src/report.rs Adds CRITICAL severity and expands severity counts tuple.
src/lib.rs Applies baseline filtering/update workflow and updates CLI warning output and exit-code logic.
src/detector.rs Extends detector model with allowlist/keywords/entropy and implements keyword/entropy helpers.
src/cli.rs Adds --stdin, --git-history, --baseline, --update-baseline, and scan-args validation.
src/baseline.rs Introduces hashed baseline format with merge/update and filtering.
README.md Documents stdin scan, git history scan, baseline usage, inline suppression, and updated exit-mode semantics.
justfile Minor formatting/line-number normalization.
detectors.toml Adds keywords/entropy metadata, fixes some patterns, and adds many new detectors.
CHANGELOG.md Documents new features/fixes and behavior changes.
Cargo.toml Adds rayon and sha2 dependencies.
Cargo.lock Locks new dependency graph (rayon/sha2 and transitive deps).
.gitignore Ignores /.omo.

Comment thread detectors.toml Outdated
Comment thread detectors.toml Outdated
Comment thread src/baseline.rs
Comment thread tests/scanner_tests.rs Outdated
Comment thread src/scanner.rs
@pixincreate
pixincreate force-pushed the feat/missing-features branch 2 times, most recently from b6c143a to eedadcb Compare August 1, 2026 18:52
@pixincreate
pixincreate merged commit 97637e1 into master Aug 2, 2026
5 checks passed
@pixincreate
pixincreate deleted the feat/missing-features branch August 2, 2026 08:05
@pixincreate
pixincreate restored the feat/missing-features branch August 2, 2026 08:05
@pixincreate
pixincreate deleted the feat/missing-features branch August 2, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add config file, SARIF output, CI/CD integrations, and betterleaks-inspired features

2 participants