Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe7dae8bd3 | |||
| 52356523c9 | |||
| a567558341 |
@@ -0,0 +1,97 @@
|
||||
id: prisma_cloud
|
||||
name: Prisma Cloud
|
||||
version: 1.0.0
|
||||
description: "Palo Alto Prisma Cloud (CSPM REST API) — cloud posture: list and read alerts, dismiss alerts, list policies and cloud accounts, and run a config (RQL) search. Access-key login authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: list/get alerts, dismiss alerts, list policies, list cloud accounts, config search."
|
||||
category: cloud
|
||||
|
||||
# Per-instance configuration. Each command logs in with the access key ID +
|
||||
# secret key to obtain a JWT (sent as the 'x-redlock-auth' header).
|
||||
config_schema:
|
||||
properties:
|
||||
api_url:
|
||||
type: string
|
||||
description: "Prisma Cloud API URL (e.g. https://api.prismacloud.io)"
|
||||
username:
|
||||
type: string
|
||||
description: "Access Key ID"
|
||||
password:
|
||||
type: string
|
||||
description: "Secret Key"
|
||||
x-soar-sensitive: true
|
||||
insecure:
|
||||
type: boolean
|
||||
description: "Trust any TLS certificate (not secure)"
|
||||
default: false
|
||||
required:
|
||||
- api_url
|
||||
- username
|
||||
- password
|
||||
|
||||
commands:
|
||||
- id: list_alerts
|
||||
name: prisma-list-alerts
|
||||
description: "List alerts in a relative time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
time_amount: { type: number, description: "Look-back amount (default 24)" }
|
||||
time_unit: { type: string, description: "hour, day, week, month, or year (default hour)" }
|
||||
status: { type: string, description: "Optional status filter (open, resolved, dismissed)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_alert
|
||||
name: prisma-get-alert
|
||||
description: "Get a single alert by ID."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
alert_id: { type: string, description: "Alert ID" }
|
||||
required: [alert_id]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: dismiss_alerts
|
||||
name: prisma-dismiss-alerts
|
||||
description: "Dismiss one or more alerts with a note."
|
||||
inputs_schema:
|
||||
properties:
|
||||
alert_ids: { type: string, description: "Comma-separated alert IDs" }
|
||||
note: { type: string, description: "Dismissal note" }
|
||||
required: [alert_ids]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_policies
|
||||
name: prisma-list-policies
|
||||
description: "List policies."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
policy_type: { type: string, description: "Optional type filter (config, network, audit_event, ...)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_cloud_accounts
|
||||
name: prisma-list-cloud-accounts
|
||||
description: "List onboarded cloud accounts."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: config_search
|
||||
name: prisma-config-search
|
||||
description: "Run a config (RQL) search."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
query: { type: string, description: "RQL query (e.g. config from cloud.resource where ...)" }
|
||||
time_amount: { type: number, description: "Look-back amount (default 24)" }
|
||||
time_unit: { type: string, description: "hour, day, week, month (default hour)" }
|
||||
required: [query]
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: prisma-test-connection
|
||||
description: "Verify connectivity and credentials by logging in (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,86 @@
|
||||
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 _base(cfg):
|
||||
return str(cfg.get("api_url", "")).rstrip("/")
|
||||
|
||||
|
||||
def _login(cfg):
|
||||
body = json.dumps({"username": cfg.get("username", ""), "password": cfg.get("password", "")}).encode("utf-8")
|
||||
req = urllib.request.Request(_base(cfg) + "/login", data=body,
|
||||
headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("token"):
|
||||
raise Exception("Login failed: " + json.dumps(tok))
|
||||
return tok["token"]
|
||||
|
||||
|
||||
def request(method, path, cfg, token, body=None, 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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"x-redlock-auth": 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, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _login(cfg)
|
||||
print(json.dumps(fn(cfg, 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(cfg, token, inputs):
|
||||
query = inputs.get("query")
|
||||
if not query:
|
||||
raise Exception("query is required")
|
||||
|
||||
time_amount = inputs.get("time_amount")
|
||||
time_unit = inputs.get("time_unit")
|
||||
|
||||
return request("POST", "/search/config", cfg, token, body={
|
||||
"query": query,
|
||||
"timeRange": {
|
||||
"type": "relative",
|
||||
"value": {
|
||||
"amount": int(time_amount or 24),
|
||||
"unit": (time_unit or "hour"),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,87 @@
|
||||
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 _base(cfg):
|
||||
return str(cfg.get("api_url", "")).rstrip("/")
|
||||
|
||||
|
||||
def _login(cfg):
|
||||
body = json.dumps({"username": cfg.get("username", ""), "password": cfg.get("password", "")}).encode("utf-8")
|
||||
req = urllib.request.Request(_base(cfg) + "/login", data=body,
|
||||
headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("token"):
|
||||
raise Exception("Login failed: " + json.dumps(tok))
|
||||
return tok["token"]
|
||||
|
||||
|
||||
def request(method, path, cfg, token, body=None, 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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"x-redlock-auth": 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, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _login(cfg)
|
||||
print(json.dumps(fn(cfg, 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(cfg, token, inputs):
|
||||
alert_ids = inputs.get("alert_ids")
|
||||
if not alert_ids:
|
||||
raise Exception("alert_ids is required")
|
||||
|
||||
alert_ids_list = [s.strip() for s in str(alert_ids).split(",") if s.strip()]
|
||||
if not alert_ids_list:
|
||||
raise Exception("alert_ids is required")
|
||||
|
||||
note = inputs.get("note")
|
||||
|
||||
resp = request("POST", "/alert/dismiss", cfg, token, body={
|
||||
"alerts": alert_ids_list,
|
||||
"dismissalNote": (note or "Dismissed via Riposte"),
|
||||
})
|
||||
|
||||
if not resp:
|
||||
return {"ok": True, "dismissed": alert_ids_list}
|
||||
return resp
|
||||
|
||||
|
||||
_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 _base(cfg):
|
||||
return str(cfg.get("api_url", "")).rstrip("/")
|
||||
|
||||
|
||||
def _login(cfg):
|
||||
body = json.dumps({"username": cfg.get("username", ""), "password": cfg.get("password", "")}).encode("utf-8")
|
||||
req = urllib.request.Request(_base(cfg) + "/login", data=body,
|
||||
headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("token"):
|
||||
raise Exception("Login failed: " + json.dumps(tok))
|
||||
return tok["token"]
|
||||
|
||||
|
||||
def request(method, path, cfg, token, body=None, 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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"x-redlock-auth": 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, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _login(cfg)
|
||||
print(json.dumps(fn(cfg, 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(cfg, token, inputs):
|
||||
alert_id = inputs.get("alert_id")
|
||||
if not alert_id:
|
||||
raise Exception("alert_id is required")
|
||||
|
||||
q = lambda v: urllib.parse.quote(str(v), safe="")
|
||||
return request("GET", "/alert/" + q(alert_id), cfg, token)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,83 @@
|
||||
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 _base(cfg):
|
||||
return str(cfg.get("api_url", "")).rstrip("/")
|
||||
|
||||
|
||||
def _login(cfg):
|
||||
body = json.dumps({"username": cfg.get("username", ""), "password": cfg.get("password", "")}).encode("utf-8")
|
||||
req = urllib.request.Request(_base(cfg) + "/login", data=body,
|
||||
headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("token"):
|
||||
raise Exception("Login failed: " + json.dumps(tok))
|
||||
return tok["token"]
|
||||
|
||||
|
||||
def request(method, path, cfg, token, body=None, 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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"x-redlock-auth": 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, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _login(cfg)
|
||||
print(json.dumps(fn(cfg, 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(cfg, token, inputs):
|
||||
time_amount = inputs.get("time_amount")
|
||||
time_unit = inputs.get("time_unit")
|
||||
status = inputs.get("status")
|
||||
|
||||
params = {
|
||||
"timeType": "relative",
|
||||
"timeAmount": int(time_amount or 24),
|
||||
"timeUnit": (time_unit or "hour"),
|
||||
"detailed": "true",
|
||||
}
|
||||
if status:
|
||||
params["alert.status"] = status
|
||||
|
||||
return request("GET", "/alert", cfg, token, params=params)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,70 @@
|
||||
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 _base(cfg):
|
||||
return str(cfg.get("api_url", "")).rstrip("/")
|
||||
|
||||
|
||||
def _login(cfg):
|
||||
body = json.dumps({"username": cfg.get("username", ""), "password": cfg.get("password", "")}).encode("utf-8")
|
||||
req = urllib.request.Request(_base(cfg) + "/login", data=body,
|
||||
headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("token"):
|
||||
raise Exception("Login failed: " + json.dumps(tok))
|
||||
return tok["token"]
|
||||
|
||||
|
||||
def request(method, path, cfg, token, body=None, 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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"x-redlock-auth": 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, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _login(cfg)
|
||||
print(json.dumps(fn(cfg, 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(cfg, token, inputs):
|
||||
return request("GET", "/cloud", cfg, token)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,71 @@
|
||||
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 _base(cfg):
|
||||
return str(cfg.get("api_url", "")).rstrip("/")
|
||||
|
||||
|
||||
def _login(cfg):
|
||||
body = json.dumps({"username": cfg.get("username", ""), "password": cfg.get("password", "")}).encode("utf-8")
|
||||
req = urllib.request.Request(_base(cfg) + "/login", data=body,
|
||||
headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("token"):
|
||||
raise Exception("Login failed: " + json.dumps(tok))
|
||||
return tok["token"]
|
||||
|
||||
|
||||
def request(method, path, cfg, token, body=None, 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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"x-redlock-auth": 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, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _login(cfg)
|
||||
print(json.dumps(fn(cfg, 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(cfg, token, inputs):
|
||||
policy_type = inputs.get("policy_type")
|
||||
return request("GET", "/policy", cfg, token, params={"policy.type": policy_type})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,71 @@
|
||||
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 _base(cfg):
|
||||
return str(cfg.get("api_url", "")).rstrip("/")
|
||||
|
||||
|
||||
def _login(cfg):
|
||||
body = json.dumps({"username": cfg.get("username", ""), "password": cfg.get("password", "")}).encode("utf-8")
|
||||
req = urllib.request.Request(_base(cfg) + "/login", data=body,
|
||||
headers={"Content-Type": "application/json", "Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("token"):
|
||||
raise Exception("Login failed: " + json.dumps(tok))
|
||||
return tok["token"]
|
||||
|
||||
|
||||
def request(method, path, cfg, token, body=None, 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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"x-redlock-auth": 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, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _login(cfg)
|
||||
print(json.dumps(fn(cfg, 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(cfg, token, inputs):
|
||||
request("GET", "/cloud", cfg, token)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,90 @@
|
||||
id: vault
|
||||
name: HashiCorp Vault
|
||||
version: 1.0.0
|
||||
description: "HashiCorp Vault (KV v2 + sys API) — secrets management for playbooks: read, write, delete and list secrets, list mounts, and look up the current token. Vault-token authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: read/write/delete/list secrets, list mounts, lookup token."
|
||||
category: cloud
|
||||
|
||||
# Per-instance configuration. The token is sent as the 'X-Vault-Token' header.
|
||||
# kv_mount is the KV v2 mount point used by the secret commands.
|
||||
config_schema:
|
||||
properties:
|
||||
base_url:
|
||||
type: string
|
||||
description: "Vault URL (e.g. https://vault.example.com:8200)"
|
||||
token:
|
||||
type: string
|
||||
description: "Vault token"
|
||||
x-soar-sensitive: true
|
||||
kv_mount:
|
||||
type: string
|
||||
description: "KV v2 mount point (default 'secret')"
|
||||
default: "secret"
|
||||
insecure:
|
||||
type: boolean
|
||||
description: "Trust any TLS certificate (not secure)"
|
||||
default: false
|
||||
required:
|
||||
- base_url
|
||||
- token
|
||||
|
||||
commands:
|
||||
- id: read_secret
|
||||
name: vault-read-secret
|
||||
description: "Read a secret from the KV v2 store."
|
||||
inputs_schema:
|
||||
properties:
|
||||
path: { type: string, description: "Secret path within the KV mount (e.g. app/db)" }
|
||||
required: [path]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: write_secret
|
||||
name: vault-write-secret
|
||||
description: "Write (create/update) a secret in the KV v2 store."
|
||||
inputs_schema:
|
||||
properties:
|
||||
path: { type: string, description: "Secret path" }
|
||||
data_json: { type: string, description: "Secret key/values as a JSON object" }
|
||||
required: [path, data_json]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: delete_secret
|
||||
name: vault-delete-secret
|
||||
description: "Delete a secret (all versions/metadata) from the KV v2 store."
|
||||
inputs_schema:
|
||||
properties:
|
||||
path: { type: string, description: "Secret path" }
|
||||
required: [path]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_secrets
|
||||
name: vault-list-secrets
|
||||
description: "List secret keys under a path."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
path: { type: string, description: "Path to list (empty for the mount root)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_mounts
|
||||
name: vault-list-mounts
|
||||
description: "List secret engine mounts."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: lookup_token
|
||||
name: vault-lookup-token
|
||||
description: "Look up the current token's metadata and policies."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: vault-test-connection
|
||||
description: "Verify connectivity and the token (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,70 @@
|
||||
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 _mount(cfg):
|
||||
return str(cfg.get("kv_mount") or "secret")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"X-Vault-Token": str(cfg.get("token", "")), "Accept": "application/json"}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
path = inputs.get("path")
|
||||
if not path:
|
||||
raise Exception("path is required")
|
||||
p = str(path).lstrip("/")
|
||||
result = request("DELETE", "/v1/" + _mount(cfg) + "/metadata/" + p, cfg)
|
||||
if not result:
|
||||
return {"ok": True, "deleted": path}
|
||||
return result
|
||||
|
||||
|
||||
_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 _mount(cfg):
|
||||
return str(cfg.get("kv_mount") or "secret")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"X-Vault-Token": str(cfg.get("token", "")), "Accept": "application/json"}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/v1/sys/mounts", cfg)
|
||||
|
||||
|
||||
_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 _mount(cfg):
|
||||
return str(cfg.get("kv_mount") or "secret")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"X-Vault-Token": str(cfg.get("token", "")), "Accept": "application/json"}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
p = str(inputs.get("path") or "").lstrip("/")
|
||||
return request("GET", "/v1/" + _mount(cfg) + "/metadata/" + p, cfg, params={"list": "true"})
|
||||
|
||||
|
||||
_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 _mount(cfg):
|
||||
return str(cfg.get("kv_mount") or "secret")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"X-Vault-Token": str(cfg.get("token", "")), "Accept": "application/json"}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/v1/auth/token/lookup-self", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,67 @@
|
||||
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 _mount(cfg):
|
||||
return str(cfg.get("kv_mount") or "secret")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"X-Vault-Token": str(cfg.get("token", "")), "Accept": "application/json"}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
path = inputs.get("path")
|
||||
if not path:
|
||||
raise Exception("path is required")
|
||||
p = str(path).lstrip("/")
|
||||
return request("GET", "/v1/" + _mount(cfg) + "/data/" + p, cfg)
|
||||
|
||||
|
||||
_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 _mount(cfg):
|
||||
return str(cfg.get("kv_mount") or "secret")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"X-Vault-Token": str(cfg.get("token", "")), "Accept": "application/json"}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
request("GET", "/v1/sys/health", cfg)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,71 @@
|
||||
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 _mount(cfg):
|
||||
return str(cfg.get("kv_mount") or "secret")
|
||||
|
||||
|
||||
def _parse_json(s, field):
|
||||
try:
|
||||
return json.loads(s)
|
||||
except Exception:
|
||||
raise Exception(field + " must be a valid JSON object")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=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)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {"X-Vault-Token": str(cfg.get("token", "")), "Accept": "application/json"}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
path = inputs.get("path")
|
||||
if not path:
|
||||
raise Exception("path is required")
|
||||
data_json = inputs.get("data_json")
|
||||
if not data_json:
|
||||
raise Exception("data_json is required")
|
||||
data = _parse_json(data_json, "data_json")
|
||||
p = str(path).lstrip("/")
|
||||
return request("POST", "/v1/" + _mount(cfg) + "/data/" + p, cfg, body={"data": data})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,90 @@
|
||||
id: wiz
|
||||
name: Wiz
|
||||
version: 1.0.0
|
||||
description: "Wiz (CNAPP GraphQL API) — cloud security posture: list and read issues, update an issue's status, list vulnerability findings, and search cloud resources. OAuth2 client-credentials authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: list/get issues, update issue status, list vulnerabilities, list cloud resources."
|
||||
category: cloud
|
||||
|
||||
# Per-instance configuration. Client credentials are exchanged at the auth URL
|
||||
# for a bearer token used against the tenant GraphQL endpoint.
|
||||
config_schema:
|
||||
properties:
|
||||
api_url:
|
||||
type: string
|
||||
description: "Wiz GraphQL API endpoint (e.g. https://api.us1.app.wiz.io/graphql)"
|
||||
auth_url:
|
||||
type: string
|
||||
description: "Wiz OAuth token URL"
|
||||
default: "https://auth.app.wiz.io/oauth/token"
|
||||
client_id:
|
||||
type: string
|
||||
description: "Wiz service account client ID"
|
||||
client_secret:
|
||||
type: string
|
||||
description: "Wiz service account client secret"
|
||||
x-soar-sensitive: true
|
||||
required:
|
||||
- api_url
|
||||
- client_id
|
||||
- client_secret
|
||||
|
||||
commands:
|
||||
- id: list_issues
|
||||
name: wiz-list-issues
|
||||
description: "List issues (optionally filtered by status and severity)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
status: { type: string, description: "Status filter (OPEN, IN_PROGRESS, RESOLVED, REJECTED)" }
|
||||
severity: { type: string, description: "Severity filter (CRITICAL, HIGH, MEDIUM, LOW, INFORMATIONAL)" }
|
||||
first: { type: number, description: "Max issues (default 20)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_issue
|
||||
name: wiz-get-issue
|
||||
description: "Get a single issue by ID."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
issue_id: { type: string, description: "Issue ID" }
|
||||
required: [issue_id]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: update_issue_status
|
||||
name: wiz-update-issue-status
|
||||
description: "Update an issue's status (e.g. resolve or reject)."
|
||||
inputs_schema:
|
||||
properties:
|
||||
issue_id: { type: string, description: "Issue ID" }
|
||||
status: { type: string, description: "OPEN, IN_PROGRESS, RESOLVED, or REJECTED" }
|
||||
note: { type: string, description: "Optional note" }
|
||||
required: [issue_id, status]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_vulnerabilities
|
||||
name: wiz-list-vulnerabilities
|
||||
description: "List vulnerability findings."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
severity: { type: string, description: "Severity filter (CRITICAL, HIGH, MEDIUM, LOW)" }
|
||||
first: { type: number, description: "Max findings (default 20)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_cloud_resources
|
||||
name: wiz-list-cloud-resources
|
||||
description: "Search cloud resources by a text query."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
search: { type: string, description: "Free-text search over resource names" }
|
||||
first: { type: number, description: "Max resources (default 20)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: wiz-test-connection
|
||||
description: "Verify the token exchange and GraphQL access (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,75 @@
|
||||
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 _token(cfg):
|
||||
auth_url = str(cfg.get("auth_url") or "https://auth.app.wiz.io/oauth/token")
|
||||
form = urllib.parse.urlencode({
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": str(cfg.get("client_id", "")),
|
||||
"client_secret": str(cfg.get("client_secret", "")),
|
||||
"audience": "wiz-api",
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(auth_url, data=form,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("access_token"):
|
||||
raise Exception("Token request failed: " + json.dumps(tok))
|
||||
return tok["access_token"]
|
||||
|
||||
|
||||
def graphql(cfg, token, query, variables):
|
||||
body = json.dumps({"query": query, "variables": variables}).encode("utf-8")
|
||||
req = urllib.request.Request(str(cfg.get("api_url", "")), data=body, headers={
|
||||
"Authorization": "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=90) as r:
|
||||
raw = r.read()
|
||||
resp = json.loads(raw) if raw else {}
|
||||
if resp.get("errors"):
|
||||
raise Exception("GraphQL error: " + json.dumps(resp["errors"]))
|
||||
return resp.get("data", resp)
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _token(cfg)
|
||||
print(json.dumps(fn(cfg, 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)
|
||||
|
||||
|
||||
QUERY = """
|
||||
query Issue($id: ID!) {
|
||||
issue(id: $id) { id status severity type createdAt notes { text } entitySnapshot { name type } }
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(cfg, token, inputs):
|
||||
issue_id = inputs.get("issue_id")
|
||||
if not issue_id:
|
||||
raise Exception("issue_id is required")
|
||||
|
||||
variables = {"id": issue_id}
|
||||
return graphql(cfg, token, QUERY, variables)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,81 @@
|
||||
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 _token(cfg):
|
||||
auth_url = str(cfg.get("auth_url") or "https://auth.app.wiz.io/oauth/token")
|
||||
form = urllib.parse.urlencode({
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": str(cfg.get("client_id", "")),
|
||||
"client_secret": str(cfg.get("client_secret", "")),
|
||||
"audience": "wiz-api",
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(auth_url, data=form,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("access_token"):
|
||||
raise Exception("Token request failed: " + json.dumps(tok))
|
||||
return tok["access_token"]
|
||||
|
||||
|
||||
def graphql(cfg, token, query, variables):
|
||||
body = json.dumps({"query": query, "variables": variables}).encode("utf-8")
|
||||
req = urllib.request.Request(str(cfg.get("api_url", "")), data=body, headers={
|
||||
"Authorization": "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=90) as r:
|
||||
raw = r.read()
|
||||
resp = json.loads(raw) if raw else {}
|
||||
if resp.get("errors"):
|
||||
raise Exception("GraphQL error: " + json.dumps(resp["errors"]))
|
||||
return resp.get("data", resp)
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _token(cfg)
|
||||
print(json.dumps(fn(cfg, 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)
|
||||
|
||||
|
||||
QUERY = """
|
||||
query CloudResources($first: Int, $filterBy: CloudResourceFilters) {
|
||||
cloudResources(first: $first, filterBy: $filterBy) {
|
||||
nodes { id name type subscriptionId region }
|
||||
pageInfo { hasNextPage endCursor }
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(cfg, token, inputs):
|
||||
search = inputs.get("search")
|
||||
first = inputs.get("first")
|
||||
|
||||
filter_by = {}
|
||||
if search:
|
||||
filter_by["search"] = search
|
||||
|
||||
variables = {"first": int(first or 20), "filterBy": filter_by}
|
||||
return graphql(cfg, token, QUERY, variables)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,84 @@
|
||||
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 _token(cfg):
|
||||
auth_url = str(cfg.get("auth_url") or "https://auth.app.wiz.io/oauth/token")
|
||||
form = urllib.parse.urlencode({
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": str(cfg.get("client_id", "")),
|
||||
"client_secret": str(cfg.get("client_secret", "")),
|
||||
"audience": "wiz-api",
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(auth_url, data=form,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("access_token"):
|
||||
raise Exception("Token request failed: " + json.dumps(tok))
|
||||
return tok["access_token"]
|
||||
|
||||
|
||||
def graphql(cfg, token, query, variables):
|
||||
body = json.dumps({"query": query, "variables": variables}).encode("utf-8")
|
||||
req = urllib.request.Request(str(cfg.get("api_url", "")), data=body, headers={
|
||||
"Authorization": "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=90) as r:
|
||||
raw = r.read()
|
||||
resp = json.loads(raw) if raw else {}
|
||||
if resp.get("errors"):
|
||||
raise Exception("GraphQL error: " + json.dumps(resp["errors"]))
|
||||
return resp.get("data", resp)
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _token(cfg)
|
||||
print(json.dumps(fn(cfg, 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)
|
||||
|
||||
|
||||
QUERY = """
|
||||
query Issues($first: Int, $filterBy: IssueFilters) {
|
||||
issues(first: $first, filterBy: $filterBy) {
|
||||
nodes { id status severity createdAt type entitySnapshot { name type } }
|
||||
pageInfo { hasNextPage endCursor }
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(cfg, token, inputs):
|
||||
status = inputs.get("status")
|
||||
severity = inputs.get("severity")
|
||||
first = inputs.get("first")
|
||||
|
||||
filter_by = {}
|
||||
if status:
|
||||
filter_by["status"] = [status]
|
||||
if severity:
|
||||
filter_by["severity"] = [severity]
|
||||
|
||||
variables = {"first": int(first or 20), "filterBy": filter_by}
|
||||
return graphql(cfg, token, QUERY, variables)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,81 @@
|
||||
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 _token(cfg):
|
||||
auth_url = str(cfg.get("auth_url") or "https://auth.app.wiz.io/oauth/token")
|
||||
form = urllib.parse.urlencode({
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": str(cfg.get("client_id", "")),
|
||||
"client_secret": str(cfg.get("client_secret", "")),
|
||||
"audience": "wiz-api",
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(auth_url, data=form,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("access_token"):
|
||||
raise Exception("Token request failed: " + json.dumps(tok))
|
||||
return tok["access_token"]
|
||||
|
||||
|
||||
def graphql(cfg, token, query, variables):
|
||||
body = json.dumps({"query": query, "variables": variables}).encode("utf-8")
|
||||
req = urllib.request.Request(str(cfg.get("api_url", "")), data=body, headers={
|
||||
"Authorization": "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=90) as r:
|
||||
raw = r.read()
|
||||
resp = json.loads(raw) if raw else {}
|
||||
if resp.get("errors"):
|
||||
raise Exception("GraphQL error: " + json.dumps(resp["errors"]))
|
||||
return resp.get("data", resp)
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _token(cfg)
|
||||
print(json.dumps(fn(cfg, 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)
|
||||
|
||||
|
||||
QUERY = """
|
||||
query Vulns($first: Int, $filterBy: VulnerabilityFindingFilters) {
|
||||
vulnerabilityFindings(first: $first, filterBy: $filterBy) {
|
||||
nodes { id name severity cvssSeverity vendorSeverity firstDetectedAt }
|
||||
pageInfo { hasNextPage endCursor }
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(cfg, token, inputs):
|
||||
severity = inputs.get("severity")
|
||||
first = inputs.get("first")
|
||||
|
||||
filter_by = {}
|
||||
if severity:
|
||||
filter_by["severity"] = [severity]
|
||||
|
||||
variables = {"first": int(first or 20), "filterBy": filter_by}
|
||||
return graphql(cfg, token, QUERY, variables)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,69 @@
|
||||
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 _token(cfg):
|
||||
auth_url = str(cfg.get("auth_url") or "https://auth.app.wiz.io/oauth/token")
|
||||
form = urllib.parse.urlencode({
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": str(cfg.get("client_id", "")),
|
||||
"client_secret": str(cfg.get("client_secret", "")),
|
||||
"audience": "wiz-api",
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(auth_url, data=form,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("access_token"):
|
||||
raise Exception("Token request failed: " + json.dumps(tok))
|
||||
return tok["access_token"]
|
||||
|
||||
|
||||
def graphql(cfg, token, query, variables):
|
||||
body = json.dumps({"query": query, "variables": variables}).encode("utf-8")
|
||||
req = urllib.request.Request(str(cfg.get("api_url", "")), data=body, headers={
|
||||
"Authorization": "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=90) as r:
|
||||
raw = r.read()
|
||||
resp = json.loads(raw) if raw else {}
|
||||
if resp.get("errors"):
|
||||
raise Exception("GraphQL error: " + json.dumps(resp["errors"]))
|
||||
return resp.get("data", resp)
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _token(cfg)
|
||||
print(json.dumps(fn(cfg, 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)
|
||||
|
||||
|
||||
QUERY = """
|
||||
query { issues(first: 1) { nodes { id } } }
|
||||
"""
|
||||
|
||||
|
||||
def main(cfg, token, inputs):
|
||||
graphql(cfg, token, QUERY, {})
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,84 @@
|
||||
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 _token(cfg):
|
||||
auth_url = str(cfg.get("auth_url") or "https://auth.app.wiz.io/oauth/token")
|
||||
form = urllib.parse.urlencode({
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": str(cfg.get("client_id", "")),
|
||||
"client_secret": str(cfg.get("client_secret", "")),
|
||||
"audience": "wiz-api",
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(auth_url, data=form,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
tok = json.loads(r.read())
|
||||
if not tok.get("access_token"):
|
||||
raise Exception("Token request failed: " + json.dumps(tok))
|
||||
return tok["access_token"]
|
||||
|
||||
|
||||
def graphql(cfg, token, query, variables):
|
||||
body = json.dumps({"query": query, "variables": variables}).encode("utf-8")
|
||||
req = urllib.request.Request(str(cfg.get("api_url", "")), data=body, headers={
|
||||
"Authorization": "Bearer " + token,
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=90) as r:
|
||||
raw = r.read()
|
||||
resp = json.loads(raw) if raw else {}
|
||||
if resp.get("errors"):
|
||||
raise Exception("GraphQL error: " + json.dumps(resp["errors"]))
|
||||
return resp.get("data", resp)
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
cfg = _cfg()
|
||||
inputs = _inputs()
|
||||
token = _token(cfg)
|
||||
print(json.dumps(fn(cfg, 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)
|
||||
|
||||
|
||||
QUERY = """
|
||||
mutation UpdateIssue($input: UpdateIssueInput!) {
|
||||
updateIssue(input: $input) { issue { id status } }
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(cfg, token, inputs):
|
||||
issue_id = inputs.get("issue_id")
|
||||
status = inputs.get("status")
|
||||
note = inputs.get("note")
|
||||
if not issue_id:
|
||||
raise Exception("issue_id is required")
|
||||
if not status:
|
||||
raise Exception("status is required")
|
||||
|
||||
patch = {"status": status}
|
||||
if note:
|
||||
patch["note"] = note
|
||||
|
||||
input_obj = {"id": issue_id, "patch": patch}
|
||||
variables = {"input": input_obj}
|
||||
return graphql(cfg, token, QUERY, variables)
|
||||
|
||||
|
||||
_run(main)
|
||||
Reference in New Issue
Block a user