Compare commits

...

3 Commits

Author SHA1 Message Date
Guillaume BOURGEOIS 087b9abd19 feat(thinkst-canary): new Thinkst Canary deception integration
Canary Console API v1, 5 commands: list/get incidents, acknowledge incident,
list devices. Auth-token auth, stdlib-only. py_compile clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 21:53:59 +02:00
Guillaume BOURGEOIS e91febd319 feat(intune): new Microsoft Intune MDM integration
Microsoft Graph device management, 6 commands: list/get managed devices,
retire/wipe/remote-lock device (containment). OAuth2 client-credentials auth,
stdlib-only. py_compile clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 21:53:59 +02:00
Guillaume BOURGEOIS 374e4184ff feat(meraki): new Cisco Meraki network integration
Meraki Dashboard API v1, 5 commands: list organizations/networks/devices, list
network clients. API-key auth, stdlib-only. py_compile clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 21:53:58 +02:00
19 changed files with 1136 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
id: intune
name: Microsoft Intune
version: 1.0.0
description: "Microsoft Intune (Microsoft Graph device management) — endpoint containment: list and read managed devices, and retire, wipe, or remote-lock a device. Azure AD OAuth2 client-credentials authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: list/get managed devices, retire/wipe/remote-lock device."
category: endpoint
# Per-instance configuration. Application (client-credentials) OAuth2. The app
# registration needs Graph application permissions
# DeviceManagementManagedDevices.ReadWrite.All and .PrivilegedOperations.All.
config_schema:
properties:
tenant_id:
type: string
description: "Azure AD tenant ID"
client_id:
type: string
description: "App registration (client) ID"
client_secret:
type: string
description: "App registration client secret"
x-soar-sensitive: true
required:
- tenant_id
- client_id
- client_secret
commands:
- id: list_managed_devices
name: intune-list-managed-devices
description: "List Intune-managed devices (optionally filtered)."
risk: read
inputs_schema:
properties:
filter: { type: string, description: "OData $filter (e.g. userPrincipalName eq 'jdoe@corp.com')" }
limit: { type: number, description: "Max devices (default 50)" }
required: []
outputs_schema: { properties: {} }
- id: get_managed_device
name: intune-get-managed-device
description: "Get a single managed device by ID."
risk: read
inputs_schema:
properties:
device_id: { type: string, description: "Managed device ID" }
required: [device_id]
outputs_schema: { properties: {} }
- id: retire_device
name: intune-retire-device
description: "Retire a device (removes company data/management)."
inputs_schema:
properties:
device_id: { type: string, description: "Managed device ID" }
required: [device_id]
outputs_schema: { properties: {} }
- id: wipe_device
name: intune-wipe-device
description: "Wipe a device (factory reset — containment)."
inputs_schema:
properties:
device_id: { type: string, description: "Managed device ID" }
keep_enrollment_data: { type: boolean, description: "Keep enrollment data (default false)" }
required: [device_id]
outputs_schema: { properties: {} }
- id: remote_lock_device
name: intune-remote-lock-device
description: "Remotely lock a device."
inputs_schema:
properties:
device_id: { type: string, description: "Managed device ID" }
required: [device_id]
outputs_schema: { properties: {} }
- id: test_connection
name: intune-test-connection
description: "Verify the app credentials (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,68 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
GRAPH = "https://graph.microsoft.com/v1.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
url = "https://login.microsoftonline.com/" + str(cfg.get("tenant_id", "")) + "/oauth2/v2.0/token"
form = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"scope": "https://graph.microsoft.com/.default",
}).encode("utf-8")
req = urllib.request.Request(url, data=form, headers={"Content-Type": "application/x-www-form-urlencoded"}, 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 graph(method, path, token, body=None, params=None):
url = GRAPH + 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=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):
device_id = inputs.get("device_id")
if not device_id:
raise Exception("device_id is required")
q = lambda v: urllib.parse.quote(str(v), safe="")
return graph("GET", "/deviceManagement/managedDevices/" + q(device_id), token)
_run(main)
@@ -0,0 +1,67 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
GRAPH = "https://graph.microsoft.com/v1.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
url = "https://login.microsoftonline.com/" + str(cfg.get("tenant_id", "")) + "/oauth2/v2.0/token"
form = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"scope": "https://graph.microsoft.com/.default",
}).encode("utf-8")
req = urllib.request.Request(url, data=form, headers={"Content-Type": "application/x-www-form-urlencoded"}, 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 graph(method, path, token, body=None, params=None):
url = GRAPH + 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=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):
return graph("GET", "/deviceManagement/managedDevices", token, params={
"$filter": inputs.get("filter"),
"$top": int(inputs.get("limit") or 50),
})
_run(main)
@@ -0,0 +1,71 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
GRAPH = "https://graph.microsoft.com/v1.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
url = "https://login.microsoftonline.com/" + str(cfg.get("tenant_id", "")) + "/oauth2/v2.0/token"
form = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"scope": "https://graph.microsoft.com/.default",
}).encode("utf-8")
req = urllib.request.Request(url, data=form, headers={"Content-Type": "application/x-www-form-urlencoded"}, 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 graph(method, path, token, body=None, params=None):
url = GRAPH + 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=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):
device_id = inputs.get("device_id")
if not device_id:
raise Exception("device_id is required")
q = lambda v: urllib.parse.quote(str(v), safe="")
resp = graph("POST", "/deviceManagement/managedDevices/" + q(device_id) + "/remoteLock", token, body={})
if not resp:
return {"ok": True, "device_id": device_id, "action": "remoteLock"}
return resp
_run(main)
@@ -0,0 +1,71 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
GRAPH = "https://graph.microsoft.com/v1.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
url = "https://login.microsoftonline.com/" + str(cfg.get("tenant_id", "")) + "/oauth2/v2.0/token"
form = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"scope": "https://graph.microsoft.com/.default",
}).encode("utf-8")
req = urllib.request.Request(url, data=form, headers={"Content-Type": "application/x-www-form-urlencoded"}, 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 graph(method, path, token, body=None, params=None):
url = GRAPH + 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=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):
device_id = inputs.get("device_id")
if not device_id:
raise Exception("device_id is required")
q = lambda v: urllib.parse.quote(str(v), safe="")
resp = graph("POST", "/deviceManagement/managedDevices/" + q(device_id) + "/retire", token, body={})
if not resp:
return {"ok": True, "device_id": device_id, "action": "retire"}
return resp
_run(main)
@@ -0,0 +1,65 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
GRAPH = "https://graph.microsoft.com/v1.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
url = "https://login.microsoftonline.com/" + str(cfg.get("tenant_id", "")) + "/oauth2/v2.0/token"
form = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"scope": "https://graph.microsoft.com/.default",
}).encode("utf-8")
req = urllib.request.Request(url, data=form, headers={"Content-Type": "application/x-www-form-urlencoded"}, 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 graph(method, path, token, body=None, params=None):
url = GRAPH + 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=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):
graph("GET", "/deviceManagement/managedDevices", token, params={"$top": 1})
return {"ok": True}
_run(main)
@@ -0,0 +1,74 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
GRAPH = "https://graph.microsoft.com/v1.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def _token(cfg):
url = "https://login.microsoftonline.com/" + str(cfg.get("tenant_id", "")) + "/oauth2/v2.0/token"
form = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": str(cfg.get("client_id", "")),
"client_secret": str(cfg.get("client_secret", "")),
"scope": "https://graph.microsoft.com/.default",
}).encode("utf-8")
req = urllib.request.Request(url, data=form, headers={"Content-Type": "application/x-www-form-urlencoded"}, 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 graph(method, path, token, body=None, params=None):
url = GRAPH + 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=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):
device_id = inputs.get("device_id")
if not device_id:
raise Exception("device_id is required")
q = lambda v: urllib.parse.quote(str(v), safe="")
resp = graph("POST", "/deviceManagement/managedDevices/" + q(device_id) + "/wipe", token, body={
"keepEnrollmentData": bool(inputs.get("keep_enrollment_data")),
"keepUserData": False,
})
if not resp:
return {"ok": True, "device_id": device_id, "action": "wipe"}
return resp
_run(main)
+63
View File
@@ -0,0 +1,63 @@
id: meraki
name: Cisco Meraki
version: 1.0.0
description: "Cisco Meraki (Dashboard API v1) — network visibility: list organizations, networks and devices, and list clients on a network. API-key authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: list organizations/networks/devices, list network clients."
category: network
# Per-instance configuration. Auth header 'X-Cisco-Meraki-API-Key: <api_key>'.
config_schema:
properties:
api_key:
type: string
description: "Meraki Dashboard API key"
x-soar-sensitive: true
required:
- api_key
commands:
- id: list_organizations
name: meraki-list-organizations
description: "List organizations the API key can access."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
- id: list_networks
name: meraki-list-networks
description: "List networks in an organization."
risk: read
inputs_schema:
properties:
organization_id: { type: string, description: "Organization ID" }
required: [organization_id]
outputs_schema: { properties: {} }
- id: list_devices
name: meraki-list-devices
description: "List devices in an organization."
risk: read
inputs_schema:
properties:
organization_id: { type: string, description: "Organization ID" }
required: [organization_id]
outputs_schema: { properties: {} }
- id: list_clients
name: meraki-list-clients
description: "List clients seen on a network."
risk: read
inputs_schema:
properties:
network_id: { type: string, description: "Network ID" }
timespan: { type: number, description: "Look-back window in seconds (default 86400)" }
required: [network_id]
outputs_schema: { properties: {} }
- id: test_connection
name: meraki-test-connection
description: "Verify the API key (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,56 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.meraki.com/api/v1"
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, 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)
headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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):
network_id = inputs.get("network_id")
if not network_id:
raise Exception("network_id is required")
timespan = inputs.get("timespan")
response = request(
"GET",
"/networks/" + q(network_id) + "/clients",
cfg,
params={"timespan": int(timespan or 86400)},
)
return response
_run(main)
@@ -0,0 +1,50 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.meraki.com/api/v1"
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, 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)
headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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):
organization_id = inputs.get("organization_id")
if not organization_id:
raise Exception("organization_id is required")
response = request("GET", "/organizations/" + q(organization_id) + "/devices", cfg)
return response
_run(main)
@@ -0,0 +1,50 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.meraki.com/api/v1"
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, 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)
headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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):
organization_id = inputs.get("organization_id")
if not organization_id:
raise Exception("organization_id is required")
response = request("GET", "/organizations/" + q(organization_id) + "/networks", cfg)
return response
_run(main)
@@ -0,0 +1,43 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.meraki.com/api/v1"
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, 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)
headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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):
response = request("GET", "/organizations", cfg)
return response
_run(main)
@@ -0,0 +1,43 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.meraki.com/api/v1"
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, 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)
headers = {"X-Cisco-Meraki-API-Key": str(cfg.get("api_key", "")), "Accept": "application/json"}
req = urllib.request.Request(url, 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", "/organizations", cfg)
return {"ok": True}
_run(main)
+66
View File
@@ -0,0 +1,66 @@
id: thinkst_canary
name: Thinkst Canary
version: 1.0.0
description: "Thinkst Canary (Console API v1) — deception/honeypot alerting: list and read incidents, acknowledge an incident, and list Canary devices. API-token authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: list/get incidents, acknowledge incident, list devices."
category: endpoint
# Per-instance configuration. The auth token is sent as a request parameter; the
# console is reached at https://<domain>.canary.tools.
config_schema:
properties:
domain:
type: string
description: "Console subdomain (the X in https://X.canary.tools)"
auth_token:
type: string
description: "Console API auth token"
x-soar-sensitive: true
required:
- domain
- auth_token
commands:
- id: list_incidents
name: canary-list-incidents
description: "List all incidents (alerts)."
risk: read
inputs_schema:
properties:
limit: { type: number, description: "Max incidents (default 50)" }
required: []
outputs_schema: { properties: {} }
- id: get_incident
name: canary-get-incident
description: "Get a single incident by its ID/key."
risk: read
inputs_schema:
properties:
incident_id: { type: string, description: "Incident node/key ID" }
required: [incident_id]
outputs_schema: { properties: {} }
- id: acknowledge_incident
name: canary-acknowledge-incident
description: "Acknowledge an incident."
inputs_schema:
properties:
incident_id: { type: string, description: "Incident node/key ID" }
required: [incident_id]
outputs_schema: { properties: {} }
- id: list_devices
name: canary-list-devices
description: "List Canary devices."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
- id: test_connection
name: canary-test-connection
description: "Verify the auth token (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,55 @@
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 _base(cfg):
return "https://" + str(cfg.get("domain", "")) + ".canary.tools/api/v1"
def get(path, cfg, params=None):
p = {k: v for k, v in (params or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
url = _base(cfg) + path + "?" + urllib.parse.urlencode(p)
req = urllib.request.Request(url, headers={"Accept": "application/json"}, method="GET")
with urllib.request.urlopen(req, timeout=60) as r:
raw = r.read()
return json.loads(raw) if raw else {}
def post(path, cfg, fields=None):
p = {k: v for k, v in (fields or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
data = urllib.parse.urlencode(p).encode("utf-8")
req = urllib.request.Request(_base(cfg) + path, data=data,
headers={"Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json"}, method="POST")
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):
incident_id = inputs.get("incident_id")
if not incident_id:
raise Exception("incident_id is required")
return post("/incident/acknowledge", cfg, fields={"incident": incident_id})
_run(main)
@@ -0,0 +1,55 @@
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 _base(cfg):
return "https://" + str(cfg.get("domain", "")) + ".canary.tools/api/v1"
def get(path, cfg, params=None):
p = {k: v for k, v in (params or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
url = _base(cfg) + path + "?" + urllib.parse.urlencode(p)
req = urllib.request.Request(url, headers={"Accept": "application/json"}, method="GET")
with urllib.request.urlopen(req, timeout=60) as r:
raw = r.read()
return json.loads(raw) if raw else {}
def post(path, cfg, fields=None):
p = {k: v for k, v in (fields or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
data = urllib.parse.urlencode(p).encode("utf-8")
req = urllib.request.Request(_base(cfg) + path, data=data,
headers={"Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json"}, method="POST")
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):
incident_id = inputs.get("incident_id")
if not incident_id:
raise Exception("incident_id is required")
return get("/incident/fetch", cfg, params={"incident": incident_id})
_run(main)
@@ -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 _base(cfg):
return "https://" + str(cfg.get("domain", "")) + ".canary.tools/api/v1"
def get(path, cfg, params=None):
p = {k: v for k, v in (params or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
url = _base(cfg) + path + "?" + urllib.parse.urlencode(p)
req = urllib.request.Request(url, headers={"Accept": "application/json"}, method="GET")
with urllib.request.urlopen(req, timeout=60) as r:
raw = r.read()
return json.loads(raw) if raw else {}
def post(path, cfg, fields=None):
p = {k: v for k, v in (fields or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
data = urllib.parse.urlencode(p).encode("utf-8")
req = urllib.request.Request(_base(cfg) + path, data=data,
headers={"Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json"}, method="POST")
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):
return get("/devices/all", cfg)
_run(main)
@@ -0,0 +1,53 @@
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 _base(cfg):
return "https://" + str(cfg.get("domain", "")) + ".canary.tools/api/v1"
def get(path, cfg, params=None):
p = {k: v for k, v in (params or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
url = _base(cfg) + path + "?" + urllib.parse.urlencode(p)
req = urllib.request.Request(url, headers={"Accept": "application/json"}, method="GET")
with urllib.request.urlopen(req, timeout=60) as r:
raw = r.read()
return json.loads(raw) if raw else {}
def post(path, cfg, fields=None):
p = {k: v for k, v in (fields or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
data = urllib.parse.urlencode(p).encode("utf-8")
req = urllib.request.Request(_base(cfg) + path, data=data,
headers={"Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json"}, method="POST")
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") or 50
return get("/incidents/all", cfg, params={"limit": int(limit)})
_run(main)
@@ -0,0 +1,53 @@
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 _base(cfg):
return "https://" + str(cfg.get("domain", "")) + ".canary.tools/api/v1"
def get(path, cfg, params=None):
p = {k: v for k, v in (params or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
url = _base(cfg) + path + "?" + urllib.parse.urlencode(p)
req = urllib.request.Request(url, headers={"Accept": "application/json"}, method="GET")
with urllib.request.urlopen(req, timeout=60) as r:
raw = r.read()
return json.loads(raw) if raw else {}
def post(path, cfg, fields=None):
p = {k: v for k, v in (fields or {}).items() if v not in (None, "")}
p["auth_token"] = str(cfg.get("auth_token", ""))
data = urllib.parse.urlencode(p).encode("utf-8")
req = urllib.request.Request(_base(cfg) + path, data=data,
headers={"Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json"}, method="POST")
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):
get("/ping", cfg)
return {"ok": True}
_run(main)