File size: 2,579 Bytes
1838600
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import asyncio
import httpx
import json
import sys

# LIVE TARGET
TARGET_URL = "https://avinashanalytics-sentinel-scam-honeypo.hf.space/api/guvi/analyze"

async def validate_live_deployment():
    print(f"πŸš€ STARTING LIVE VALIDATION: {TARGET_URL}")
    print("────────────────────────────────────────────────────────")
    
    payload = {
        "sessionId": "LIVE-AUDIT-001",
        "message": {
            "text": "Your bank account is locked. Click here to verify: http://bit.ly/scam",
            "sender": "scammer"
        },
        "metadata": {"source": "validator_script"}
    }
    
    headers = {
        "x-api-key": "GUVI_HACKATHON_V2", # Updated based on user input
        "Content-Type": "application/json"
    }
    
    try:
        async with httpx.AsyncClient(timeout=15.0) as client:
            start_time = asyncio.get_event_loop().time()
            resp = await client.post(TARGET_URL, json=payload, headers=headers)
            end_time = asyncio.get_event_loop().time()
            latency = (end_time - start_time) * 1000
            
            print(f"πŸ“‘ Status Code: {resp.status_code}")
            print(f"⏱️ Latency: {latency:.2f}ms")
            
            if resp.status_code == 200:
                data = resp.json()
                print(f"βœ… Response Body: {json.dumps(data, indent=2)}")
                
                # Compliance Checks
                failures = []
                if "scamDetected" not in data: failures.append("Missing 'scamDetected'")
                if "extractedIntelligence" not in data: failures.append("Missing 'extractedIntelligence'")
                if "engagementMetrics" not in data: failures.append("Missing 'engagementMetrics'")
                
                # Check CamelCase
                if "riskLevel" not in data and "risk_level" in data:
                    failures.append("Schema Violation: snake_case found instead of camelCase")
                
                if not failures:
                    print(f"\nπŸŽ‰ LIVE DEPLOYMENT IS COMPLIANT! (GUVI_HACKATHON_V2)")
                    print("Status: READY FOR JUDGES")
                else:
                    print(f"\n❌ COMPLIANCE FAILURES: {failures}")
            else:
                print(f"❌ API Request Failed: {resp.text}")
                
    except Exception as e:
        print(f"⚠️ Network/System Error: {e}")

if __name__ == "__main__":
    asyncio.run(validate_live_deployment())