-
Notifications
You must be signed in to change notification settings - Fork 24
[WIP]patcheval env #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,6 @@ tmp/ | |
|
|
||
| # External SDK checkouts should be installed as dependencies instead. | ||
| /wt-data-gateway/ | ||
|
|
||
| # | ||
| wheels/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"cve_id":"CVE-2020-25459","work_dir":"/workspace/FATE","problem_statement":"Fix CVE-2020-25459 in FATE. sync_tree sends sensitive decision-tree information to hosts during federated training. Remove sensitive information before transfer while preserving training behavior.\nVulnerability Location\n[{\"file_path\":\"federatedml/tree/hetero/hetero_decision_tree_guest.py\",\"start_line\":532,\"end_line\":544}]"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"cve_id":"CVE-2020-26215","work_dir":"/workspace/notebook","problem_statement":"Fix CVE-2020-26215 in Jupyter Notebook. Trailing-slash redirects can interpret repeated leading slashes as a protocol-relative external URL. Preserve the query string and normalize the redirect to a local path.\nVulnerability Location\n[{\"file_path\":\"notebook/base/handlers.py\",\"start_line\":861,\"end_line\":863}]"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"cve_id":"CVE-2021-23376","work_dir":"/workspace/ffmpegdotjs","problem_statement":"Fix CVE-2021-23376 in ffmpegdotjs. Attacker-controlled arguments to trimvideo reach child_process.exec and permit OS command injection. Preserve normal video trimming behavior.\nVulnerability Location\n[{\"file_path\":\"index.js\",\"start_line\":216,\"end_line\":233}]"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"cve_id":"CVE-2022-1986","work_dir":"/workspace/gogs","problem_statement":"Fix CVE-2022-1986 in Gogs. Repository path validation is vulnerable to OS command injection because Git path detection is platform-separator dependent. Handle both slash styles safely.\nVulnerability Location\n[{\"file_path\":\"internal/db/repo_editor.go\",\"start_line\":468,\"end_line\":474}]"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"cve_id":"CVE-2024-25620","work_dir":"/workspace/helm","problem_statement":"Fix CVE-2024-25620 in Helm. A chart name containing relative path changes can cause a chart to be saved outside the expected directory. Validate chart metadata names without breaking valid charts.\nVulnerability Location\n[{\"file_path\":\"pkg/chart/metadata.go\",\"start_line\":87,\"end_line\":146}]"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| environments: | ||
| - env_name: patcheval_cve_2021_23376 | ||
| env_image: ghcr.io/anonymous2578-data/cve-2021-23376:latest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Pin PatchEval images to immutable versions. Using Also applies to: 11-11, 19-19, 27-27, 35-35 🤖 Prompt for AI Agents |
||
| env_num: 1 | ||
| dataset: ./datasets/cve-2021-23376.jsonl | ||
| dataset_load_mode: eager | ||
| env_params: | ||
| task_family: patcheval | ||
|
|
||
| - env_name: patcheval_cve_2020_25459 | ||
| env_image: ghcr.io/anonymous2578-data/cve-2020-25459:latest | ||
| env_num: 1 | ||
| dataset: ./datasets/cve-2020-25459.jsonl | ||
| dataset_load_mode: eager | ||
| env_params: | ||
| task_family: patcheval | ||
|
|
||
| - env_name: patcheval_cve_2022_1986 | ||
| env_image: ghcr.io/anonymous2578-data/cve-2022-1986:latest | ||
| env_num: 1 | ||
| dataset: ./datasets/cve-2022-1986.jsonl | ||
| dataset_load_mode: eager | ||
| env_params: | ||
| task_family: patcheval | ||
|
|
||
| - env_name: patcheval_cve_2024_25620 | ||
| env_image: ghcr.io/anonymous2578-data/cve-2024-25620:latest | ||
| env_num: 1 | ||
| dataset: ./datasets/cve-2024-25620.jsonl | ||
| dataset_load_mode: eager | ||
| env_params: | ||
| task_family: patcheval | ||
|
|
||
| - env_name: patcheval_cve_2020_26215 | ||
| env_image: ghcr.io/anonymous2578-data/cve-2020-26215:latest | ||
| env_num: 1 | ||
| dataset: ./datasets/cve-2020-26215.jsonl | ||
| dataset_load_mode: eager | ||
| env_params: | ||
| task_family: patcheval | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| agents: | ||
| patcheval_cve_2021_23376: &patcheval | ||
| container: | ||
| workdir: /workspace | ||
| runner_entrypoint: | ||
| source: ./runner.py | ||
| target: /tmp/safactory-patcheval-runner.py | ||
| command: "python /tmp/safactory-patcheval-runner.py" | ||
| install_runner_script: true | ||
| env: | ||
| PYTHONDONTWRITEBYTECODE: "1" | ||
| NO_PROXY: host.docker.internal,localhost,127.0.0.1,::1 | ||
| no_proxy: host.docker.internal,localhost,127.0.0.1,::1 | ||
| extra_args: | ||
| - --add-host=host.docker.internal:host-gateway | ||
| idle_command: "tail -f /dev/null" | ||
|
|
||
| patcheval_cve_2020_25459: *patcheval | ||
| patcheval_cve_2022_1986: *patcheval | ||
| patcheval_cve_2024_25620: *patcheval | ||
| patcheval_cve_2020_26215: *patcheval |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from evaluator.eval_types import EvalRequest, EvalResult, EvalSpec, EvalStatus, Trajectory | ||
|
|
||
|
|
||
| async def evaluate_rule( | ||
| *, | ||
| request: EvalRequest, | ||
| spec: EvalSpec, | ||
| trajectory: Trajectory, | ||
| ) -> EvalResult: | ||
| """Commit the runner's staged PatchEval score as a 0-10 reward.""" | ||
| metrics = _start_metrics(request) | ||
| score = _float_or_none(metrics.get("score")) | ||
| if score is None: | ||
| return EvalResult.failed( | ||
| session_id=request.session_id, | ||
| eval_id=spec.eval_id, | ||
| method=spec.method.value, | ||
| reason="patcheval metrics did not contain a numeric score", | ||
| artifacts={"bench": "patcheval", "metrics": metrics}, | ||
| ) | ||
|
|
||
| normalized_score = max(0.0, min(10.0, score)) | ||
| return EvalResult( | ||
| session_id=request.session_id, | ||
| eval_id=spec.eval_id, | ||
| method=spec.method.value, | ||
| status=EvalStatus.SUCCEEDED.value, | ||
| raw_score=float(score), | ||
| normalized_score_10=round(normalized_score, 6), | ||
| reason="patcheval staged reward: apply=1, PoC=7, strict=10", | ||
| artifacts={ | ||
| "bench": "patcheval", | ||
| "cve_id": metrics.get("cve_id"), | ||
| "strict_success": metrics.get("strict_success"), | ||
| "patch_applied": metrics.get("patch_applied"), | ||
| "poc_passed": metrics.get("poc_passed"), | ||
| "unit_tests_passed": metrics.get("unit_tests_passed"), | ||
| "failure_stage": metrics.get("failure_stage"), | ||
| "poc_log": metrics.get("poc_log"), | ||
| "unit_test_log": metrics.get("unit_test_log"), | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
| def _start_metrics(request: EvalRequest) -> dict[str, Any]: | ||
| start_result = getattr(request, "start_result", None) | ||
| metrics = getattr(start_result, "metrics", None) | ||
| return dict(metrics) if isinstance(metrics, dict) else {} | ||
|
|
||
|
|
||
| def _float_or_none(value: Any) -> float | None: | ||
| try: | ||
| if value is None: | ||
| return None | ||
| return float(value) | ||
| except (TypeError, ValueError): | ||
| return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Use the per-environment path before deciding whether to install.
The fallback at Lines 521-524 checks
self._runner_container_pathbefore this custom path is resolved. For a custom runner path withinstall_runner_scriptomitted, Lines 576-581 enable installation, but this helper returns early and never copies the runner. Resolverunner_container_pathbefore the fallback check, or pass the resolved install decision into this method.🤖 Prompt for AI Agents