feat: validate path compatibility and drift checks#97
Closed
Patel230 wants to merge 2 commits into
Closed
Conversation
Add a new drift check that compares hawk's own go.mod requirements for tracked pins against what each external/ submodule declares. This helps detect version mismatches that could cause silent build-time upgrades. Related: docs/compatibility.md explains the drift concern in detail.
PatchTool, StructuredEditTool, and SmartCreateTool wrote/deleted files from LLM-authored paths without calling validatePathAllowed, the sandbox guard already used by file_write.go and file_edit.go. This let an LLM escape the working directory / allowed-directories sandbox via these three tools even though the equivalent Write/Edit tools were guarded. Thread ctx through PatchParser.ApplyAll so each patch's path (including the Delete File directive, which shares the same Apply function) is validated before any filesystem mutation. Add the same guard check to StructuredEditTool.Execute and SmartCreateTool.Execute before their ReadFile/WriteFile/MkdirAll calls. Add a regression test asserting PatchTool.Execute rejects a Create File patch targeting a path outside the allowed directories and does not create the file. Co-Authored-By: Claude Sonnet 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.
Add path validation and structured-edit compatibility drift checks.