mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-04 18:58:18 +00:00
fix(hunt): lines read through a tool count as shown; an unparseable answer is an empty answer
The answer check counted only the rendered function text as shown, so 7 of 8 baseline suspicions citing lines the model had read with read_file were marked unknown (baseline 1/12 against the pilot hunter's 6/12). Tools now record the lines they return. A DSPy parse failure scores as zero findings with a flag instead of a broken run. The per-run response cache now takes effect through dspy.configure_cache. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c5bf52f47d
commit
602ec23e03
@@ -34,9 +34,11 @@ def _location_match(change: Mapping[str, Any], finding: Mapping[str, Any], toler
|
||||
|
||||
|
||||
def _on_diff(change: Mapping[str, Any], finding: Mapping[str, Any], tolerance: int) -> bool:
|
||||
return any(finding.get("path") == file["path"] and
|
||||
any(start - tolerance <= (finding.get("line", 0) or 0) <= end + tolerance
|
||||
for start, end in file.get("head_lines", [])) for file in change.get("files", []))
|
||||
return any(
|
||||
finding.get("path") == file["path"]
|
||||
and any(start - tolerance <= (finding.get("line", 0) or 0) <= end + tolerance for start, end in file.get("head_lines", []))
|
||||
for file in change.get("files", [])
|
||||
)
|
||||
|
||||
|
||||
def search_outcome(change: Mapping[str, Any], findings: Sequence[Mapping[str, Any]], *, tolerance: int = 10) -> Outcome:
|
||||
@@ -51,11 +53,11 @@ def search_outcome(change: Mapping[str, Any], findings: Sequence[Mapping[str, An
|
||||
on_diff = sum(_on_diff(change, finding, tolerance) for finding in findings)
|
||||
feedback = []
|
||||
if change["kind"] == "vulnerability" and not hit:
|
||||
span = change.get("function_lines") or [next((start for f in change.get("files", [])
|
||||
for start, _ in f.get("head_lines", [])), 0)]
|
||||
span = change.get("function_lines") or [next((start for f in change.get("files", []) for start, _ in f.get("head_lines", [])), 0)]
|
||||
feedback.append(f"missed {change.get('path', '')}:{span[0]} {change.get('function', '')} family {change.get('family', '')}")
|
||||
off_diff = [f"{f.get('path', '')}:{f.get('line', 0)} family {f.get('family', '')}"
|
||||
for f in findings if not _on_diff(change, f, tolerance)]
|
||||
off_diff = [
|
||||
f"{f.get('path', '')}:{f.get('line', 0)} family {f.get('family', '')}" for f in findings if not _on_diff(change, f, tolerance)
|
||||
]
|
||||
if off_diff:
|
||||
feedback.append("off-diff suspicions: " + ", ".join(off_diff))
|
||||
return Outcome(hit, len(findings), on_diff, "; ".join(feedback))
|
||||
|
||||
Reference in New Issue
Block a user