Skip to content

fix: close path-traversal gap and harness scoring nits from full code review - #169

Closed
akshaylive wants to merge 1 commit into
mainfrom
akshaya/remove_env_vars
Closed

akshaylive wants to merge 1 commit into
mainfrom
akshaya/remove_env_vars

Conversation

@akshaylive

@akshaylive akshaylive commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

What this fixes

Security — path traversal in --resume cleanup. orchestration/batch.py::clear_rerun_artifacts joined the task-authored task_id (an unvalidated string; dataset rows use "<suite>/<row>") straight onto the run directory and rmtree'd the result with no containment check. A crafted task_id like "../../victim" could delete a directory outside the run tree. Pulled the containment check orchestration/regrade.py already applies to the same shape of field into a shared path_utils.is_within, and used it at both call sites. Added test_clear_rerun_artifacts_refuses_path_traversal to lock it in.

Correctness — unbound-variable risk in the judge's route dispatch. criteria/llm_judge.py::_invoke_tool_channel matches on route and unconditionally reads verdict/err/response_usage afterward, but the match had no wildcard arm — flagged by CodeQL (py/uninitialized-local-variable) and already fixed once before in the sibling models/routing.py::resolve_route. Added the same case _: raise AssertionError(...) arm here.

Correctness — misleading zero in report scoring. reports.py's per-criterion completion_rate computed rows_aggregated / rows_total if rows_total else 0.0, so a zero-row suite published 0.0 — indistinguishable from "measured and completely failed." pass_rate/error_share already avoid this via nothing_was_measured; completion_rate now follows suit by omitting the metric when there's no denominator, so a suite_thresholds gate on it fails closed with actual_value=None instead of a silent zero.

Type safety — rename-unsafe cost probe. batch.py's pricing-coverage check used getattr(criterion, "model", None), which would silently start returning None forever if LLMJudgeCriterion.model were ever renamed. Replaced with isinstance(criterion, LLMJudgeCriterion) narrowing.

Docs. Removed a stale optimize/ line from CLAUDE.md's directory tree — the package doesn't exist anymore.

Context

Found via a full 8-axis code review (/coder-eval-code-review-full, all axes, no scope filter — report kept locally under gitignored tmp/, not part of this diff). These five are the findings that were both real and safely fixable without a design call. Deliberately left out, each needing its own decision: docker image tags colliding under parallel variant builds, the same checker-misuse-vs-agent-failure gap (CE039) in 5 more criteria, generate_run_id()'s same-second collision risk, UiPath credentials forwarded into every sandbox by default, and orchestrator.py being a 3443-line god class. One reviewed candidate — LiteLLM route allegedly missing temperature — turned out to be intentional per its own docstring; no change made.

Testing

Full suite: 6167 passed, 8 skipped, 0 failed. ruff/pyright/all 635 CE0xx lint checks clean.

🤖 Generated with Claude Code

… review

Ran the full 8-axis coder-eval-code-review-full pass and fixed the
mechanically-safe, high-confidence findings:

- orchestration/batch.py::clear_rerun_artifacts joined an unvalidated
  task_id onto the run dir and rmtree'd it with no containment check,
  letting a crafted task_id delete outside the run directory. Extracted
  regrade.py's containment check into a shared path_utils.is_within and
  applied it here too, with a regression test.
- criteria/llm_judge.py's route-dispatch match had no exhaustiveness arm
  (confirmed py/uninitialized-local-variable CodeQL alert); added the same
  case _: raise AssertionError(...) pattern already used in
  models/routing.py::resolve_route.
- reports.py's per-criterion completion_rate published a bare 0.0 for a
  zero-row suite instead of following the nothing_was_measured convention
  pass_rate/error_share already use; now omitted so a suite_thresholds gate
  fails closed with a visible actual_value=None.
- batch.py's cost-pricing-coverage check used an untyped
  getattr(criterion, "model", None) probe; replaced with isinstance
  narrowing against LLMJudgeCriterion, the only union member with that
  field.
- Removed a stale optimize/ line from CLAUDE.md's directory tree.

Larger findings (docker image-tag collisions under parallel builds, CE039
discipline gaps across 5 criteria checkers, generate_run_id collision risk,
UiPath credentials forwarded by default, a 3443-line orchestrator.py) are
documented in tmp/code-review-20260914-124404/ for dedicated follow-up
rather than bundled here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@UiPath UiPath deleted a comment from github-actions Bot Sep 14, 2026
@akshaylive akshaylive closed this Sep 14, 2026
@akshaylive
akshaylive deleted the akshaya/remove_env_vars branch September 14, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant