feat(vectra): new Vectra AI NDR integration

Vectra Detect API v2.3, 8 commands: list/get detections, mark detection fixed,
add note, list/get hosts, list accounts. Token auth, stdlib-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guillaume BOURGEOIS
2026-07-12 00:48:01 +02:00
parent 0775500b15
commit 41e8aa8e7e
9 changed files with 565 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
id: vectra
name: Vectra AI
version: 1.0.0
description: "Vectra AI (Detect API v2.3) — network threat detection: list and read detections, mark a detection fixed, add a note, and list/read hosts and accounts. Token authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: list/get detections, mark detection fixed, add note, list/get hosts, list accounts."
category: ndr
# Per-instance configuration. Auth header 'Authorization: Token <api_token>'.
config_schema:
properties:
base_url:
type: string
description: "Vectra brain URL (e.g. https://vectra.example.com)"
api_token:
type: string
description: "Vectra 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_detections
name: vectra-list-detections
description: "List detections (optionally filtered)."
risk: read
inputs_schema:
properties:
state: { type: string, description: "Filter by state (active, inactive, fixed)" }
min_threat: { type: number, description: "Minimum threat score (optional)" }
page_size: { type: number, description: "Max detections (default 50)" }
required: []
outputs_schema: { properties: {} }
- id: get_detection
name: vectra-get-detection
description: "Get a single detection by ID."
risk: read
inputs_schema:
properties:
detection_id: { type: string, description: "Detection ID" }
required: [detection_id]
outputs_schema: { properties: {} }
- id: mark_detection_fixed
name: vectra-mark-detection-fixed
description: "Mark one or more detections as fixed."
inputs_schema:
properties:
detection_ids: { type: string, description: "Comma-separated detection IDs" }
required: [detection_ids]
outputs_schema: { properties: {} }
- id: add_detection_note
name: vectra-add-detection-note
description: "Add a note to a detection."
inputs_schema:
properties:
detection_id: { type: string, description: "Detection ID" }
note: { type: string, description: "Note text" }
required: [detection_id, note]
outputs_schema: { properties: {} }
- id: list_hosts
name: vectra-list-hosts
description: "List hosts (optionally filtered)."
risk: read
inputs_schema:
properties:
min_threat: { type: number, description: "Minimum threat score (optional)" }
page_size: { type: number, description: "Max hosts (default 50)" }
required: []
outputs_schema: { properties: {} }
- id: get_host
name: vectra-get-host
description: "Get a single host by ID."
risk: read
inputs_schema:
properties:
host_id: { type: string, description: "Host ID" }
required: [host_id]
outputs_schema: { properties: {} }
- id: list_accounts
name: vectra-list-accounts
description: "List accounts (optionally filtered)."
risk: read
inputs_schema:
properties:
page_size: { type: number, description: "Max accounts (default 50)" }
required: []
outputs_schema: { properties: {} }
- id: test_connection
name: vectra-test-connection
description: "Verify connectivity and the API token (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,60 @@
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/v2.3" + 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": "Token " + 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):
detection_id = inputs.get("detection_id")
note = inputs.get("note")
if not detection_id:
raise Exception("detection_id is required")
if not note:
raise Exception("note is required")
q = lambda v: urllib.parse.quote(str(v), safe="")
return request("POST", "/detections/" + q(detection_id) + "/notes", cfg, body={"note": note})
_run(main)
@@ -0,0 +1,57 @@
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/v2.3" + 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": "Token " + 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):
detection_id = inputs.get("detection_id")
if not detection_id:
raise Exception("detection_id is required")
q = lambda v: urllib.parse.quote(str(v), safe="")
return request("GET", "/detections/" + q(detection_id), cfg)
_run(main)
+57
View File
@@ -0,0 +1,57 @@
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/v2.3" + 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": "Token " + 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):
host_id = inputs.get("host_id")
if not host_id:
raise Exception("host_id is required")
q = lambda v: urllib.parse.quote(str(v), safe="")
return request("GET", "/hosts/" + q(host_id), cfg)
_run(main)
@@ -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/v2.3" + 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": "Token " + 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):
page_size = inputs.get("page_size")
return request("GET", "/accounts", cfg, params={"page_size": int(page_size or 50)})
_run(main)
@@ -0,0 +1,62 @@
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/v2.3" + 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": "Token " + 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):
state = inputs.get("state")
min_threat = inputs.get("min_threat")
page_size = inputs.get("page_size")
params = {"page_size": int(page_size or 50)}
if state:
params["state"] = state
if min_threat not in (None, ""):
params["threat_gte"] = int(min_threat)
return request("GET", "/detections", cfg, params=params)
_run(main)
+59
View File
@@ -0,0 +1,59 @@
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/v2.3" + 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": "Token " + 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):
min_threat = inputs.get("min_threat")
page_size = inputs.get("page_size")
params = {"page_size": int(page_size or 50)}
if min_threat not in (None, ""):
params["threat_gte"] = int(min_threat)
return request("GET", "/hosts", cfg, params=params)
_run(main)
@@ -0,0 +1,64 @@
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/v2.3" + 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": "Token " + 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):
detection_ids = inputs.get("detection_ids")
if not detection_ids:
raise Exception("detection_ids is required")
detection_ids_list = [s.strip() for s in str(detection_ids).split(",") if s.strip()]
if not detection_ids_list:
raise Exception("detection_ids is required")
body = {
"detectionIdList": [int(x) for x in detection_ids_list],
"mark_as_fixed": "True",
}
return request("PATCH", "/detections", cfg, body=body)
_run(main)
@@ -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/v2.3" + 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": "Token " + 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", "/detections", cfg, params={"page_size": 1})
return {"ok": True}
_run(main)