Fix 10 audit bugs: path prefix matching, verdict parsing, CORS, stale-task detection, phase mapping
CI / build (push) Has been cancelled

Batch 1 (High severity):
- Bug 1: --audit cat3 now checks .automaton/tasks/ paths
- Bug 4: Verdict PASS/FAIL uses structured ## Status: line parsing
- Bug 5: register-guards.sh checks .json/.jsonc, writes plugin key, strips comments
- Bug 7: --can-edit/--scope-check path prefix uses os.sep boundary

Batch 2 (Medium/Low severity):
- Bug 2: migrate-project.sh find command parentheses for -prune binding
- Bug 3: vram_detect model prefix matching with known-suffix whitelist
- Bug 6: dashboard reads .state file before artifact heuristic fallback
- Bug 8: removed wildcard CORS, added security headers (nosniff, DENY)
- Bug 9: stale-task detection uses .state.lastedit instead of .state mtime
- Bug 10: TEST_PLAN.md maps to test_design (was implement)

249 tests pass (up from 235). All 10 tasks driven through full workflow to completion.
This commit is contained in:
Lap Tran
2026-06-22 10:40:58 -04:00
parent f32f98575b
commit 81ccf548e5
106 changed files with 1643 additions and 436 deletions
+1
View File
@@ -0,0 +1 @@
complete
@@ -0,0 +1,2 @@
research:approved|2026-06-22T13:56:13.904635+00:00|user
code_review:approved|2026-06-22T14:06:37.059516+00:00|user
@@ -0,0 +1,19 @@
# Adversarial Bug Report: fix-can-edit-path-prefix
## Summary
Adversarial review of the path prefix fix. No additional bugs found.
## Bugs Found
No bugs found.
## Analysis
- **Security — symlink bypass**: `Path(args.file).resolve()` resolves symlinks before comparison, so a symlink inside the project pointing outside would be resolved to the real path and correctly rejected. Good.
- **Trailing slash**: The `== proj_str` clause handles the edge case where `file_path` is exactly the project directory. `Path.resolve()` strips trailing slashes, so this is robust.
- **Case sensitivity**: On macOS (default filesystem is case-insensitive), `Path.resolve()` does not normalize case. A file at `/Users/user/Project/file.py` would not match project `/Users/user/project`. This is consistent with the original behavior and not a regression.
- **Framework vs project**: The fix applies `os.sep` to both `proj_str` and `auto_str` checks — consistent across all 5 locations.
- **Empty file path**: `args.file` is required by argparse for `--can-edit --file` and `--scope-check`, so empty paths are not reachable.
## Score
0
ADVERSARIAL_BUG_FIND_COMPLETE
@@ -0,0 +1,16 @@
# Bug Report: fix-can-edit-path-prefix
## Summary
The fix correctly prevents sibling-directory bypass at all 5 locations in status.py.
## Bugs Found
No bugs found.
## Verification
- `str(file_path).startswith(proj_str + os.sep) or str(file_path) == proj_str` correctly handles both files inside the directory and the directory itself.
- All 5 locations use the same consistent pattern.
- `Path.resolve()` is called on `file_path`, so symlinks are resolved before comparison.
- 3 tests pass: sibling-rejection, subdirectory-acceptance, can-edit-task.
## Score
0
@@ -0,0 +1,15 @@
# Code Review: fix-can-edit-path-prefix
## Summary
Fixes path prefix matching at 5 locations to prevent sibling-directory bypass.
## Findings
- **Correctness**: `str(file_path).startswith(proj_str + os.sep) or str(file_path) == proj_str` correctly handles both files inside the directory and the directory itself. The `os.sep` ensures the boundary is a path separator, preventing `/home/user/project-evil` from matching `/home/user/project`.
- **Consistency**: All 5 locations use the same pattern — good.
- **Edge cases**:
- A file exactly at `proj_str` (the project root itself) is handled by the `== proj_str` clause.
- Symlinks: `Path.resolve()` is called on `file_path`, so symlinks are resolved before comparison. This is correct.
- **Tests**: 3 tests cover the sibling-rejection, subdirectory-acceptance, and can-edit-task scenarios.
## Verdict
APPROVED — no issues found.
@@ -0,0 +1,12 @@
# Doc Review: fix-can-edit-path-prefix
## Summary
No documentation updates needed. The `--can-edit` and `--scope-check` commands' external behavior is unchanged — only the internal path comparison logic was fixed.
## Findings
- README.md, AGENTS.md, and contracts/harness-integration.md document `--can-edit` and `--scope-check` usage but not the internal path comparison implementation.
- The fix does not change any command-line interface, output format, or exit code.
- No user-facing behavior change for valid use cases (only invalid sibling-directory bypass is now correctly rejected).
## Verdict
No doc changes required.
@@ -0,0 +1,12 @@
# Implementation: fix-can-edit-path-prefix
## Changes
- **scripts/status.py** `cmd_can_edit()` (5 locations): Replaced `str(file_path).startswith(proj_str)` with `str(file_path).startswith(proj_str + os.sep) or str(file_path) == proj_str` to prevent sibling-directory bypass. Same fix applied to `auto_str` (framework directory) checks.
- Line ~986: `--can-edit --project --file` scope check
- Line ~1039: `--can-edit --task --file` framework case
- Line ~1045: `--can-edit --task --file` regular project case
- Line ~1082: `--scope-check` project check
- Line ~1087: `--scope-check` framework check
## Test
- `tests/test_status.py::TestCanEditPathPrefix` — 3 tests: sibling directory rejected by scope-check, subdirectory accepted by scope-check, sibling directory rejected by can-edit --task --file.
+30
View File
@@ -0,0 +1,30 @@
# Spec: fix-can-edit-path-prefix
## Problem
`--can-edit` and `--scope-check` in `scripts/status.py` use `str(file_path).startswith(proj_str)` to verify a file is within the project directory. String `startswith` matches sibling directories: `/home/user/project-evil/file.py` matches prefix `/home/user/project`. This allows editing files outside the project boundary.
Affected locations:
- `scripts/status.py:951` (`--can-edit --project --file`)
- `scripts/status.py:1004` (`--can-edit --task --file`, framework case)
- `scripts/status.py:1010` (`--can-edit --task --file`, regular project case)
- `scripts/status.py:1047` (`--scope-check`)
- `scripts/status.py:1052` (`--scope-check`, framework check)
## Fix
Append a trailing path separator to the prefix before comparison:
```python
str(file_path).startswith(proj_str + os.sep)
```
Or use `Path.relative_to()` which correctly resolves path boundaries:
```python
try:
file_path.relative_to(project_dir.resolve())
except ValueError:
# out of scope
```
## Acceptance Criteria
- A file in `/home/user/project-evil/` is correctly rejected as out-of-scope when project is `/home/user/project`
- A file in `/home/user/project/subdir/` is correctly accepted as in-scope
- Both framework and regular project cases work
- Add a test in `tests/test_status.py` covering the sibling-directory edge case
+27
View File
@@ -0,0 +1,27 @@
# Verdict: fix-can-edit-path-prefix
## Status: PASS
**Completion Date**: 2026-06-22
## Summary
The fix correctly prevents sibling-directory bypass at all 5 locations in status.py. All tests pass.
## Findings
- `str(file_path).startswith(proj_str + os.sep) or str(file_path) == proj_str` correctly handles path boundaries.
- All 5 affected locations use the same consistent pattern.
- Bug Finder found no bugs. Adversarial Bug Finder confirmed no issues with symlinks, trailing slashes, or case sensitivity.
- No contradictions between the two reports.
- Test coverage added: `TestCanEditPathPrefix` (3 tests covering sibling rejection, subdirectory acceptance, and can-edit-task).
- All 242 tests pass.
## Tasks for Review / Tie-Breaks
None.
## Remaining Issues
None.
## Score
+10 (PASS)
## Reviewer Comments