feat(mandiant): new Mandiant Advantage threat-intel integration

Mandiant TI API v4, 8 commands: search/get indicator, get actor/malware/
vulnerability, list/get reports. Key+secret OAuth2 token exchange, 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:15:12 +02:00
parent a5db725529
commit 796a95d5f8
9 changed files with 644 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
id: mandiant
name: Mandiant Advantage
version: 1.0.0
description: "Mandiant Advantage Threat Intelligence (API v4) — threat intelligence: look up indicators, threat actors, malware families, and vulnerabilities, and list/read intelligence reports. Key + secret authentication (OAuth2 token exchange); stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: search/get indicator, get actor/malware/vulnerability, list/get reports."
category: threat_intel
# Per-instance configuration. The key + secret are exchanged (HTTP Basic against
# /token) for a bearer token used on the v4 API.
config_schema:
properties:
api_key:
type: string
description: "Mandiant API key (public key)"
secret_key:
type: string
description: "Mandiant secret key"
x-soar-sensitive: true
required:
- api_key
- secret_key
commands:
- id: search_indicator
name: mandiant-search-indicator
description: "Look up threat intelligence for an indicator value (IP, domain, URL, or hash)."
risk: read
inputs_schema:
properties:
value: { type: string, description: "Indicator value" }
required: [value]
outputs_schema: { properties: {} }
- id: get_indicator
name: mandiant-get-indicator
description: "Get a single indicator by its Mandiant ID."
risk: read
inputs_schema:
properties:
indicator_id: { type: string, description: "Mandiant indicator ID" }
required: [indicator_id]
outputs_schema: { properties: {} }
- id: get_actor
name: mandiant-get-actor
description: "Get a threat actor by ID or name."
risk: read
inputs_schema:
properties:
actor_id: { type: string, description: "Threat actor ID or name" }
required: [actor_id]
outputs_schema: { properties: {} }
- id: get_malware
name: mandiant-get-malware
description: "Get a malware family by ID or name."
risk: read
inputs_schema:
properties:
malware_id: { type: string, description: "Malware family ID or name" }
required: [malware_id]
outputs_schema: { properties: {} }
- id: get_vulnerability
name: mandiant-get-vulnerability
description: "Get vulnerability intelligence by CVE ID."
risk: read
inputs_schema:
properties:
cve_id: { type: string, description: "CVE ID (e.g. CVE-2024-1234)" }
required: [cve_id]
outputs_schema: { properties: {} }
- id: list_reports
name: mandiant-list-reports
description: "List intelligence reports."
risk: read
inputs_schema:
properties:
limit: { type: number, description: "Max reports (default 25)" }
required: []
outputs_schema: { properties: {} }
- id: get_report
name: mandiant-get-report
description: "Get a single intelligence report by ID."
risk: read
inputs_schema:
properties:
report_id: { type: string, description: "Report ID" }
required: [report_id]
outputs_schema: { properties: {} }
- id: test_connection
name: mandiant-test-connection
description: "Verify connectivity and the token exchange (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,70 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
actor_id = inputs.get("actor_id")
if not actor_id:
raise Exception("actor_id is required")
return request("GET", "/v4/actor/" + q(actor_id), token)
_run(main)
@@ -0,0 +1,70 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
indicator_id = inputs.get("indicator_id")
if not indicator_id:
raise Exception("indicator_id is required")
return request("GET", "/v4/indicator/" + q(indicator_id), token)
_run(main)
@@ -0,0 +1,70 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
malware_id = inputs.get("malware_id")
if not malware_id:
raise Exception("malware_id is required")
return request("GET", "/v4/malware/" + q(malware_id), token)
_run(main)
@@ -0,0 +1,70 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
report_id = inputs.get("report_id")
if not report_id:
raise Exception("report_id is required")
return request("GET", "/v4/report/" + q(report_id), token)
_run(main)
@@ -0,0 +1,70 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
cve_id = inputs.get("cve_id")
if not cve_id:
raise Exception("cve_id is required")
return request("GET", "/v4/vulnerability/" + q(cve_id), token)
_run(main)
@@ -0,0 +1,66 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
limit = inputs.get("limit")
limit = int(limit) if limit not in (None, "") else 25
return request("GET", "/v4/reports", token, params={"limit": limit})
_run(main)
@@ -0,0 +1,68 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
value = inputs.get("value")
if not value:
raise Exception("value is required")
body = {"requests": [{"values": [value]}]}
return request("POST", "/v4/indicator", token, body=body)
_run(main)
@@ -0,0 +1,65 @@
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
BASE = "https://api.intelligence.mandiant.com"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
creds = str(cfg.get("api_key", "")) + ":" + str(cfg.get("secret_key", ""))
basic = base64.b64encode(creds.encode("utf-8")).decode("utf-8")
form = urllib.parse.urlencode({"grant_type": "client_credentials"}).encode("utf-8")
req = urllib.request.Request(BASE + "/token", data=form, headers={
"Authorization": "Basic " + basic,
"Content-Type": "application/x-www-form-urlencoded",
"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, token, body=None, params=None):
url = BASE + 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", "X-App-Name": "riposte-soar"}
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=90) 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(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(token, inputs):
request("GET", "/v4/reports", token, params={"limit": 1})
return {"ok": True}
_run(main)