fix: security-hardened hooks, portable config, non-UTF8 handling#52
Open
pixincreate wants to merge 23 commits intomainfrom
Open
fix: security-hardened hooks, portable config, non-UTF8 handling#52pixincreate wants to merge 23 commits intomainfrom
pixincreate wants to merge 23 commits intomainfrom
Conversation
- Add shell injection protection in generated hooks (escape user input) - Make detector loading portable (check exe dir first, then CWD) - Handle non-UTF8 files gracefully (skip binary files) - Fix filenames with spaces via IFS= read -r in pre-commit hook - Distinguish secret detection (exit 1) from runtime errors - Clean CLI help text (remove typos and non-English text) - Add comprehensive tests for new features Closes #32
- Add exit_code_on_secrets/no_secrets tests (verify findings behavior) - Add verify_integrity_flag test - Add exclude_pattern_filtering test (verify *.log exclusion works) - Add portable_config_loading test (detectors.toml loading) - Add hook_missing_binary_path and hook_missing_detectors_toml tests 21 tests now pass (was 14). Closes #32
- Document security hardening in hooks - Add Development section with just commands - Add Security Notes section - Update project structure - Add CHANGELOG entry for v1.1.0
- Move hook templates to templates/pre-push.sh and templates/pre-commit.sh - Rename v->escaped, ch->character for clarity - just check passes (21 tests)
- DEFAULT_BINARY_NAME constant - Remove generic render_template, use specific render_pre_push/pre_commit - Remove empty string placeholders from templates - just check passes
- find_keywatch() searches: PATH -> hook_dir -> target/debug - Works during development without cargo install - Remove blocking local hooks
Consolidate ScanMetadata and ReportMetadata into single struct. Move scan_time to report level, not metadata level.
- Add EXIT_MODE_ALWAYS, EXIT_MODE_CRITICAL, EXIT_MODE_STRICT constants - Add SEVERITY_HIGH constant - Use descriptive variable names instead of single-char - Remove redundant imports
- Output summary instead of JSON by default (verbose for full JSON) - Add install.sh script for easy installation to ~/.local/bin or /usr/local/bin - Add uninstall.sh script for clean removal - Update README with script-based installation instructions
- Rewrite README to be concise (~50 lines) - Add binary aliases: keywatch, watch (in addition to key-watch) - Simplify install script: cargo install first, then local binary fallback - Remove legacy hooks/keywatch.sh - Remove .pre-commit-config.yaml - Default: all repos allowed (no restrictions)
- Simplify README (~60 lines) - Rewrite CHANGELOG with clear sections - Add tests: binary_aliases, exit_mode_always, exit_mode_critical
- scanner_tests.rs (9 tests) - hooks_tests.rs (5 tests) - report_tests.rs (2 tests) - exit_tests.rs (5 tests) - utils_tests.rs (2 tests) 24 tests pass
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
Security and usability fixes for KeyWatch:
Security
key-watchis on PATH before runningUsability
IFS= read -rfor safe handlingCleanup
Testing
test_non_utf8_file_handlingtest_hook_generation_pre_pushtest_hook_generation_pre_committest_hook_shell_escapingAll tests pass (14 total).
Files changed:
src/hooks.rs- New module for hook generationsrc/detector.rs- Portable config loadingsrc/scanner.rs- Non-UTF8 handlingsrc/lib.rs- Export hookssrc/main.rs- Use hooks moduletests/integration_tests.rs- New tests