Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions eval/run_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,11 @@ def build_task(base, objective):


def parse_verdict(text):
if not text:
if not text or not text.strip():
return "NO_OUTPUT"
m = re.findall(r"VERDICT:\s*(VULNERABLE|NOT[_ ]?VULNERABLE|INCONCLUSIVE)", text, re.I)
if m:
return m[-1].upper().replace(" ", "_")
t = text[-500:].lower()
if re.search(r"\bnot\s+vulnerable\b|no\s+(?:xss|sqli|sql injection|vuln|redirect|ssrf|idor|cors)\b|not\s+exploitable", t):
return "NOT_VULNERABLE"
if re.search(r"\b(is\s+vulnerable|confirmed|exploitable|vulnerability\s+(?:exists|confirmed))\b", t):
return "VULNERABLE"
return "INCONCLUSIVE"
final_line = text.strip().splitlines()[-1]
match = re.fullmatch(r"VERDICT:[ \t]*(NOT_VULNERABLE|VULNERABLE)", final_line, re.I)
return match.group(1).upper() if match else "INCONCLUSIVE"


def do_case(case, base, cond, model, max_turns, timeout):
Expand Down
17 changes: 16 additions & 1 deletion eval/test_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import oracle_portswigger as ORACLE # noqa: E402
from run_fp import parse_verdict # noqa: E402


def check_configs():
Expand Down Expand Up @@ -73,6 +74,20 @@ def check_oracle():
return errs


def check_fp_verdicts():
cases = [
("", "NO_OUTPUT"),
(" \n ", "NO_OUTPUT"),
("No hypothesis was confirmed.", "INCONCLUSIVE"),
("Example: VERDICT: VULNERABLE\nNo result.", "INCONCLUSIVE"),
("VERDICT: VULNERABLE with caveats", "INCONCLUSIVE"),
("REASONING\nVERDICT: VULNERABLE\n", "VULNERABLE"),
("REASONING\nVERDICT: NOT_VULNERABLE", "NOT_VULNERABLE"),
]
return [f"fp verdict: expected {want!r} for {text!r}"
for text, want in cases if parse_verdict(text) != want]


def _free_port():
s = socket.socket()
s.bind(("127.0.0.1", 0))
Expand Down Expand Up @@ -127,7 +142,7 @@ def check_fp_app():


def main():
errs = check_configs() + check_oracle() + check_fp_app()
errs = check_configs() + check_oracle() + check_fp_app() + check_fp_verdicts()
for e in errs:
print(f"ERROR {e}")
if errs:
Expand Down