Compare commits
3 Commits
6cc0bb61bc
...
aca1db5cad
| Author | SHA1 | Date | |
|---|---|---|---|
| aca1db5cad | |||
| d0d72c5171 | |||
| fd64c245f4 |
@@ -0,0 +1,76 @@
|
||||
id: chronicle
|
||||
name: Google Chronicle
|
||||
version: 1.0.0
|
||||
description: "Google Chronicle (Backstory API) — SIEM threat context: list IOCs seen in the enterprise, list alerts, list assets, and get IOC details for an artifact. Authenticates with a Google service account (RS256 JWT bearer flow). Runs on a remote engine. Requires the Python 'PyJWT' and 'cryptography' libraries on the engine host (pip install pyjwt cryptography)."
|
||||
changelog: "1.0.0 — Initial release: list IOCs, list alerts, list assets, get IOC details."
|
||||
category: siem
|
||||
|
||||
# Per-instance configuration. The scripts build a signed RS256 assertion from the
|
||||
# service account's private_key/client_email and exchange it for an access token
|
||||
# (scope chronicle-backstory). base_url is the regional Chronicle API host.
|
||||
config_schema:
|
||||
properties:
|
||||
service_account_json:
|
||||
type: string
|
||||
description: "Full Chronicle service account key JSON (must contain client_email and private_key)"
|
||||
x-soar-sensitive: true
|
||||
base_url:
|
||||
type: string
|
||||
description: "Chronicle API base URL (region-specific)"
|
||||
default: "https://backstory.googleapis.com"
|
||||
required:
|
||||
- service_account_json
|
||||
|
||||
commands:
|
||||
- id: list_iocs
|
||||
name: chronicle-list-iocs
|
||||
description: "List IOCs (indicators of compromise) observed in the enterprise since a start time."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
start_time: { type: string, description: "RFC3339 start time (e.g. 2024-01-01T00:00:00Z)" }
|
||||
page_size: { type: number, description: "Max IOCs (default 100)" }
|
||||
required: [start_time]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_alerts
|
||||
name: chronicle-list-alerts
|
||||
description: "List alerts in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
start_time: { type: string, description: "RFC3339 start time" }
|
||||
end_time: { type: string, description: "RFC3339 end time" }
|
||||
page_size: { type: number, description: "Max alerts (default 100)" }
|
||||
required: [start_time, end_time]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_assets
|
||||
name: chronicle-list-assets
|
||||
description: "List assets that accessed an artifact (domain, IP, or hash) in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
artifact_type: { type: string, description: "domain_name, destination_ip_address, or hash_sha256" }
|
||||
artifact_value: { type: string, description: "The artifact value" }
|
||||
start_time: { type: string, description: "RFC3339 start time" }
|
||||
end_time: { type: string, description: "RFC3339 end time" }
|
||||
required: [artifact_type, artifact_value, start_time, end_time]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: ioc_details
|
||||
name: chronicle-ioc-details
|
||||
description: "Get IOC details for an artifact (domain, IP, or hash)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
artifact_type: { type: string, description: "domain_name, destination_ip_address, or hash_sha256" }
|
||||
artifact_value: { type: string, description: "The artifact value" }
|
||||
required: [artifact_type, artifact_value]
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: chronicle-test-connection
|
||||
description: "Verify the service-account token exchange (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,82 @@
|
||||
import json, os, sys, time, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
import jwt
|
||||
|
||||
TOKEN_URL = "https://oauth2.googleapis.com/token"
|
||||
SCOPE = "https://www.googleapis.com/auth/chronicle-backstory"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("base_url") or "https://backstory.googleapis.com")).rstrip("/")
|
||||
|
||||
|
||||
def _token(cfg):
|
||||
raw = cfg.get("service_account_json", "")
|
||||
sa = json.loads(raw) if isinstance(raw, str) else raw
|
||||
if not sa.get("client_email") or not sa.get("private_key"):
|
||||
raise Exception("service_account_json must contain client_email and private_key")
|
||||
now = int(time.time())
|
||||
aud = sa.get("token_uri") or TOKEN_URL
|
||||
payload = {"iss": sa["client_email"], "scope": SCOPE, "aud": aud, "iat": now, "exp": now + 3600}
|
||||
assertion = jwt.encode(payload, sa["private_key"], algorithm="RS256")
|
||||
data = urllib.parse.urlencode({
|
||||
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
||||
"assertion": assertion,
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(aud, data=data,
|
||||
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 api(method, path, cfg, params=None):
|
||||
url = _base(cfg) + 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 = {"Accept": "application/json", "Authorization": "Bearer " + _token(cfg)}
|
||||
req = urllib.request.Request(url, 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:
|
||||
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 _artifact_params(inputs):
|
||||
at = inputs.get("artifact_type")
|
||||
av = inputs.get("artifact_value")
|
||||
if not at:
|
||||
raise Exception("artifact_type is required")
|
||||
if not av:
|
||||
raise Exception("artifact_value is required")
|
||||
return {"artifact." + at: av}
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
params = _artifact_params(inputs)
|
||||
return api("GET", "/v1/artifact/listiocdetails", cfg, params)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,83 @@
|
||||
import json, os, sys, time, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
import jwt
|
||||
|
||||
TOKEN_URL = "https://oauth2.googleapis.com/token"
|
||||
SCOPE = "https://www.googleapis.com/auth/chronicle-backstory"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("base_url") or "https://backstory.googleapis.com")).rstrip("/")
|
||||
|
||||
|
||||
def _token(cfg):
|
||||
raw = cfg.get("service_account_json", "")
|
||||
sa = json.loads(raw) if isinstance(raw, str) else raw
|
||||
if not sa.get("client_email") or not sa.get("private_key"):
|
||||
raise Exception("service_account_json must contain client_email and private_key")
|
||||
now = int(time.time())
|
||||
aud = sa.get("token_uri") or TOKEN_URL
|
||||
payload = {"iss": sa["client_email"], "scope": SCOPE, "aud": aud, "iat": now, "exp": now + 3600}
|
||||
assertion = jwt.encode(payload, sa["private_key"], algorithm="RS256")
|
||||
data = urllib.parse.urlencode({
|
||||
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
||||
"assertion": assertion,
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(aud, data=data,
|
||||
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 api(method, path, cfg, params=None):
|
||||
url = _base(cfg) + 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 = {"Accept": "application/json", "Authorization": "Bearer " + _token(cfg)}
|
||||
req = urllib.request.Request(url, 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:
|
||||
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):
|
||||
start_time = inputs.get("start_time")
|
||||
if not start_time:
|
||||
raise Exception("start_time is required")
|
||||
end_time = inputs.get("end_time")
|
||||
if not end_time:
|
||||
raise Exception("end_time is required")
|
||||
page_size = inputs.get("page_size")
|
||||
params = {
|
||||
"start_time": start_time,
|
||||
"end_time": end_time,
|
||||
"page_size": int(page_size or 100),
|
||||
}
|
||||
return api("GET", "/v1/alert/listalerts", cfg, params)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,90 @@
|
||||
import json, os, sys, time, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
import jwt
|
||||
|
||||
TOKEN_URL = "https://oauth2.googleapis.com/token"
|
||||
SCOPE = "https://www.googleapis.com/auth/chronicle-backstory"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("base_url") or "https://backstory.googleapis.com")).rstrip("/")
|
||||
|
||||
|
||||
def _token(cfg):
|
||||
raw = cfg.get("service_account_json", "")
|
||||
sa = json.loads(raw) if isinstance(raw, str) else raw
|
||||
if not sa.get("client_email") or not sa.get("private_key"):
|
||||
raise Exception("service_account_json must contain client_email and private_key")
|
||||
now = int(time.time())
|
||||
aud = sa.get("token_uri") or TOKEN_URL
|
||||
payload = {"iss": sa["client_email"], "scope": SCOPE, "aud": aud, "iat": now, "exp": now + 3600}
|
||||
assertion = jwt.encode(payload, sa["private_key"], algorithm="RS256")
|
||||
data = urllib.parse.urlencode({
|
||||
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
||||
"assertion": assertion,
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(aud, data=data,
|
||||
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 api(method, path, cfg, params=None):
|
||||
url = _base(cfg) + 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 = {"Accept": "application/json", "Authorization": "Bearer " + _token(cfg)}
|
||||
req = urllib.request.Request(url, 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:
|
||||
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 _artifact_params(inputs):
|
||||
at = inputs.get("artifact_type")
|
||||
av = inputs.get("artifact_value")
|
||||
if not at:
|
||||
raise Exception("artifact_type is required")
|
||||
if not av:
|
||||
raise Exception("artifact_value is required")
|
||||
return {"artifact." + at: av}
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
params = _artifact_params(inputs)
|
||||
start_time = inputs.get("start_time")
|
||||
if not start_time:
|
||||
raise Exception("start_time is required")
|
||||
end_time = inputs.get("end_time")
|
||||
if not end_time:
|
||||
raise Exception("end_time is required")
|
||||
params["start_time"] = start_time
|
||||
params["end_time"] = end_time
|
||||
return api("GET", "/v1/artifact/listassets", cfg, params)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,79 @@
|
||||
import json, os, sys, time, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
import jwt
|
||||
|
||||
TOKEN_URL = "https://oauth2.googleapis.com/token"
|
||||
SCOPE = "https://www.googleapis.com/auth/chronicle-backstory"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("base_url") or "https://backstory.googleapis.com")).rstrip("/")
|
||||
|
||||
|
||||
def _token(cfg):
|
||||
raw = cfg.get("service_account_json", "")
|
||||
sa = json.loads(raw) if isinstance(raw, str) else raw
|
||||
if not sa.get("client_email") or not sa.get("private_key"):
|
||||
raise Exception("service_account_json must contain client_email and private_key")
|
||||
now = int(time.time())
|
||||
aud = sa.get("token_uri") or TOKEN_URL
|
||||
payload = {"iss": sa["client_email"], "scope": SCOPE, "aud": aud, "iat": now, "exp": now + 3600}
|
||||
assertion = jwt.encode(payload, sa["private_key"], algorithm="RS256")
|
||||
data = urllib.parse.urlencode({
|
||||
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
||||
"assertion": assertion,
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(aud, data=data,
|
||||
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 api(method, path, cfg, params=None):
|
||||
url = _base(cfg) + 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 = {"Accept": "application/json", "Authorization": "Bearer " + _token(cfg)}
|
||||
req = urllib.request.Request(url, 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:
|
||||
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):
|
||||
start_time = inputs.get("start_time")
|
||||
if not start_time:
|
||||
raise Exception("start_time is required")
|
||||
page_size = inputs.get("page_size")
|
||||
params = {
|
||||
"start_time": start_time,
|
||||
"page_size": int(page_size or 100),
|
||||
}
|
||||
return api("GET", "/v1/ioc/listiocs", cfg, params)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,72 @@
|
||||
import json, os, sys, time, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
import jwt
|
||||
|
||||
TOKEN_URL = "https://oauth2.googleapis.com/token"
|
||||
SCOPE = "https://www.googleapis.com/auth/chronicle-backstory"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("base_url") or "https://backstory.googleapis.com")).rstrip("/")
|
||||
|
||||
|
||||
def _token(cfg):
|
||||
raw = cfg.get("service_account_json", "")
|
||||
sa = json.loads(raw) if isinstance(raw, str) else raw
|
||||
if not sa.get("client_email") or not sa.get("private_key"):
|
||||
raise Exception("service_account_json must contain client_email and private_key")
|
||||
now = int(time.time())
|
||||
aud = sa.get("token_uri") or TOKEN_URL
|
||||
payload = {"iss": sa["client_email"], "scope": SCOPE, "aud": aud, "iat": now, "exp": now + 3600}
|
||||
assertion = jwt.encode(payload, sa["private_key"], algorithm="RS256")
|
||||
data = urllib.parse.urlencode({
|
||||
"grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
||||
"assertion": assertion,
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(aud, data=data,
|
||||
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 api(method, path, cfg, params=None):
|
||||
url = _base(cfg) + 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 = {"Accept": "application/json", "Authorization": "Bearer " + _token(cfg)}
|
||||
req = urllib.request.Request(url, 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:
|
||||
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):
|
||||
api("GET", "/v1/ioc/listiocs", cfg, {"page_size": 1})
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,94 @@
|
||||
id: elasticsearch
|
||||
name: Elasticsearch
|
||||
version: 1.0.0
|
||||
description: "Elasticsearch (REST API) — log search and enrichment for security data: run queries, count and read documents, list indices, index a document, and delete by query. API-key authentication; stdlib-only, no extra Python dependencies. Works with Elastic Security indices."
|
||||
changelog: "1.0.0 — Initial release: search, count, get document, index document, list indices, delete by query."
|
||||
category: siem
|
||||
|
||||
# Per-instance configuration. Auth header 'Authorization: ApiKey <api_key>'.
|
||||
config_schema:
|
||||
properties:
|
||||
url:
|
||||
type: string
|
||||
description: "Elasticsearch base URL (e.g. https://es.example.com:9200)"
|
||||
api_key:
|
||||
type: string
|
||||
description: "Elasticsearch API key (base64 id:key)"
|
||||
x-soar-sensitive: true
|
||||
insecure:
|
||||
type: boolean
|
||||
description: "Trust any TLS certificate (not secure)"
|
||||
default: false
|
||||
required:
|
||||
- url
|
||||
- api_key
|
||||
|
||||
commands:
|
||||
- id: search
|
||||
name: elasticsearch-search
|
||||
description: "Search an index. Provide a raw query DSL (query_json) or a simple query string."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
index: { type: string, description: "Index or index pattern (e.g. logs-*)" }
|
||||
query_json: { type: string, description: "Raw Elasticsearch query DSL as a JSON object (advanced)" }
|
||||
query_string: { type: string, description: "Simple query_string query (used if query_json is empty)" }
|
||||
size: { type: number, description: "Max hits (default 50)" }
|
||||
required: [index]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: count
|
||||
name: elasticsearch-count
|
||||
description: "Count documents matching a query."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
index: { type: string, description: "Index or index pattern" }
|
||||
query_string: { type: string, description: "Optional simple query_string (default all)" }
|
||||
required: [index]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_document
|
||||
name: elasticsearch-get-document
|
||||
description: "Get a single document by ID."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
index: { type: string, description: "Index name" }
|
||||
doc_id: { type: string, description: "Document ID" }
|
||||
required: [index, doc_id]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: index_document
|
||||
name: elasticsearch-index-document
|
||||
description: "Index (create) a document."
|
||||
inputs_schema:
|
||||
properties:
|
||||
index: { type: string, description: "Index name" }
|
||||
document_json: { type: string, description: "Document body as a JSON object" }
|
||||
doc_id: { type: string, description: "Optional document ID (auto-generated if omitted)" }
|
||||
required: [index, document_json]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_indices
|
||||
name: elasticsearch-list-indices
|
||||
description: "List indices."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: delete_by_query
|
||||
name: elasticsearch-delete-by-query
|
||||
description: "Delete documents matching a query."
|
||||
inputs_schema:
|
||||
properties:
|
||||
index: { type: string, description: "Index name" }
|
||||
query_json: { type: string, description: "Raw query DSL (JSON object) selecting documents to delete" }
|
||||
required: [index, query_json]
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: elasticsearch-test-connection
|
||||
description: "Verify connectivity and the API key (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,72 @@
|
||||
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("url", "")).rstrip("/") + 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": "ApiKey " + 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=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
index = inputs.get("index")
|
||||
if not index:
|
||||
raise Exception("index is required")
|
||||
query_string = inputs.get("query_string")
|
||||
|
||||
if query_string:
|
||||
body = {"query": {"query_string": {"query": query_string}}}
|
||||
else:
|
||||
body = {"query": {"match_all": {}}}
|
||||
|
||||
return request("POST", "/" + q(index) + "/_count", cfg, body=body)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,75 @@
|
||||
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("url", "")).rstrip("/") + 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": "ApiKey " + 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=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
index = inputs.get("index")
|
||||
if not index:
|
||||
raise Exception("index is required")
|
||||
query_json = inputs.get("query_json")
|
||||
if not query_json:
|
||||
raise Exception("query_json is required")
|
||||
parsed = _parse_json(query_json, "query_json")
|
||||
|
||||
if "query" in parsed:
|
||||
body = parsed
|
||||
else:
|
||||
body = {"query": parsed}
|
||||
|
||||
return request("POST", "/" + q(index) + "/_delete_by_query", cfg, body=body)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,69 @@
|
||||
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("url", "")).rstrip("/") + 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": "ApiKey " + 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=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
index = inputs.get("index")
|
||||
if not index:
|
||||
raise Exception("index is required")
|
||||
doc_id = inputs.get("doc_id")
|
||||
if not doc_id:
|
||||
raise Exception("doc_id is required")
|
||||
|
||||
return request("GET", "/" + q(index) + "/_doc/" + q(doc_id), cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,73 @@
|
||||
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("url", "")).rstrip("/") + 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": "ApiKey " + 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=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
index = inputs.get("index")
|
||||
if not index:
|
||||
raise Exception("index is required")
|
||||
document_json = inputs.get("document_json")
|
||||
if not document_json:
|
||||
raise Exception("document_json is required")
|
||||
doc = _parse_json(document_json, "document_json")
|
||||
doc_id = inputs.get("doc_id")
|
||||
|
||||
if doc_id:
|
||||
return request("PUT", "/" + q(index) + "/_doc/" + q(doc_id), cfg, body=doc)
|
||||
return request("POST", "/" + q(index) + "/_doc", cfg, body=doc)
|
||||
|
||||
|
||||
_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("url", "")).rstrip("/") + 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": "ApiKey " + 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=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/_cat/indices", cfg, params={"format": "json"})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,81 @@
|
||||
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("url", "")).rstrip("/") + 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": "ApiKey " + 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=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
index = inputs.get("index")
|
||||
if not index:
|
||||
raise Exception("index is required")
|
||||
query_json = inputs.get("query_json")
|
||||
query_string = inputs.get("query_string")
|
||||
size = inputs.get("size")
|
||||
|
||||
if query_json:
|
||||
parsed = _parse_json(query_json, "query_json")
|
||||
if "query" in parsed:
|
||||
body = parsed
|
||||
body.setdefault("size", int(size or 50))
|
||||
else:
|
||||
body = {"query": parsed, "size": int(size or 50)}
|
||||
elif query_string:
|
||||
body = {"query": {"query_string": {"query": query_string}}, "size": int(size or 50)}
|
||||
else:
|
||||
body = {"query": {"match_all": {}}, "size": int(size or 50)}
|
||||
|
||||
return request("POST", "/" + q(index) + "/_search", cfg, body=body)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,63 @@
|
||||
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("url", "")).rstrip("/") + 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": "ApiKey " + 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=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
request("GET", "/", cfg)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,101 @@
|
||||
id: qradar
|
||||
name: IBM QRadar
|
||||
version: 1.0.0
|
||||
description: "IBM QRadar (REST API) — SIEM investigation and response: list and read offenses, update/close an offense, list reference sets and add/remove values (block/allow lists used by rules), and list assets. SEC-token authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: list/get offenses, update offense, list reference sets, add/remove reference-set value, list assets."
|
||||
category: siem
|
||||
|
||||
# Per-instance configuration. The API token is sent as the 'SEC' header.
|
||||
config_schema:
|
||||
properties:
|
||||
base_url:
|
||||
type: string
|
||||
description: "QRadar console URL (e.g. https://qradar.example.com)"
|
||||
api_token:
|
||||
type: string
|
||||
description: "QRadar authorized service (SEC) 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_offenses
|
||||
name: qradar-list-offenses
|
||||
description: "List offenses (optionally filtered)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
filter: { type: string, description: "QRadar filter expression (e.g. status=OPEN)" }
|
||||
limit: { type: number, description: "Max offenses (default 50)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_offense
|
||||
name: qradar-get-offense
|
||||
description: "Get a single offense by ID."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
offense_id: { type: string, description: "Offense ID" }
|
||||
required: [offense_id]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: update_offense
|
||||
name: qradar-update-offense
|
||||
description: "Update an offense (status, assignee, or close with a reason)."
|
||||
inputs_schema:
|
||||
properties:
|
||||
offense_id: { type: string, description: "Offense ID" }
|
||||
status: { type: string, description: "OPEN, HIDDEN, or CLOSED" }
|
||||
assigned_to: { type: string, description: "Assignee username" }
|
||||
closing_reason_id: { type: string, description: "Closing reason ID (required when status=CLOSED)" }
|
||||
required: [offense_id]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_reference_sets
|
||||
name: qradar-list-reference-sets
|
||||
description: "List reference sets."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: add_to_reference_set
|
||||
name: qradar-add-to-reference-set
|
||||
description: "Add a value to a reference set (e.g. a block list consumed by rules)."
|
||||
inputs_schema:
|
||||
properties:
|
||||
set_name: { type: string, description: "Reference set name" }
|
||||
value: { type: string, description: "Value to add" }
|
||||
required: [set_name, value]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: delete_from_reference_set
|
||||
name: qradar-delete-from-reference-set
|
||||
description: "Remove a value from a reference set."
|
||||
inputs_schema:
|
||||
properties:
|
||||
set_name: { type: string, description: "Reference set name" }
|
||||
value: { type: string, description: "Value to remove" }
|
||||
required: [set_name, value]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_assets
|
||||
name: qradar-list-assets
|
||||
description: "List assets from the asset model."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
filter: { type: string, description: "Optional filter expression" }
|
||||
limit: { type: number, description: "Max assets (default 50)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: qradar-test-connection
|
||||
description: "Verify connectivity and the SEC token (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,61 @@
|
||||
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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
set_name = inputs.get("set_name")
|
||||
if not set_name:
|
||||
raise Exception("set_name is required")
|
||||
value = inputs.get("value")
|
||||
if not value:
|
||||
raise Exception("value is required")
|
||||
|
||||
return request("POST", "/api/reference_data/sets/" + q(set_name), cfg, params={"value": value})
|
||||
|
||||
|
||||
_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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
set_name = inputs.get("set_name")
|
||||
if not set_name:
|
||||
raise Exception("set_name is required")
|
||||
value = inputs.get("value")
|
||||
if not value:
|
||||
raise Exception("value is required")
|
||||
|
||||
result = request("DELETE", "/api/reference_data/sets/" + q(set_name) + "/" + q(value), cfg)
|
||||
if not result:
|
||||
return {"ok": True}
|
||||
return result
|
||||
|
||||
|
||||
_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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
offense_id = inputs.get("offense_id")
|
||||
if not offense_id:
|
||||
raise Exception("offense_id is required")
|
||||
return request("GET", "/api/siem/offenses/" + q(offense_id), cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
filter_ = inputs.get("filter")
|
||||
limit = inputs.get("limit")
|
||||
limit = int(limit) if limit not in (None, "") else 50
|
||||
params = {"filter": filter_}
|
||||
headers = {"Range": "items=0-" + str(limit - 1)}
|
||||
return request("GET", "/api/asset_model/assets", cfg, params=params, extra_headers=headers)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
filter_ = inputs.get("filter")
|
||||
limit = inputs.get("limit")
|
||||
limit = int(limit) if limit not in (None, "") else 50
|
||||
params = {"filter": filter_}
|
||||
headers = {"Range": "items=0-" + str(limit - 1)}
|
||||
return request("GET", "/api/siem/offenses", cfg, params=params, extra_headers=headers)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,54 @@
|
||||
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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/api/reference_data/sets", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,55 @@
|
||||
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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
request("GET", "/api/system/about", cfg)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,73 @@
|
||||
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, params=None, extra_headers=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + 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 = {"SEC": str(cfg.get("api_token", "")), "Version": "20.0", "Accept": "application/json"}
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
req = urllib.request.Request(url, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=90, 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)
|
||||
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
offense_id = inputs.get("offense_id")
|
||||
if not offense_id:
|
||||
raise Exception("offense_id is required")
|
||||
|
||||
status = inputs.get("status")
|
||||
assigned_to = inputs.get("assigned_to")
|
||||
closing_reason_id = inputs.get("closing_reason_id")
|
||||
|
||||
params = {}
|
||||
if status not in (None, ""):
|
||||
params["status"] = status
|
||||
if assigned_to not in (None, ""):
|
||||
params["assigned_to"] = assigned_to
|
||||
if closing_reason_id not in (None, ""):
|
||||
params["closing_reason_id"] = closing_reason_id
|
||||
|
||||
if not params:
|
||||
raise Exception("at least one of status, assigned_to, closing_reason_id is required")
|
||||
|
||||
return request("POST", "/api/siem/offenses/" + q(offense_id), cfg, params=params)
|
||||
|
||||
|
||||
_run(main)
|
||||
Reference in New Issue
Block a user