From ac47315b309a17605299c0c2a3830fd908d394c6 Mon Sep 17 00:00:00 2001 From: Guillaume BOURGEOIS Date: Sun, 12 Jul 2026 21:37:31 +0200 Subject: [PATCH] feat(cybelangel): new CybelAngel attack-surface integration (French vendor) CybelAngel platform API, 4 commands: list/get reports, update report status. OAuth2 client-credentials auth, stdlib-only. py_compile clean. Co-Authored-By: Claude Opus 4.8 (1M context) --- integrations/cybelangel/manifest.yaml | 67 ++++++++++++++++ integrations/cybelangel/scripts/get_report.py | 74 +++++++++++++++++ .../cybelangel/scripts/list_reports.py | 69 ++++++++++++++++ .../cybelangel/scripts/test_connection.py | 69 ++++++++++++++++ .../scripts/update_report_status.py | 80 +++++++++++++++++++ 5 files changed, 359 insertions(+) create mode 100644 integrations/cybelangel/manifest.yaml create mode 100644 integrations/cybelangel/scripts/get_report.py create mode 100644 integrations/cybelangel/scripts/list_reports.py create mode 100644 integrations/cybelangel/scripts/test_connection.py create mode 100644 integrations/cybelangel/scripts/update_report_status.py diff --git a/integrations/cybelangel/manifest.yaml b/integrations/cybelangel/manifest.yaml new file mode 100644 index 0000000..6e6efbc --- /dev/null +++ b/integrations/cybelangel/manifest.yaml @@ -0,0 +1,67 @@ +id: cybelangel +name: CybelAngel +version: 1.0.0 +description: "CybelAngel (External Attack Surface / data-leak detection API) — read exposure reports: list reports, get a report, and update a report's status. OAuth2 client-credentials authentication; stdlib-only, no extra Python dependencies. (French vendor.)" +changelog: "1.0.0 — Initial release: list/get reports, update report status." +category: threat_intel + +# Per-instance configuration. Client credentials are exchanged for a bearer +# token at the auth endpoint; API calls go to the platform API. +config_schema: + properties: + auth_url: + type: string + description: "Token URL" + default: "https://auth.cybelangel.com/oauth/token" + api_url: + type: string + description: "Platform API URL" + default: "https://platform.cybelangel.com" + client_id: + type: string + description: "API client ID" + client_secret: + type: string + description: "API client secret" + x-soar-sensitive: true + required: + - client_id + - client_secret + +commands: + - id: list_reports + name: cybelangel-list-reports + description: "List exposure reports." + risk: read + inputs_schema: + properties: + status: { type: string, description: "Optional status filter (open, resolved, discarded)" } + required: [] + outputs_schema: { properties: {} } + - id: get_report + name: cybelangel-get-report + description: "Get a single report by ID." + risk: read + inputs_schema: + properties: + report_id: { type: string, description: "Report ID" } + required: [report_id] + outputs_schema: { properties: {} } + - id: update_report_status + name: cybelangel-update-report-status + description: "Update a report's status." + inputs_schema: + properties: + report_id: { type: string, description: "Report ID" } + status: { type: string, description: "New status (open, resolved, discarded)" } + required: [report_id, status] + outputs_schema: { properties: {} } + + - id: test_connection + name: cybelangel-test-connection + description: "Verify credentials via the token exchange (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/cybelangel/scripts/get_report.py b/integrations/cybelangel/scripts/get_report.py new file mode 100644 index 0000000..c5d3268 --- /dev/null +++ b/integrations/cybelangel/scripts/get_report.py @@ -0,0 +1,74 @@ +import json, os, sys, 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 _api(cfg): + return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2" + + +def _token(cfg): + auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token") + api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/" + body = json.dumps({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + "audience": api, + }).encode("utf-8") + req = urllib.request.Request(auth_url, data=body, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _api(cfg) + 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 = {"Authorization": "Bearer " + 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) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, 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) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, token, inputs): + report_id = inputs.get("report_id") + if not report_id: + raise Exception("report_id is required") + return request("GET", "/reports/" + q(report_id), cfg, token) + + +_run(main) diff --git a/integrations/cybelangel/scripts/list_reports.py b/integrations/cybelangel/scripts/list_reports.py new file mode 100644 index 0000000..01b4208 --- /dev/null +++ b/integrations/cybelangel/scripts/list_reports.py @@ -0,0 +1,69 @@ +import json, os, sys, 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 _api(cfg): + return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2" + + +def _token(cfg): + auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token") + api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/" + body = json.dumps({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + "audience": api, + }).encode("utf-8") + req = urllib.request.Request(auth_url, data=body, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _api(cfg) + 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 = {"Authorization": "Bearer " + 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) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, 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, token, inputs): + status = inputs.get("status") + return request("GET", "/reports", cfg, token, params={"status": status}) + + +_run(main) diff --git a/integrations/cybelangel/scripts/test_connection.py b/integrations/cybelangel/scripts/test_connection.py new file mode 100644 index 0000000..9ac5461 --- /dev/null +++ b/integrations/cybelangel/scripts/test_connection.py @@ -0,0 +1,69 @@ +import json, os, sys, 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 _api(cfg): + return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2" + + +def _token(cfg): + auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token") + api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/" + body = json.dumps({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + "audience": api, + }).encode("utf-8") + req = urllib.request.Request(auth_url, data=body, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _api(cfg) + 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 = {"Authorization": "Bearer " + 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) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, 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, token, inputs): + request("GET", "/reports", cfg, token, params={"limit": 1}) + return {"ok": True} + + +_run(main) diff --git a/integrations/cybelangel/scripts/update_report_status.py b/integrations/cybelangel/scripts/update_report_status.py new file mode 100644 index 0000000..a62a5d7 --- /dev/null +++ b/integrations/cybelangel/scripts/update_report_status.py @@ -0,0 +1,80 @@ +import json, os, sys, 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 _api(cfg): + return (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/api/v2" + + +def _token(cfg): + auth_url = str(cfg.get("auth_url") or "https://auth.cybelangel.com/oauth/token") + api = (str(cfg.get("api_url") or "https://platform.cybelangel.com")).rstrip("/") + "/" + body = json.dumps({ + "grant_type": "client_credentials", + "client_id": str(cfg.get("client_id", "")), + "client_secret": str(cfg.get("client_secret", "")), + "audience": api, + }).encode("utf-8") + req = urllib.request.Request(auth_url, data=body, + headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST") + with urllib.request.urlopen(req, timeout=60) as r: + tok = json.loads(r.read()) + if not tok.get("access_token"): + raise Exception("Token request failed: " + json.dumps(tok)) + return tok["access_token"] + + +def request(method, path, cfg, token, body=None, params=None): + url = _api(cfg) + 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 = {"Authorization": "Bearer " + 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) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + cfg = _cfg() + inputs = _inputs() + token = _token(cfg) + print(json.dumps(fn(cfg, token, 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) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, token, inputs): + report_id = inputs.get("report_id") + status = inputs.get("status") + if not report_id: + raise Exception("report_id is required") + if not status: + raise Exception("status is required") + resp = request("PUT", "/reports/" + q(report_id) + "/status", cfg, token, body={"status": status}) + if not resp: + return {"ok": True, "report_id": report_id, "status": status} + return resp + + +_run(main)