mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 18:28:19 +00:00
openultrasast.plane.memory and openultrasast.plane.budget are now
openultrasast.memory and openultrasast.budget; every importer follows. A pure move:
no behaviour changes. The two renames themselves were swept into 1aad435 by mistake
(they were staged when that spec commit was made), so the three commits between it
and this one do not import; this commit completes the move.
memory.py still reaches into the plane in two lazy imports (results_root in
open_store, the reconciler in seed); the cut of the plane has to settle both.
Checked: ruff, ruff format, mypy; 163 test files around memory, budget, plane, learn
and hunt passed across three runs by the implementing agent, and the six closest
files again before this commit. The whole suite was not run locally.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
51 lines
2.3 KiB
Python
51 lines
2.3 KiB
Python
"""The plane task `features` (learned-decision-engine task 1) on validation-46's recorded lmdeploy case
|
|
(``tests/fixtures/plane-remember``), and `remember` storing its records as `features` rows."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from openultrasast.memory import FileStore
|
|
from openultrasast.plane.tasks import features
|
|
from openultrasast.plane.tasks.remember import remember_run
|
|
|
|
FIXTURE = Path(__file__).parent / "fixtures" / "plane-remember" / "validation-46"
|
|
CASE = "lmdeploy-media-url-ssrf"
|
|
|
|
|
|
@pytest.fixture
|
|
def run_dir(tmp_path: Path) -> Path:
|
|
target = tmp_path / "plane" / "validation-46"
|
|
shutil.copytree(FIXTURE, target)
|
|
return target
|
|
|
|
|
|
def test_the_task_writes_records_and_remember_stores_them(run_dir: Path, tmp_path: Path) -> None:
|
|
out = tmp_path / "out"
|
|
env = {
|
|
"OUSAST_OUTPUT_DIR": str(out), "OUSAST_INPUT_FACTS": str(run_dir / f"{CASE}-facts" / "facts.json"),
|
|
"OUSAST_INPUT_AGREED": str(run_dir / f"{CASE}-final" / "agreed.json"),
|
|
**{f"OUSAST_INPUT_PASS_{p.upper()}": str(run_dir / f"{CASE}-v{p}" / "units.jsonl") for p in "abc"},
|
|
**{f"OUSAST_INPUT_SUMMARY_{p.upper()}": str(run_dir / f"{CASE}-v{p}" / "summary.json") for p in "abc"},
|
|
} # fmt: skip
|
|
assert features.main(env) == 0
|
|
summary = json.loads((out / "summary.json").read_text())
|
|
assert (summary["status"], summary["records"], summary["usd"], summary["calls"]) == ("done", 1, 0, 0)
|
|
assert summary["instruments"]["verify"] == {"ran": 1} and summary["instruments"]["quick"] == {"none": 1}
|
|
(run_dir / f"{CASE}-features").mkdir()
|
|
shutil.copy(out / features.OUTPUT, run_dir / f"{CASE}-features" / features.OUTPUT)
|
|
store = FileStore(tmp_path / "memory")
|
|
[result] = remember_run(run_dir, store, population="population-v2", split="validation")
|
|
assert result.kinds == {"facts": 1, "unit_cost": 2, "verdict": 1, "features": 1}
|
|
[row] = store.rows(kind="features")
|
|
assert row.row["candidate"] == "lmdeploy/vl/media/connection.py::_load_http_url" and row.row["family"] == "untrusted_destination"
|
|
assert row.row["repo"] == "example.com/reserved/lmdeploy" and row.row["x"]["agree.final"] == "agreed"
|
|
|
|
|
|
def test_the_task_fails_loudly_without_an_output_dir() -> None:
|
|
assert features.main({}) == 2
|