Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
| if rel != tasks and not rel.startswith(f"{tasks}/"): | ||
| continue |
There was a problem hiding this comment.
Validate task files reachable through internal directory aliases.
Trigger: .agent-eval/tasks/t1 -> ../shared, with .agent-eval/shared/task.json linking to an external host JSON file.
Evidence: WorkTree.files() and GitTree.files() list tasks/t1 without its descendants. Resolving that entry with dirs=True succeeds, while this filter skips shared/task.json. Export preserves both links, and load_tasks() discovers tasks/t1/task.json through the directory alias and reads its external target.
Impact: external JSON bypasses the new refusal and can enter cell artifacts when it has valid task keys.
Workaround: replace directory aliases with ordinary task directories.
Should fix: A run shows it, and the code before this change fails the same way.
Shown by running: exit 1 (at the head) · exit 1 (at the merge base) · exit 0 (at the head with the fix)
python -m pytest -q -p no:randomly -p no:cacheprovider tests/test_proof_c2.py
What the proof does: Runs repo run on a repo where tasks/t1 links to ../shared, whose task.json links outside the repo, and asserts exit 2 with path escapes the repository.
The problem shows as the output DIR_ALIAS_NOT_REFUSED.
Script: dokimi/tests/test_proof_c2.py (46 lines).
out = run.stdout + run.stderr
> assert 'path escapes the repository' in out and run.returncode == 2, 'DIR_ALIAS_NOT_REFUSED ' + out
E AssertionError: DIR_ALIAS_NOT_REFUSED ✗ .agent-eval/tasks/t1/task.json: missing or empty required key 'family'; missing or empty required key 'prompt'
E
E assert ('path escapes the repository' in "✗ .agent-eval/tasks/t1/task.json: missing or empty required key 'family'; missing or empty required key 'prompt'\n")
tests/test_proof_c2.py:46: AssertionError
=========================== short test summary info ============================
FAILED tests/test_proof_c2.py::test_dir_alias_to_external_task_is_refused - A...
1 failed in 1.18s
| if rel != tasks and not rel.startswith(f"{tasks}/"): | ||
| continue | ||
| try: | ||
| tree.resolve(rel, dirs=True) |
There was a problem hiding this comment.
Validate containment after relocation, not only in the source tree.
Trigger: use eval_dir: a/b/c/d, tasks: a/b/c/d/tasks, and tasks/t1/task.json -> ../../../../../../outside.json, with a tracked outside.json at the repository root.
Evidence: both WorkTree and GitTree resolve this inside the repository, so this check accepts it; _export() preserves the link and moves the eval directory. With --out-dir /tmp/demo/b --name run, the exported link instead targets /tmp/demo/outside.json. _require_grade() immediately calls load_tasks(), whose read_text() follows that link without containment validation.
Impact: host-local JSON is read and, if it has valid task keys, can be persisted through runner.py's task.raw writer.
Workaround: use regular task files or links contained within the exported eval directory.
Should fix: A run shows it, and the code before this change fails the same way.
Shown by running: exit 1 (at the head) · exit 1 (at the merge base) · exit 0 (at the head with the fix)
python -m pytest -q -p no:randomly -p no:cacheprovider tests/test_proof_c1.py
What the proof does: Runs repo run on a repo with a relative task.json link that stays inside the repo but leaves the relocated eval_dir, and asserts exit 2 with path escapes the repository.
The problem shows as the output RELOCATED_LINK_NOT_REFUSED.
Script: dokimi/tests/test_proof_c1.py (44 lines).
out = run.stdout + run.stderr
> assert 'path escapes the repository' in out and run.returncode == 2, 'RELOCATED_LINK_NOT_REFUSED ' + out
E AssertionError: RELOCATED_LINK_NOT_REFUSED ✗ [Errno 2] No such file or directory: '/tmp/pytest-of-root/pytest-0/test_relocated_relative_link_i0/b/run/_eval/content/tasks/t1/task.json'
E
E assert ('path escapes the repository' in "✗ [Errno 2] No such file or directory: '/tmp/pytest-of-root/pytest-0/test_relocated_relative_link_i0/b/run/_eval/content/tasks/t1/task.json'\n")
tests/test_proof_c1.py:44: AssertionError
=========================== short test summary info ============================
FAILED tests/test_proof_c1.py::test_relocated_relative_link_is_refused - Asse...
1 failed in 1.18s
| if not task_json.is_file(): | ||
| continue |
There was a problem hiding this comment.
Validate containment before filtering by file type.
Trigger: use the relocation fixture's relative link, keep repo/outside.json a tracked regular file, but make tmp_path/outside.json a FIFO.
Evidence: source resolution accepts the repository file; after export, task_json.is_file() returns false for the FIFO, so this check skips it, while load_tasks() discovers the symlink with glob("*/task.json") and _read_task_json() opens it without a regular-file check.
Impact: _require_grade() blocks reading the host FIFO instead of refusing the escaped path; the relocation fix therefore still has a containment bypass. Resolve and check containment for every task.json entry the consumer discovers before applying any file-type filter.
Workaround: avoid task symlinks in untrusted eval trees.
Should fix: A run shows it; it was not judged to be met in ordinary use.
Shown by running: exit 1 (at the head) · exit 1 (at the merge base, which cannot run it) · exit 0 (at the head with the fix)
python review_fifo_proof_runner.py
What the proof does: Creates a tracked relative task link and a real external FIFO, calls the source validation and export code, and checks that exported-path validation refuses the escaped entry discovered by the task loader's glob.
The problem shows as the output AssertionError: escaped FIFO task.json must be rejected before task loading.
Script: dokimi/tests/test_review_fifo_containment.py (53 lines), dokimi/review_fifo_proof_runner.py (8 lines).
except InputError as exc:
assert 'path escapes the repository:' in str(exc)
else:
> raise AssertionError('escaped FIFO task.json must be rejected before task loading')
E AssertionError: escaped FIFO task.json must be rejected before task loading
tests/test_review_fifo_containment.py:53: AssertionError
=========================== short test summary info ============================
FAILED tests/test_review_fifo_containment.py::test_exported_fifo_link_must_be_refused
1 failed in 0.64s
| out = run.stdout + run.stderr | ||
| assert "path escapes the repository" in out, out | ||
| assert run.returncode == 2, out | ||
| \n No newline at end of file |
There was a problem hiding this comment.
Remove the literal trailing \n characters.
Trigger: pytest collects this module.
Impact: Python raises a SyntaxError before any regression tests execute, interrupting test collection.
Evidence: line 129 contains a backslash followed by n outside a string; the local Ruff check confirms Expected a newline after line continuation character at this line.
Workaround: delete these characters or replace them with an actual newline.
Should fix: A run shows the tests do not catch this.
Shown by running: exit 1 (at the head) · exit 1 (at the merge base, which cannot run it) · exit 0 (at the head with the fix)
python tests/_parse_check.py
What the proof does: Parses the new test module with ast.parse and exits 1 on SyntaxError.
The problem shows as the output PARSE FAILED.
dokimi/tests/_parse_check.py
import ast, sys
src = open('tests/test_repo_run_task_link_escape.py', encoding='utf-8').read()
try:
ast.parse(src)
except SyntaxError as e:
print('PARSE FAILED: ' + str(e))
sys.exit(1)
print('ok')PARSE FAILED: unexpected character after line continuation character (<unknown>, line 129)
|
|
||
| repo_run._context(args, tmp_path, SimpleNamespace()) | ||
|
|
||
| assert calls == [("source", tree, manifest), ("exported", content, manifest)] No newline at end of file |
There was a problem hiding this comment.
The ordering assertion does not observe the security boundaries.
Trigger: move _check_exported_task_json_links() below _require_grade() (or source validation below export), keeping the two validators in their current relative order.
Evidence: export and _require_grade are unrecorded stubs, so calls and this assertion remain unchanged.
Impact: this regression test passes even when task JSON is read before containment validation. Record export and _require_grade in the same event list and assert source check → export → exported check → grade.
Workaround: retain the current production ordering and inspect it manually.
Should fix: A run shows the tests do not catch this.
Shown by running: exit 0 (tests, code unchanged) · exit 0 (tests, code broken on purpose) · exit 0 (suggested test, code unchanged) · exit 1 (suggested test, code broken on purpose)
python -m pytest -q -p no:randomly -p no:cacheprovider tests/test_repo_run_task_link_escape.py::test_context_checks_task_links_before_and_after_export
. [100%]
1 passed in 0.75s
Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Cover task-directory aliases and links that escape after eval-directory relocation; document the refusal contract and changelog entry. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: sazid63 <322897530+sazid63@users.noreply.github.com>
Exercise source and exported-tree validation directly, including unresolved paths and checks around eval export. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
d85511d to
420d2e2
Compare
Refuse escaped FIFO targets and dangling task symlinks, and assert task loading follows both containment checks. Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1611 +/- ##
==========================================
+ Coverage 96.45% 96.49% +0.03%
==========================================
Files 565 570 +5
Lines 74867 75284 +417
Branches 12930 12985 +55
==========================================
+ Hits 72216 72643 +427
+ Misses 1628 1614 -14
- Partials 1023 1027 +4
🚀 New features to boost your workflow:
|
|
|
||
|
|
||
| @pytest.mark.parametrize(("create_tasks", "create_task_file"), [(False, False), (True, False), (True, True)]) | ||
| def test_exported_task_link_check_skips_missing_tasks( |
There was a problem hiding this comment.
CI check Tests (py3.14) fails: The added helpers push repo_run.py from 793 to 843 measured lines, exceeding the 800-line cap without a baseline entry; extract the helpers into a separate module. The new missing-tasks test also has no assertion; its deliberate must-not-raise behavior can use the audit's documented exemption with a reason. Proposed fix, not run by the bot.
| def test_exported_task_link_check_skips_missing_tasks( | |
| def test_exported_task_link_check_skips_missing_tasks( # test-quality: ok must-not-raise smoke test for missing tasks and ordinary task files |
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 4661cd9)
- Contract: candidate. errors dokimi/dokimi/commands/repo_run.py:159; errors dokimi/dokimi/commands/repo_run.py:181
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
Open issues to resolve on 4661cd9d.
- The growth check passes at the merge base and fails on head because repo_run.py has 843 measured lines against the 800-line cap. CI also rejects the new test with no assertion. Earlier finding
Both task-path fixes touch the same preparation flow and conflict in their shared test file. Reconcile this PR with #1610 before merging either.
Reviewed the diff, edge cases and prior threads. Path containment was reviewed statically. The full local suite was outside coverage.
|
@napetrov I've updated this PR to address the remaining security review findings and reconciled its scope with #1610. The latest changes:
The intended division is:
Both changes are intended to form complementary layers of the same security boundary. Please review the latest commits and let me know if you see any remaining concerns before these are considered ready for merge. |
| # strict=False still resolves dangling symlinks, so an external missing target | ||
| # is rejected. In-tree dangling links and loops are left to load_tasks(), | ||
| # which knows whether the task was selected. |
There was a problem hiding this comment.
CI check Static checks (ruff, schema, zizmor, licenses, pre-commit, bandit, secrets, changelog, schema com... fails: The new comment at task_source.py:45–47 has three consecutive full-line comments. The comment-block checker rejects changed blocks longer than two lines, matching the failed step's diagnostic. Proposed fix, not run by the bot.
| # strict=False still resolves dangling symlinks, so an external missing target | |
| # is rejected. In-tree dangling links and loops are left to load_tasks(), | |
| # which knows whether the task was selected. | |
| # Resolve dangling targets to reject escapes; defer in-tree broken links | |
| # and loops to selection-aware load_tasks(). |
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
bdc16b4 to
d472aab
Compare
|
@napetrov Follow-up on the latest head ( The outstanding findings have been addressed in the updated implementation and regression tests:
The latest changes are pushed. The remaining GitHub workflow runs are awaiting maintainer approval. Please review the current head and let me know if anything remains before merge. |
Mutation of changed linesAt 8d6ae2d: 21 caught · 0 missed · 2 waived Not checked:
Marked harmless with
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
b9f1049 to
b7043b7
Compare
…ations Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
6c6c786 to
8d6ae2d
Compare
vchamarthi
left a comment
There was a problem hiding this comment.
@sazid63, could you fix the 2 small things I've marked fix before merge (in the line comments) and answer my question below? I'll approve once that's done.
I'll approve once that's done.
My question before I approve:
- A task directory that links outside the eval directory after relocation, with no
task.jsonin it, is skipped without a refusal, and the run saysno task underwhen it is the only task. Decide which is meant: refuse this link and add a test for it, or keep skipping it and change that comment and the contract sentence to say so.
Optional, non-blocking (1)
dokimi/dokimi/repos/task_source.py:37: An eval directory that is itself a link to a directory outside the repository is still read (main has it too).
What I checked on 8d6ae2d:
- When I changed the code on purpose, the tests still passed for 2 of 9 changes, and no test pins this one down yet (non-blocking):
dokimi/dokimi/repos/task_source.py:28(the handled error is raised again). - The 18 changed tests pass, and fail on main as expected.
- The full test suite passes with main merged in (36,280 tests), apart from failures main has too.
- It merges cleanly onto main.
| """Exit 2 for what the user typed and for task-file links that leave the tree. | ||
| Other paths supplied by the tree are checked by the operation that reads them.""" |
There was a problem hiding this comment.
Fix before merge (blocking): The refuse_typed docstring says it refuses task-file links, but that check is in _context.
I tested this suggestion: it fixes the problem, and the tests still pass.
| """Exit 2 for what the user typed and for task-file links that leave the tree. | |
| Other paths supplied by the tree are checked by the operation that reads them.""" | |
| """Exit 2 for what the user typed, and for a ``--manifest`` or ``--suite`` leaving the tree. | |
| Task links are checked in ``_context``; other tree paths fail later, with exit 1.""" |
Details
The first line of the docstring says refuse_typed exits 2 for task-file links that leave the tree. Its body checks only the typed source, the manifest and the suite paths. The task links are checked in _context, at repo_run.py:91 and :100, so this sentence describes the wrong function.
| target = task_json.resolve(strict=False) | ||
| target.relative_to(root) | ||
| except ValueError as exc: | ||
| raise InputError(f"path escapes the repository: {tasks}/{task_dir.name}/task.json") from exc |
There was a problem hiding this comment.
Fix before merge (blocking): A task link to a file inside the repository but outside the eval directory fails as path escapes the repository.
Suggestion: Give this refusal its own message that names the eval directory, and update the relocation test in dokimi/tests/test_repo_run_source_task_link_escape.py that asserts the current text.
Details
I made .agent-eval/tasks/t1/task.json a symlink to docs/shared.json, a tracked file outside .agent-eval. On the latest commit repo run exits 2 with path escapes the repository: .agent-eval/tasks/t1/task.json, but the target is in the repository. On the base commit 0eeae5f it exits 1 with a missing-file error. I'd expect a message that says the link leaves the exported eval directory, since that is what this check tests.
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
Signed-off-by: Sajid Hossain <322897530+sazid63@users.noreply.github.com>
|
@vchamarthi I've pushed the requested updates:
I've left the evaluation-directory symlink behaviour unchanged to keep the scope of this PR focused. The updated CI workflows are currently awaiting approval, so the full test results are not available yet. I'll follow up once they have run. I'll also coordinate the integration with #1610 before either PR is merged. |
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 0fbb7d2)
- Contract: candidate. defaults dokimi/dokimi/repos/task_source.py:14; errors dokimi/dokimi/repos/task_source.py:20
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
No new actionable findings.
This PR adds source and post-export containment checks before repo run uses tasks. It overlaps #1610, which checks containment in the shared exported-task loader.
Review alongside #1610 so the source/export checks and the shared task loader agree on scope. Nine focused task-selection and check-order tests passed on the combined tree.
CI on head 0fbb7d2: 0 failing Actions jobs; merge base 0eeae5f is behind base tip 5225c2a.
Compared the change and input edges against the merge base and checked existing threads and GitHub Actions. Runtime checks used local fixtures. Live credentials and external path access were outside the review. Focused tests on the head: extra 6 passed, 20 deselected in 0.60s.
Summary
Prevent
repo runfrom reading task JSON through symlinks that escape the source repository or the relocated eval directory.Changes
Risk
Only escaping or unresolvable task paths are newly refused. No artifact schema or persisted format changes.
Testing
test_blob_less_clone_reads_manifests_in_few_requests: its local filtered clone had noHEAD(2022 passed, 19 skipped before failure).Open questions
None.
Revert
Revert the PR commits; no stored data or schema migration needs undoing.
Checklist