17faa01103
Adds device/IOC/process enrichment, host groups, cases, RTR scripts/files/responders, ML/IOA exclusions, quarantine, Spotlight/CVE, ODS scans, CSPM, users, IOA rules, CNAPP, detection resolve, workflows, and identity (GraphQL). OAuth2 client-credentials, code-first scripts. Excludes XSOAR-only plumbing (fetch/mirroring), deprecated legacy commands, and binary/long-poll flows (retrieve-file, ngsiem search). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
2.6 KiB
Python
73 lines
2.6 KiB
Python
import json, os, sys, urllib.request, urllib.parse, urllib.error
|
|
|
|
SECRETS = json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
|
INPUTS = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
|
BASE = SECRETS.get("base_url", "https://api.crowdstrike.com").rstrip("/")
|
|
|
|
|
|
def token():
|
|
data = urllib.parse.urlencode({"client_id": SECRETS.get("client_id", ""), "client_secret": SECRETS.get("client_secret", "")}).encode()
|
|
req = urllib.request.Request(BASE + "/oauth2/token", data=data, headers={"Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json"}, method="POST")
|
|
with urllib.request.urlopen(req, timeout=30) as r:
|
|
return json.loads(r.read()).get("access_token", "")
|
|
|
|
|
|
def call(method, path, tok, params=None, body=None):
|
|
url = BASE + path
|
|
if params:
|
|
# params is a list of (key, value) tuples to allow repeated keys (e.g. ids)
|
|
url += "?" + urllib.parse.urlencode(params)
|
|
data = json.dumps(body).encode() if body is not None else None
|
|
headers = {"Authorization": "Bearer " + tok, "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 csv(v):
|
|
return [x.strip() for x in str(v or "").split(",") if x.strip()]
|
|
|
|
|
|
def main():
|
|
tok = token()
|
|
ids = INPUTS.get("ids", "")
|
|
update_status = INPUTS.get("update_status", "")
|
|
assign_to_uuid = INPUTS.get("assign_to_uuid", "")
|
|
append_comment = INPUTS.get("append_comment", "")
|
|
add_tag = INPUTS.get("add_tag", "")
|
|
remove_tag = INPUTS.get("remove_tag", "")
|
|
unassign = INPUTS.get("unassign", "")
|
|
show_in_ui = INPUTS.get("show_in_ui", "")
|
|
|
|
action_parameters = []
|
|
for name, value in [
|
|
("update_status", update_status),
|
|
("assign_to_uuid", assign_to_uuid),
|
|
("append_comment", append_comment),
|
|
("add_tag", add_tag),
|
|
("remove_tag", remove_tag),
|
|
("unassign", unassign),
|
|
("show_in_ui", show_in_ui),
|
|
]:
|
|
if value:
|
|
action_parameters.append({"name": name, "value": value})
|
|
|
|
result = call("PATCH", "/alerts/entities/alerts/v3", tok, body={
|
|
"action_parameters": action_parameters,
|
|
"composite_ids": csv(ids),
|
|
})
|
|
print(json.dumps(result))
|
|
|
|
|
|
try:
|
|
main()
|
|
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)
|