fix(coder): address #827 + #828 auto-review findings (security + runtime)#832
Conversation
Six fixes flagged by the auto-review bot on PRs #827 and #828: Critical: - Path traversal in import_with_attribution (oss_reuse.py). dest_path is @tool-exposed (LLM-controlled) and was joined into repo_root without containment check — absolute paths and ../ traversal escaped. Now resolve + relative_to-check + AttributionError on violation. Important: - License filter silent-drop in _validate_license_filter (oss_reuse.py). Unknown SPDX ids were silently dropped; a typo ("MIT-License") produced an empty search with no feedback. Now raises ValueError per CLAUDE.md fail-loudly. - gh_pr_merge hardcoded --admin (tools/github.py). Bypasses branch protection unconditionally. Gate behind admin_override=False default; --admin only when explicitly requested. - Webhook signature round-trip was effectively a no-op (repo_binding.py). Positive check alone would pass a verifier that always returns True. Added a wrong-signature rejection test and a wrong-payload rejection test — verifier must discriminate on both. - add_instrumented_trace produced broken targets (tools/debug.py). Probe wrote `logger.debug(...)` into files that may not bind a module-level logger; NameError at import. Now inlines __import__('logging') lookup. - diff_behavior left HEAD detached at the wrong ref (tools/debug.py). ``git switch -`` after two detached switches returns to the FIRST detached state, not the caller's original branch. Now captures original_head via symbolic-ref + rev-parse at entry and restores explicitly in the finally block. Tests: - 7 new regression tests in tests/coder/test_fixes_827_828.py. - Updated test_debug_tools.py::test_add_instrumented_trace_* to assert the mutated module actually imports (previously only asserted the string was written — would have passed even on a broken probe). - Updated test_debug_tools.py::test_diff_behavior_* to expect the new symbolic-ref call at sequence start. All 395 tests pass on coder HEAD with the fixes.
SummaryClean, well-scoped follow-up that addresses every auto-review finding from #827 and #828 with matching regression tests. The path-traversal fix in Issues Found🟢 Minor — Unused
|
…view pass) (#834) ## Summary Final cleanup pass to complete the `coder` branch for EM testing. Five Important + three Minor findings across the Phase 5/6/11 auto-reviews. All 395 tests pass. ## Changes - `test_self_fix/test_cli.py` — `pytest.raises` so a silent-pass regression in argparse can't pass the test. [#825, #829] - `test_integration_e2e.py` — real `PATH` prepend via `monkeypatch.setenv` instead of a no-op assignment that leaked env. [#829] - `test_fixes_827_828.py` — drop unused `Path` import. [#832] - `loop_driver.py` — narrow broad `except Exception` around `review_gate` and `notify_em` to `(RuntimeError, CalledProcessError, OSError)`. Programming errors now surface per CLAUDE.md fail-loudly. [#825] - `loop_driver.py` + `verifier.py` — `_append_notes` / `_append_note` raise `ValueError` on corrupted or wrong-type `notes_json` instead of silently replacing with `[]`. [#825] ## Test plan - [x] `pytest tests/coder/ tests/eval/` — 395/395 pass
Summary
Six fixes flagged by the auto-review bot: one Critical (security), five Important (two on #827, two on #828, one on both). All 395 tests pass on
coderwith the fixes.Changes
Critical (security):
oss_reuse.pyimport_with_attribution— path traversal on LLM-controlleddest_path. Now resolves +relative_to(root)-checks; raisesAttributionErroron escape.Important:
oss_reuse.py_validate_license_filter— unknown SPDX ids silently dropped; now raises per CLAUDE.md fail-loudly.tools/github.pygh_pr_merge— hardcoded--admin; now gated behindadmin_override=Falsedefault.repo_binding.pywebhook round-trip — only did positive check; added wrong-signature + wrong-payload discrimination.tools/debug.pyadd_instrumented_trace— emittedlogger.debug(...)requiring pre-boundlogger; now inlines__import__('logging')lookup.tools/debug.pydiff_behavior—git switch -after two detached switches returns to wrong ref; now captures + explicitly restores original HEAD.Test plan
pytest tests/coder/ tests/eval/— 395 passtest_fixes_827_828.pycover each fixtest_add_instrumented_trace_*now asserts the mutated module actually imports (previously asserted only the string was written)