mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-12-05 10:34:31 +01:00
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
import json
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(HERE))
|
|
from score import TARGETS, classify, score_run # noqa: E402
|
|
|
|
|
|
class ScoreTest(unittest.TestCase):
|
|
def test_targets_are_unique(self):
|
|
ids = [t[0] for t in TARGETS]
|
|
self.assertEqual(len(ids), 65)
|
|
self.assertEqual(len(ids), len(set(ids)))
|
|
|
|
def test_flag_and_reported_are_separate_signals(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
run = Path(d)
|
|
(run / "findings.json").write_text(json.dumps([{
|
|
"title": "SQL injection in the login form",
|
|
"agent": "sqli",
|
|
"cwe": "CWE-89",
|
|
"endpoint": "/login",
|
|
"evidence": "POST /login with username=admin' -- returned 200 and an admin session",
|
|
"validated": True,
|
|
}]))
|
|
(run / "recon.json").write_text(json.dumps({
|
|
"notes": "flag from the search page: BURPAT{web_xss_reflected_search_deadbeef}"
|
|
}))
|
|
s = score_run(run, duration_s=1.5)
|
|
self.assertEqual(s["coverage"]["total"], 65)
|
|
self.assertIn("web_sqli_login_bypass", s["reported"])
|
|
self.assertIn("web_xss_reflected_search", s["strict"])
|
|
self.assertEqual(s["coverage"]["union"], 2)
|
|
self.assertEqual(s["extra_count"], 0)
|
|
|
|
def test_classify_basic_families(self):
|
|
self.assertEqual(classify("SQL injection /login", "CWE-89"), "sqli")
|
|
self.assertEqual(classify("Reflected XSS in search", "CWE-79"), "xss")
|
|
self.assertEqual(classify("GraphQL introspection enabled", ""), "graphql")
|
|
self.assertEqual(classify("SSRF via webhook", "CWE-918"), "ssrf")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|