avinash-rai commited on
Commit
bee2ada
·
1 Parent(s): 4378f28

🚀 FINAL COMPLIANCE: Added callback authentication, expanded intelligence mapping, and centralized GUVI_API_KEY

Browse files
app/config.py CHANGED
@@ -12,6 +12,7 @@ class Settings(BaseSettings):
12
  APP_NAME: str = "Scam Honeypot API"
13
  VERSION: str = "2.0.0"
14
  DEBUG: bool = False
 
15
 
16
  # LLM Configuration
17
  LLM_PROVIDER: str = "groq"
 
12
  APP_NAME: str = "Scam Honeypot API"
13
  VERSION: str = "2.0.0"
14
  DEBUG: bool = False
15
+ GUVI_API_KEY: str = "GUVI_HACKATHON_V2"
16
 
17
  # LLM Configuration
18
  LLM_PROVIDER: str = "groq"
app/utils/callback_client.py CHANGED
@@ -5,6 +5,8 @@ from typing import Dict, List
5
  from tenacity import retry, stop_after_attempt, wait_exponential
6
  from app.utils.logger import AgentLogger
7
 
 
 
8
  logger = AgentLogger("callback_client")
9
  GUVI_CALLBACK_URL = "https://hackathon.guvi.in/api/updateHoneyPotFinalResult"
10
 
@@ -53,14 +55,24 @@ class GUVIMandatoryCallback:
53
  response = await client.post(
54
  GUVI_CALLBACK_URL,
55
  json=payload,
56
- headers={"Content-Type": "application/json"}
 
 
 
57
  )
58
 
59
  if response.status_code in [200, 201]:
60
  logger.info("GUVI callback successful", session_id=session_id)
61
  return True
62
  else:
63
- logger.error("GUVI callback failed", status=response.status_code, session_id=session_id)
 
 
 
 
 
 
 
64
  return False
65
 
66
  except Exception as e:
 
5
  from tenacity import retry, stop_after_attempt, wait_exponential
6
  from app.utils.logger import AgentLogger
7
 
8
+ from app.config import settings
9
+
10
  logger = AgentLogger("callback_client")
11
  GUVI_CALLBACK_URL = "https://hackathon.guvi.in/api/updateHoneyPotFinalResult"
12
 
 
55
  response = await client.post(
56
  GUVI_CALLBACK_URL,
57
  json=payload,
58
+ headers={
59
+ "Content-Type": "application/json",
60
+ "x-api-key": settings.GUVI_API_KEY
61
+ }
62
  )
63
 
64
  if response.status_code in [200, 201]:
65
  logger.info("GUVI callback successful", session_id=session_id)
66
  return True
67
  else:
68
+ try:
69
+ resp_body = response.json()
70
+ except:
71
+ resp_body = response.text
72
+ logger.error("GUVI callback failed",
73
+ status=response.status_code,
74
+ session_id=session_id,
75
+ response=resp_body)
76
  return False
77
 
78
  except Exception as e:
app/utils/guvi_handler.py CHANGED
@@ -16,6 +16,11 @@ class GUVIHandler:
16
  "upiIds": internal_intel.get("upi_ids", []),
17
  "phishingLinks": internal_intel.get("urls", []),
18
  "phoneNumbers": internal_intel.get("phone_numbers", []),
 
 
 
 
 
19
  "suspiciousKeywords": internal_intel.get("keywords", [])
20
  }
21
 
 
16
  "upiIds": internal_intel.get("upi_ids", []),
17
  "phishingLinks": internal_intel.get("urls", []),
18
  "phoneNumbers": internal_intel.get("phone_numbers", []),
19
+ "ifscCodes": internal_intel.get("ifsc_codes", []),
20
+ "emailAddresses": internal_intel.get("emails", []),
21
+ "panCards": internal_intel.get("pan_cards", []),
22
+ "aadharNumbers": internal_intel.get("aadhar_numbers", []),
23
+ "amountsExtracted": internal_intel.get("amounts", []),
24
  "suspiciousKeywords": internal_intel.get("keywords", [])
25
  }
26
 
reproduce_guvi_call.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import httpx
3
+ import asyncio
4
+ import json
5
+
6
+ async def test_guvi_api():
7
+ url = "https://avinashanalytics-sentinel-scam-honeypo.hf.space/api/guvi/analyze"
8
+ headers = {
9
+ "x-api-key": "GUVI_HACKATHON_V2",
10
+ "Content-Type": "application/json"
11
+ }
12
+
13
+ # 1. First Message
14
+ payload1 = {
15
+ "sessionId": "local-repro-123",
16
+ "message": {
17
+ "sender": "scammer",
18
+ "text": "Hello, your bank account is suspended. Update KYC at http://fake.com",
19
+ "timestamp": "2026-01-28T10:15:30Z"
20
+ },
21
+ "conversationHistory": [],
22
+ "metadata": {"channel": "SMS"}
23
+ }
24
+
25
+ print("\n[Test 1] Sending First Message...")
26
+ async with httpx.AsyncClient(timeout=30.0) as client:
27
+ try:
28
+ resp1 = await client.post(url, json=payload1, headers=headers)
29
+ print(f"Status: {resp1.status_code}")
30
+ print(f"Response: {json.dumps(resp1.json(), indent=2)}")
31
+
32
+ if resp1.status_code != 200:
33
+ return
34
+
35
+ # 2. Second Message (Follow-up)
36
+ payload2 = {
37
+ "sessionId": "local-repro-123",
38
+ "message": {
39
+ "sender": "scammer",
40
+ "text": "Please provide your UPI ID to verify.",
41
+ "timestamp": "2026-01-28T10:17:10Z"
42
+ },
43
+ "conversationHistory": [
44
+ {
45
+ "sender": "scammer",
46
+ "text": "Hello, your bank account is suspended. Update KYC at http://fake.com",
47
+ "timestamp": "2026-01-28T10:15:30Z"
48
+ },
49
+ {
50
+ "sender": "user",
51
+ "text": "Why is it suspended?",
52
+ "timestamp": "2026-01-28T10:16:10Z"
53
+ }
54
+ ],
55
+ "metadata": {"channel": "SMS"}
56
+ }
57
+
58
+ print("\n[Test 2] Sending Second Message (with History)...")
59
+ resp2 = await client.post(url, json=payload2, headers=headers)
60
+ print(f"Status: {resp2.status_code}")
61
+ print(f"Response: {json.dumps(resp2.json(), indent=2)}")
62
+
63
+ except Exception as e:
64
+ print(f"Error: {e}")
65
+
66
+ if __name__ == "__main__":
67
+ # Ensure server is running before executing this
68
+ # uvicorn app.main:app --host 0.0.0.0 --port 8000
69
+ asyncio.run(test_guvi_api())