feat: user config file, SARIF output, detector overrides, pre-commit hooks - #73
Open
pixincreate wants to merge 20 commits into
Open
feat: user config file, SARIF output, detector overrides, pre-commit hooks#73pixincreate wants to merge 20 commits into
pixincreate wants to merge 20 commits into
Conversation
pixincreate
force-pushed
the
feat/config-sarif-more
branch
2 times, most recently
from
July 30, 2026 16:02
2514f31 to
ebb9d17
Compare
pixincreate
force-pushed
the
feat/config-sarif-more
branch
from
July 30, 2026 16:38
ebb9d17 to
83613f4
Compare
…feat/config-sarif-more * origin/feat/github-action-docker: docs(changelog): add GitHub Action and Docker entries docs(changelog): add PR review fix entries chore(deps): bump toml from 1.1.3+spec-1.1.0 to 1.1.4+spec-1.1.0 (#70) # Conflicts: # CHANGELOG.md
…feat/config-sarif-more * origin/feat/github-action-docker: refactor: use const for baseline version and domain separator, rename severity param chore: bump GitHub Actions to latest versions, minimize Docker image to scratch
There was a problem hiding this comment.
Pull request overview
This PR closes the remaining feature gaps from #71 by adding user-configurable scanning behavior via a TOML config file, introducing SARIF output for Code Scanning integration, and expanding integration support via pre-commit hooks, while also reinstating CRITICAL severity handling across the reporting/exit-code pipeline.
Changes:
- Added
.keywatch.tomlsupport (custom rules, per-detector enable/disable + severity overrides, and config-driven exclude patterns). - Added
--formatwith SARIF 2.1.0 output generation alongside JSON. - Refactored hook install/uninstall into
src/hooks.rsand added pre-commit framework hook definitions.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scanner_tests.rs | Updates tests for new ScanArgs fields and run_scan signature. |
| src/scanner.rs | Accepts optional config, applies detector overrides, and merges config exclude patterns. |
| src/report.rs | Adds CRITICAL severity and implements SARIF report generation. |
| src/lib.rs | Loads config, selects JSON vs SARIF output, and routes hook commands through hooks module. |
| src/hooks.rs | Implements install_hook/uninstall_hook and hook-safety logic in the hooks module. |
| src/config.rs | Introduces config parsing/loading and applying custom rules/overrides/excludes to detectors. |
| src/cli.rs | Adds --config and --format CLI options plus OutputFormat enum. |
| README.md | Adds an architecture section and references the new diagram. |
| docs/architecture.svg | Adds an SVG architecture diagram for documentation. |
| CHANGELOG.md | Documents config, SARIF, CLI flag changes, and updated severity counts/run_scan signature. |
| .pre-commit-hooks.yaml | Adds pre-commit hook metadata for KeyWatch scanning. |
Suppressed comments (2)
src/report.rs:120
- SARIF
resultobjects requireruleId, but this struct currently serializesrule_id(snake_case), which breaks SARIF 2.1.0 schema expectations.
#[derive(Serialize)]
struct SarifResult {
rule_id: String,
level: &'static str,
message: SarifMessage,
src/report.rs:134
- SARIF location fields are currently serialized as
physical_location,artifact_location, andstart_line(snake_case). SARIF 2.1.0 expectsphysicalLocation,artifactLocation, andstartLine, so the report will not be schema-compliant.
#[derive(Serialize)]
struct SarifLocation {
physical_location: SarifPhysicalLocation,
}
…feat/config-sarif-more
* feat/github-action-docker: fix: guard Unix-only hook test imports # Conflicts: # tests/hooks_tests.rs
pixincreate
force-pushed
the
feat/config-sarif-more
branch
from
August 1, 2026 18:29
6cbb2bc to
90caf45
Compare
pixincreate
force-pushed
the
feat/config-sarif-more
branch
from
August 1, 2026 18:52
90caf45 to
d575d74
Compare
* feat/github-action-docker: style: use descriptive scanner test errors refactor: simplify baseline hashing refactor: clarify pre-push remote policy shell # Conflicts: # tests/hooks_tests.rs
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.
Summary
Implements the remaining non-CI/CD feature gaps from #71: user-configurable
.keywatch.toml, SARIF output format, per-detector enable/disable and severity overrides, and pre-commit framework support.Changes
User Config (
.keywatch.toml)src/config.rsmodule for loading and parsing user config--config <path>or auto-detected (.keywatch.toml→keywatch.toml→.kw.toml)detectors.toml--excludeCLI flagExample config:
SARIF Output
--formatflag:key-watch scan <paths> --format sariferror, MEDIUM →warning, LOW →noteCRITICAL Severity
Severity::Criticalvariant (serialized asCRITICAL)from_string()now recognizes "CRITICAL"get_severity_counts(Critical counted with High)Per-Detector Enable/Disable
enabled = false)Pre-Commit Framework
.pre-commit-hooks.yamlfor use with pre-commitCRITICAL Severity Variant
This PR reinstates the CRITICAL severity level (also in PR #69, not yet in master) so users can flag high-value secrets (AWS root, GitHub PATs) above standard HIGH.
Future Work (not in this PR)