Conversation
- Factor hook generation into generateHookContent() helper (fixes drift) - Prefer PATH lookup first (command -v roborev), fall back to baked path (enables upgrades without hook reinstall) - Add 2>/dev/null to silence any stderr from roborev enqueue - Add TestGenerateHookContent to verify hook structure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Hook now uses baked absolute path first, only falls back to PATH if baked path is missing (prevents PATH injection attacks) - Tests now verify: baked path comes before PATH lookup, enqueue line has all required parts on same line, baked path is quoted Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Collaborator
Author
|
@sinzin91 I'm going to cut a release after merging this, let me know if this breaks your workflow and we can work with the minions to fix |
andyxhadji
pushed a commit
to andyxhadji/roborev
that referenced
this pull request
Jan 9, 2026
…improve security, and ensure truly silent operation. (roborev-dev#13) Follow on work from code review ## Changes - **Factor out `generateHookContent()` helper** - Hook script generation was duplicated in `init` and `install-hook` commands, risking drift. Now uses a single shared function. - **Security: prefer baked path over PATH lookup** - Hook now uses the absolute path baked at install time first, only falling back to `command -v roborev` if the baked binary is missing. Prevents PATH injection attacks from repo-local or malicious binaries. - **Add stderr redirect for silence** - Hook now redirects stderr (`2>/dev/null`) so errors from `roborev enqueue --quiet` don't leak to the terminal. - **Add comprehensive tests** - `TestGenerateHookContent` verifies: - Shebang and RoboRev comment present - Baked path assignment comes before PATH fallback (security) - Enqueue line has `--quiet`, `2>/dev/null`, and `&` on same line - Baked path is properly quoted ## Hook before/after **Before:** ```sh #!/bin/sh # RoboRev post-commit hook - auto-reviews every commit roborev enqueue --quiet & ``` After: ``` #!/bin/sh # RoboRev post-commit hook - auto-reviews every commit ROBOREV="/path/to/roborev" if [ ! -x "$ROBOREV" ]; then ROBOREV=$(command -v roborev 2>/dev/null) || exit 0 [ ! -x "$ROBOREV" ] && exit 0 fi "$ROBOREV" enqueue --quiet 2>/dev/null & ``` Test plan - go test ./... passes - Run roborev install-hook --force and verify hook content - Make a commit and verify no output appears - Test with baked path removed (should fall back to PATH) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.
Follow on work from code review
Changes
generateHookContent()helper - Hook script generation was duplicated ininitandinstall-hookcommands, risking drift. Now uses a single shared function.command -v roborevif the baked binary is missing. Prevents PATH injection attacks from repo-local or malicious binaries.2>/dev/null) so errors fromroborev enqueue --quietdon't leak to the terminal.TestGenerateHookContentverifies:--quiet,2>/dev/null, and&on same lineHook before/after
Before:
After:
Test plan