Fix scan_directory sandbox validation#159
Conversation
Review: Fix scan_directory sandbox validationSummary This PR strengthens sandbox validation for What I liked
Security
Correctness / logic
Performance
Code quality
Tests
Suggested fixes
if step.action == "scan_directory":
raw_path = step.params.get("path")
if raw_path:
demo_dir = Path("./demo_projects").resolve()
requested = Path(raw_path).expanduser().resolve()
try:
requested.relative_to(demo_dir)
except ValueError:
logger.warning("Path '%s' outside demo sandbox", requested)
return RejectionReason.PATH_NOT_ALLOWED
if step.action == "scan_directory":
if (raw_path := step.params.get("path")):
demo_dir = Path("./demo_projects").resolve()
requested = Path(raw_path).expanduser().resolve()
try:
requested.relative_to(demo_dir)
except ValueError:
logger.warning("Path '%s' outside demo sandbox", requested)
return RejectionReason.PATH_NOT_ALLOWEDQuestions for the author
Overall: This is a clean, focused security improvement. The path validation logic is sound, and the defense-in-depth approach is well-executed. The only real issue is the indentation inconsistency, which is minor. Nice work closing #112! |
|
(could not anchor to Inconsistent indentation — lines 82-88 use 1-2 spaces instead of the file's standard 4-space indentation. Consider running |
|
Addressed the review feedback and pushed the changes in commit 039f613. The policy validation logic has been updated accordingly. Please take another look when you get a chance. Thanks! |
fddc7ee to
c979a29
Compare
|
Hi @gautammanak1, I've addressed all the review feedback, added the required changelog entries, and updated the branch with the latest changes from main. The checks are passing on my side. Could you please take a final look when you have a chance? Thank you for the review and feedback. |
Summary
This PR fixes sandbox validation issues for
scan_directoryoperations and strengthens path enforcement across the workflow.Changes
scan_directorypaths in the orchestrator policy.Path.relative_to()instead of string prefix matching.Testing
68 passed in 10.73s
closes #112