# Python でベンチマーク API を叩くサンプル
import requests
import json

BASE_URL = "http://localhost:9090/VulnerableApp"

# スキャナーの検出結果を模擬
payload = {
    "tool": "my-python-scanner",
    "scanType": "DAST",
    "findings": [
        {"url": f"{BASE_URL}/user", "type": "SQL_INJECTION", "cwe": "89"},
        {"url": f"{BASE_URL}/comment", "type": "XSS", "cwe": "79"},
        {"url": f"{BASE_URL}/file", "type": "PATH_TRAVERSAL", "cwe": "22"},
    ]
}

resp = requests.post(f"{BASE_URL}/scanner/benchmark", json=payload)
result = resp.json()

print(f"Tool: {result['tool']}")
print(f"Coverage: {result.get('coverage', 'N/A')}")
print(f"Detected: {result.get('detected', 0)} / {result.get('totalVulnerabilities', '?')}")

# 結果をファイルに保存
with open("benchmark_result.json", "w") as f:
    json.dump(result, f, indent=2)
print("Results saved to benchmark_result.json")