MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / SecurityTester

Class SecurityTester

tests/security/test_api_vulnerabilities.py:32–73  ·  view source on GitHub ↗

Base class for security testing

Source from the content-addressed store, hash-verified

30
31
32class SecurityTester:
33 """Base class for security testing"""
34
35 def __init__(self, host="127.0.0.1", port=7777):
36 self.host = host
37 self.port = port
38 self.vulnerabilities = []
39
40 def log_vulnerability(self, severity, category, description, payload=None):
41 """Log a discovered vulnerability"""
42 vuln = {
43 "severity": severity, # CRITICAL, HIGH, MEDIUM, LOW, INFO
44 "category": category,
45 "description": description,
46 "payload": payload,
47 }
48 self.vulnerabilities.append(vuln)
49 print(f"[{severity}] {category}: {description}")
50 if payload:
51 print(f" Payload: {repr(payload)[:200]}")
52
53 def report(self):
54 """Generate vulnerability report"""
55 print("\n" + "=" * 80)
56 print("SECURITY TEST REPORT")
57 print("=" * 80)
58 print(f"Total issues found: {len(self.vulnerabilities)}")
59
60 by_severity = {}
61 for vuln in self.vulnerabilities:
62 sev = vuln["severity"]
63 by_severity[sev] = by_severity.get(sev, 0) + 1
64
65 for severity in ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]:
66 count = by_severity.get(severity, 0)
67 if count > 0:
68 print(f" {severity}: {count}")
69
70 print("\nDetailed findings:")
71 for i, vuln in enumerate(self.vulnerabilities, 1):
72 print(f"\n{i}. [{vuln['severity']}] {vuln['category']}")
73 print(f" {vuln['description']}")
74
75
76def test_json_parsing_exploits(tester):

Callers 2

testerFunction · 0.90
mainFunction · 0.85

Calls

no outgoing calls

Tested by 2

testerFunction · 0.72
mainFunction · 0.68