From 8a7e5a33a29cd2adecd82397d9b9cc2be01d1d9c Mon Sep 17 00:00:00 2001 From: Guillaume BOURGEOIS Date: Sun, 12 Jul 2026 16:12:37 +0200 Subject: [PATCH] feat(tehtris): new TEHTRIS XDR integration (French vendor) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TEHTRIS XDR, 5 commands: list/get alerts, list agents, isolate agent (containment). Bearer auth, stdlib-only. py_compile clean. NOTE: API paths best-effort — verify against vendor docs before production. Co-Authored-By: Claude Opus 4.8 (1M context) --- integrations/tehtris/manifest.yaml | 66 +++++++++++++++++++ integrations/tehtris/scripts/get_alert.py | 49 ++++++++++++++ integrations/tehtris/scripts/isolate_agent.py | 52 +++++++++++++++ integrations/tehtris/scripts/list_agents.py | 44 +++++++++++++ integrations/tehtris/scripts/list_alerts.py | 44 +++++++++++++ .../tehtris/scripts/test_connection.py | 44 +++++++++++++ 6 files changed, 299 insertions(+) create mode 100644 integrations/tehtris/manifest.yaml create mode 100644 integrations/tehtris/scripts/get_alert.py create mode 100644 integrations/tehtris/scripts/isolate_agent.py create mode 100644 integrations/tehtris/scripts/list_agents.py create mode 100644 integrations/tehtris/scripts/list_alerts.py create mode 100644 integrations/tehtris/scripts/test_connection.py diff --git a/integrations/tehtris/manifest.yaml b/integrations/tehtris/manifest.yaml new file mode 100644 index 0000000..a58cbb6 --- /dev/null +++ b/integrations/tehtris/manifest.yaml @@ -0,0 +1,66 @@ +id: tehtris +name: TEHTRIS XDR +version: 1.0.0 +description: "TEHTRIS XDR Platform — endpoint detection and response: list and read alerts, list agents, and isolate an agent (containment). Bearer-token authentication; stdlib-only, no extra Python dependencies. (French vendor. NOTE: exact API paths are best-effort — verify against the TEHTRIS API documentation before production use.)" +changelog: "1.0.0 — Initial release: list/get alerts, list agents, isolate agent." +category: endpoint + +# Per-instance configuration. Auth header 'Authorization: Bearer '. +config_schema: + properties: + base_url: + type: string + description: "TEHTRIS XDR API URL (tenant-specific)" + api_key: + type: string + description: "API key" + x-soar-sensitive: true + required: + - base_url + - api_key + +commands: + - id: list_alerts + name: tehtris-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: tehtris-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: list_agents + name: tehtris-list-agents + description: "List endpoint agents." + risk: read + inputs_schema: + properties: + limit: { type: number, description: "Max agents (default 50)" } + required: [] + outputs_schema: { properties: {} } + - id: isolate_agent + name: tehtris-isolate-agent + description: "Isolate an endpoint agent from the network (containment)." + inputs_schema: + properties: + agent_id: { type: string, description: "Agent ID" } + required: [agent_id] + outputs_schema: { properties: {} } + + - id: test_connection + name: tehtris-test-connection + description: "Verify the API key (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/tehtris/scripts/get_alert.py b/integrations/tehtris/scripts/get_alert.py new file mode 100644 index 0000000..fc48643 --- /dev/null +++ b/integrations/tehtris/scripts/get_alert.py @@ -0,0 +1,49 @@ +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 request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api" + 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 " + str(cfg.get("api_key", "")), "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: + 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) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, inputs): + alert_id = inputs.get("alert_id") + if not alert_id: + raise Exception("alert_id is required") + return request("GET", "/alerts/" + q(alert_id), cfg) + + +_run(main) diff --git a/integrations/tehtris/scripts/isolate_agent.py b/integrations/tehtris/scripts/isolate_agent.py new file mode 100644 index 0000000..c9291cd --- /dev/null +++ b/integrations/tehtris/scripts/isolate_agent.py @@ -0,0 +1,52 @@ +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 request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api" + 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 " + str(cfg.get("api_key", "")), "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: + 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) + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(cfg, inputs): + agent_id = inputs.get("agent_id") + if not agent_id: + raise Exception("agent_id is required") + result = request("POST", "/agents/" + q(agent_id) + "/isolate", cfg, body={}) + if not result: + return {"ok": True, "agent_id": agent_id, "action": "isolate"} + return result + + +_run(main) diff --git a/integrations/tehtris/scripts/list_agents.py b/integrations/tehtris/scripts/list_agents.py new file mode 100644 index 0000000..6967eb3 --- /dev/null +++ b/integrations/tehtris/scripts/list_agents.py @@ -0,0 +1,44 @@ +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 request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api" + 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 " + str(cfg.get("api_key", "")), "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: + 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", "/agents", cfg, params={"limit": int(limit or 50)}) + + +_run(main) diff --git a/integrations/tehtris/scripts/list_alerts.py b/integrations/tehtris/scripts/list_alerts.py new file mode 100644 index 0000000..4a0748c --- /dev/null +++ b/integrations/tehtris/scripts/list_alerts.py @@ -0,0 +1,44 @@ +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 request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api" + 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 " + str(cfg.get("api_key", "")), "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: + 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/tehtris/scripts/test_connection.py b/integrations/tehtris/scripts/test_connection.py new file mode 100644 index 0000000..dbd812b --- /dev/null +++ b/integrations/tehtris/scripts/test_connection.py @@ -0,0 +1,44 @@ +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 request(method, path, cfg, body=None, params=None): + url = str(cfg.get("base_url", "")).rstrip("/") + "/api" + 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 " + str(cfg.get("api_key", "")), "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: + 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)