import json, os, sys, urllib.error, urllib.request def _cfg(): return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) def main(): cfg = _cfg() base = str(cfg.get("base_url") or "").rstrip("/") if not base: raise Exception("base_url is not configured") req = urllib.request.Request( base + "/api/ingest/ping", headers={ "Accept": "application/json", "Authorization": "Bearer " + str(cfg.get("token") or ""), "User-Agent": "Riposte-SOAR/sextant", }, method="GET", ) with urllib.request.urlopen(req, timeout=30) as r: result = json.loads(r.read() or b"{}") # The probe deposits nothing and reads nothing back but an acknowledgement: # an ingestion token must not become a way to enumerate clients. if not result.get("ok"): raise Exception("unexpected response from Sextant") print(json.dumps({"ok": True})) try: main() except urllib.error.HTTPError as e: print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) sys.exit(1) except Exception as e: print(json.dumps({"error": str(e)})) sys.exit(1)