mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 19:59:26 +00:00
fix(learning-harness): the three defects the group 2 review found
Task 2.3: two of the five unscorable reasons had no code path, so an unparsable row was reported as a corpus labelling defect when the true cause was a tooling gap. They have different owners and different fixes, and conflating them is the dishonesty this spec exists to remove. The design's unscorable_reason is reinstated with the parse result as an input, and a handler that arrived without its registration is now named as missing context for the families whose bug shape is a missing check. Task 2.6: a verification stamped its own word for proof onto the shared evidence level, which is not a value the project's ladder defines, and three existing helpers raised on it. Nothing in production called it yet, so the suite stayed green while the wiring in the next group would have broken a scan. A verification now writes only its tag, and a caller that wants to move a claim up the ladder goes through an explicit mapping that can only produce a level the ladder has. Task 2.7: the injection canary planted its row in a private in-memory database the target could never reach, so it could not fire; the fake sandbox handed the token back regardless of the snippet, which is why nothing noticed. It is now an execution canary whose marker only an interpreter could write, and each template is tested by running it for real against a vulnerable fixture and its fixed twin. That test immediately caught a second flaw: a handler that merely echoes its input printed the oracle token and satisfied the oracle without any vulnerability, so an injected payload now carries a value unrelated to the token the oracle looks for. Also from the review: a configuration with no tools is refused instead of producing a detector that silently reports nothing, the classifier abstains when its fallback call fails too, and the archive docstring says which version wins. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
This commit is contained in:
co-authored by
Claude Opus 5
parent
e44d45f488
commit
b0dba26468
@@ -103,13 +103,43 @@ def test_the_static_verifier_raises_an_access_control_claim_the_checker_agrees_w
|
||||
assert elsewhere.rung == "suspicion"
|
||||
|
||||
|
||||
def test_a_verification_can_be_written_onto_the_claim_as_a_tag(repo: Path) -> None:
|
||||
def test_a_verification_is_written_onto_the_claim_as_a_tag_and_nothing_else(repo: Path) -> None:
|
||||
"""The evidence ladder belongs to another boundary; a verifier says what it saw with a tag."""
|
||||
from openultrasast.learning.verifiers import apply_verification, verifier_for
|
||||
|
||||
taxonomy = load_families()
|
||||
claim = _claim("leaky", 12, "access_control")
|
||||
verified = apply_verification(claim, verifier_for(taxonomy.by_id("access_control")).verify(claim, root=repo, language="python"))
|
||||
assert "verifier:static_corroboration" in verified.tags
|
||||
assert verified.evidence_level == "static_corroboration" and claim.evidence_level == "suspicion"
|
||||
assert verified.evidence_level == "suspicion" and claim.evidence_level == "suspicion" # the ladder is untouched
|
||||
plain = apply_verification(claim, verifier_for(taxonomy.by_id("memory")).verify(claim, root=repo, language="python"))
|
||||
assert "verifier:suspicion" in plain.tags and plain.evidence_level == "suspicion"
|
||||
assert "verifier:suspicion" in plain.tags and plain.tags.count("verifier:suspicion") == 1
|
||||
|
||||
|
||||
def test_a_rung_only_reaches_the_ladder_through_an_explicit_mapping() -> None:
|
||||
"""Every rung must land on a level the project's ladder actually defines, or the report raises later."""
|
||||
from openultrasast.learning.verifiers import RUNGS, evidence_level_for
|
||||
from openultrasast.verification import EvidenceLevel
|
||||
|
||||
assert {rung: evidence_level_for(rung) for rung in RUNGS} == {
|
||||
"suspicion": EvidenceLevel.SUSPICION,
|
||||
"static_corroboration": EvidenceLevel.STATIC_CORROBORATION,
|
||||
"proven": EvidenceLevel.EXPLOIT_DEMONSTRATED,
|
||||
}
|
||||
assert all(EvidenceLevel(evidence_level_for(rung).value) for rung in RUNGS) # never a value outside the ladder
|
||||
|
||||
|
||||
def test_a_verified_claim_still_passes_the_projects_own_verification_helpers(repo: Path) -> None:
|
||||
"""The bug this pins: stamping a learning rung onto evidence_level raised ValueError in three call sites."""
|
||||
from openultrasast.learning.verifiers import Verification, apply_verification, raise_to
|
||||
from openultrasast.verification import VerificationStatus, is_report_verified, verify_finding
|
||||
|
||||
claim = _claim("lookup", 3, "injection")
|
||||
proven = apply_verification(claim, Verification(rung="proven", reason="oracle_fired", oracle_output="CANARY x"))
|
||||
assert "verifier:proven" in proven.tags
|
||||
assert verify_finding(proven).evidence_level == "suspicion" # would raise ValueError if the rung were stamped on
|
||||
assert is_report_verified(proven.evidence_level, VerificationStatus.ACCEPTED) is False
|
||||
raised = raise_to(proven, "proven")
|
||||
assert raised.evidence_level == "exploit_demonstrated"
|
||||
assert verify_finding(raised).evidence_level == "exploit_demonstrated"
|
||||
assert is_report_verified(raised.evidence_level, VerificationStatus.ACCEPTED) is True
|
||||
|
||||
Reference in New Issue
Block a user