diff --git a/integrations/gatewatcher/manifest.yaml b/integrations/gatewatcher/manifest.yaml new file mode 100644 index 0000000..818b414 --- /dev/null +++ b/integrations/gatewatcher/manifest.yaml @@ -0,0 +1,63 @@ +id: gatewatcher +name: Gatewatcher AionIQ +version: 1.0.0 +description: "Gatewatcher AionIQ (NDR) — network detection: list and read alerts and run an alert search. API-token authentication; stdlib-only, no extra Python dependencies. (French vendor. NOTE: exact API paths are best-effort — verify against the Gatewatcher API documentation before production use.)" +changelog: "1.0.0 — Initial release: list/get alerts, search alerts." +category: ndr + +# Per-instance configuration. Auth header 'API-KEY: '. +config_schema: + properties: + base_url: + type: string + description: "AionIQ URL (e.g. https://aioniq.example.com)" + api_token: + type: string + description: "API token" + x-soar-sensitive: true + insecure: + type: boolean + description: "Trust any TLS certificate (not secure)" + default: false + required: + - base_url + - api_token + +commands: + - id: list_alerts + name: gatewatcher-list-alerts + description: "List alerts." + risk: read + inputs_schema: + properties: + limit: { type: number, description: "Max alerts (default 50)" } + required: [] + outputs_schema: { properties: {} } + - id: get_alert + name: gatewatcher-get-alert + description: "Get a single alert by ID." + risk: read + inputs_schema: + properties: + alert_id: { type: string, description: "Alert ID" } + required: [alert_id] + outputs_schema: { properties: {} } + - id: search_alerts + name: gatewatcher-search-alerts + description: "Search alerts with a query." + risk: read + inputs_schema: + properties: + query: { type: string, description: "Search query (e.g. a source IP or signature)" } + limit: { type: number, description: "Max results (default 50)" } + required: [query] + outputs_schema: { properties: {} } + + - id: test_connection + name: gatewatcher-test-connection + description: "Verify the API token (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/gatewatcher/scripts/get_alert.py b/integrations/gatewatcher/scripts/get_alert.py new file mode 100644 index 0000000..5882d75 --- /dev/null +++ b/integrations/gatewatcher/scripts/get_alert.py @@ -0,0 +1,56 @@ +import json, os, sys, ssl, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _ctx(cfg): + if cfg.get("insecure"): + c = ssl.create_default_context() + c.check_hostname = False + c.verify_mode = ssl.CERT_NONE + return c + return None + + +def request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api/v1" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"API-KEY": str(cfg.get("api_token", "")), "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + 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) + + +def main(cfg, inputs): + alert_id = inputs.get("alert_id") + if not alert_id: + raise Exception("alert_id is required") + q = lambda v: urllib.parse.quote(str(v), safe="") + return request("GET", "/alerts/" + q(alert_id), cfg) + + +_run(main) diff --git a/integrations/gatewatcher/scripts/list_alerts.py b/integrations/gatewatcher/scripts/list_alerts.py new file mode 100644 index 0000000..5bdab68 --- /dev/null +++ b/integrations/gatewatcher/scripts/list_alerts.py @@ -0,0 +1,53 @@ +import json, os, sys, ssl, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _ctx(cfg): + if cfg.get("insecure"): + c = ssl.create_default_context() + c.check_hostname = False + c.verify_mode = ssl.CERT_NONE + return c + return None + + +def request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api/v1" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"API-KEY": str(cfg.get("api_token", "")), "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + 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) + + +def main(cfg, inputs): + limit = inputs.get("limit") + return request("GET", "/alerts", cfg, params={"limit": int(limit or 50)}) + + +_run(main) diff --git a/integrations/gatewatcher/scripts/search_alerts.py b/integrations/gatewatcher/scripts/search_alerts.py new file mode 100644 index 0000000..acd9c72 --- /dev/null +++ b/integrations/gatewatcher/scripts/search_alerts.py @@ -0,0 +1,56 @@ +import json, os, sys, ssl, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _ctx(cfg): + if cfg.get("insecure"): + c = ssl.create_default_context() + c.check_hostname = False + c.verify_mode = ssl.CERT_NONE + return c + return None + + +def request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api/v1" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"API-KEY": str(cfg.get("api_token", "")), "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + 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) + + +def main(cfg, inputs): + query = inputs.get("query") + if not query: + raise Exception("query is required") + limit = inputs.get("limit") + return request("POST", "/alerts/search", cfg, body={"query": query, "size": int(limit or 50)}) + + +_run(main) diff --git a/integrations/gatewatcher/scripts/test_connection.py b/integrations/gatewatcher/scripts/test_connection.py new file mode 100644 index 0000000..916b081 --- /dev/null +++ b/integrations/gatewatcher/scripts/test_connection.py @@ -0,0 +1,53 @@ +import json, os, sys, ssl, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _ctx(cfg): + if cfg.get("insecure"): + c = ssl.create_default_context() + c.check_hostname = False + c.verify_mode = ssl.CERT_NONE + return c + return None + + +def request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api/v1" + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + data = json.dumps(body).encode("utf-8") if body is not None else None + headers = {"API-KEY": str(cfg.get("api_token", "")), "Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/json" + req = urllib.request.Request(url, data=data, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + 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) + + +def main(cfg, inputs): + request("GET", "/alerts", cfg, params={"limit": 1}) + return {"ok": True} + + +_run(main)