Nav apraksta

handlers.py 802B

12345678910111213141516171819202122232425262728
  1. from datetime import datetime, timezone
  2. def health_check():
  3. return {"status": "ok", "timestamp": datetime.now(timezone.utc).isoformat()}, 200
  4. def echo_body(body):
  5. return {"received": body, "length": len(str(body))}, 200
  6. def lookup_ioc(value, ioc_type="auto"):
  7. normalized = value.strip().lower()
  8. verdict = "unknown"
  9. if "." in normalized and " " not in normalized:
  10. verdict = "domain-like"
  11. if normalized.count(".") == 3 and all(part.isdigit() for part in normalized.split(".")):
  12. verdict = "ipv4-like"
  13. if len(normalized) in {32, 40, 64} and all(c in "0123456789abcdef" for c in normalized):
  14. verdict = "hash-like"
  15. return {
  16. "input": value,
  17. "type": ioc_type,
  18. "verdict": verdict,
  19. "source": "demo-local",
  20. }, 200