mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-18 12:39:28 +00:00
chore: format the whole tree and lint the scratch measurement scripts; CI has been red since 25ae4b4
CI runs ruff format --check and ruff check over the whole repository; 29 files had drifted from the formatter and
four measurement scripts carried lint findings, so every push since 25ae4b4 failed before pytest ran.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
fbbc03f3ea
commit
0d7d3f0dc9
+18
-12
@@ -8,11 +8,14 @@ from benchmarks.unseen.score import catches
|
||||
from openultrasast.hunt.metric import search_metric, search_outcome
|
||||
|
||||
|
||||
@pytest.mark.parametrize("change", [
|
||||
{"family": "injection", "path": "app.py", "function": "handler", "function_lines": [100, 140]},
|
||||
{"family": "path", "path": "other.py", "function": "read", "function_lines": [100, 140]},
|
||||
{"family": "config_secrets", "path": "app.py", "function": "handler", "function_lines": [100, 140]},
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"change",
|
||||
[
|
||||
{"family": "injection", "path": "app.py", "function": "handler", "function_lines": [100, 140]},
|
||||
{"family": "path", "path": "other.py", "function": "read", "function_lines": [100, 140]},
|
||||
{"family": "config_secrets", "path": "app.py", "function": "handler", "function_lines": [100, 140]},
|
||||
],
|
||||
)
|
||||
def test_matches_score_catches(change):
|
||||
change = {**change, "kind": "vulnerability", "files": [{"path": "app.py", "head_lines": [[20, 22]]}]}
|
||||
for path in ("app.py", "other.py"):
|
||||
@@ -20,17 +23,20 @@ def test_matches_score_catches(change):
|
||||
for function in ("handler", "other"):
|
||||
for family in (change["family"], "unknown"):
|
||||
finding = {"path": path, "line": line, "function": function, "family": family}
|
||||
record = {**change, "push": {"admission": {"defects": [
|
||||
{**finding, "locations": [[path, line]]}
|
||||
]}}}
|
||||
record = {**change, "push": {"admission": {"defects": [{**finding, "locations": [[path, line]]}]}}}
|
||||
assert search_outcome(change, [finding]).hit == bool(catches(record))
|
||||
|
||||
|
||||
def test_counts_scope_feedback_and_tolerance():
|
||||
change = {"kind": "vulnerability", "path": "app.py", "function": "handle", "family": "path",
|
||||
"function_lines": [20, 22], "files": [{"path": "app.py", "head_lines": [[20, 22]]}]}
|
||||
findings = [{"path": "app.py", "line": 10, "family": "path"},
|
||||
{"path": "other.py", "line": 30, "family": "path"}]
|
||||
change = {
|
||||
"kind": "vulnerability",
|
||||
"path": "app.py",
|
||||
"function": "handle",
|
||||
"family": "path",
|
||||
"function_lines": [20, 22],
|
||||
"files": [{"path": "app.py", "head_lines": [[20, 22]]}],
|
||||
}
|
||||
findings = [{"path": "app.py", "line": 10, "family": "path"}, {"path": "other.py", "line": 30, "family": "path"}]
|
||||
outcome = search_outcome(change, findings)
|
||||
assert (outcome.hit, outcome.suspicions, outcome.on_diff) == (True, 2, 1)
|
||||
assert "other.py:30" in outcome.feedback
|
||||
|
||||
Reference in New Issue
Block a user