Compare commits
3 Commits
16fe51ee99
...
3c282e8e53
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c282e8e53 | |||
| 771c90ef0d | |||
| 9fb5b65e4a |
@@ -0,0 +1,83 @@
|
||||
id: f5_bigip
|
||||
name: F5 BIG-IP
|
||||
version: 1.0.0
|
||||
description: "F5 BIG-IP (iControl REST) — application-delivery visibility and containment: list virtual servers and pools, read pool members, disable a pool member, and add an IP to an internal data-group (block list). HTTP Basic authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: list virtual servers/pools, get pool members, disable pool member, add data-group record."
|
||||
category: network
|
||||
|
||||
# Per-instance configuration. HTTP Basic auth against the iControl REST API.
|
||||
config_schema:
|
||||
properties:
|
||||
base_url:
|
||||
type: string
|
||||
description: "BIG-IP management URL (e.g. https://bigip.example.com)"
|
||||
username:
|
||||
type: string
|
||||
description: "Admin username"
|
||||
password:
|
||||
type: string
|
||||
description: "Admin password"
|
||||
x-soar-sensitive: true
|
||||
insecure:
|
||||
type: boolean
|
||||
description: "Trust any TLS certificate (not secure)"
|
||||
default: false
|
||||
required:
|
||||
- base_url
|
||||
- username
|
||||
- password
|
||||
|
||||
commands:
|
||||
- id: list_virtual_servers
|
||||
name: f5-list-virtual-servers
|
||||
description: "List virtual servers."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_pools
|
||||
name: f5-list-pools
|
||||
description: "List load-balancing pools."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_pool_members
|
||||
name: f5-get-pool-members
|
||||
description: "List a pool's members."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
pool_name: { type: string, description: "Pool name (partition path, e.g. ~Common~web_pool)" }
|
||||
required: [pool_name]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: disable_pool_member
|
||||
name: f5-disable-pool-member
|
||||
description: "Disable a pool member (drains it — containment)."
|
||||
inputs_schema:
|
||||
properties:
|
||||
pool_name: { type: string, description: "Pool name (partition path)" }
|
||||
member_name: { type: string, description: "Member name (e.g. ~Common~10.0.0.5:80)" }
|
||||
required: [pool_name, member_name]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: add_datagroup_record
|
||||
name: f5-add-datagroup-record
|
||||
description: "Add a record (e.g. an IP) to an internal data-group used by a block iRule."
|
||||
inputs_schema:
|
||||
properties:
|
||||
datagroup_name: { type: string, description: "Internal data-group name (partition path)" }
|
||||
record_name: { type: string, description: "Record key (e.g. an IP or CIDR)" }
|
||||
record_data: { type: string, description: "Optional record value" }
|
||||
required: [datagroup_name, record_name]
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: f5-test-connection
|
||||
description: "Verify connectivity and credentials (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,72 @@
|
||||
import json, os, sys, base64, 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 _auth(cfg):
|
||||
raw = str(cfg.get("username", "")) + ":" + str(cfg.get("password", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + "/mgmt/tm" + 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": _auth(cfg), "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)
|
||||
|
||||
|
||||
qn = lambda v: urllib.parse.quote(str(v), safe="~")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
datagroup_name = inputs.get("datagroup_name")
|
||||
if not datagroup_name:
|
||||
raise Exception("datagroup_name is required")
|
||||
record_name = inputs.get("record_name")
|
||||
if not record_name:
|
||||
raise Exception("record_name is required")
|
||||
record_data = inputs.get("record_data")
|
||||
return request(
|
||||
"PATCH",
|
||||
"/ltm/data-group/internal/" + qn(datagroup_name),
|
||||
cfg,
|
||||
body={"records": [{"name": record_name, "data": (record_data or "")}]},
|
||||
)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,71 @@
|
||||
import json, os, sys, base64, 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 _auth(cfg):
|
||||
raw = str(cfg.get("username", "")) + ":" + str(cfg.get("password", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + "/mgmt/tm" + 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": _auth(cfg), "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)
|
||||
|
||||
|
||||
qn = lambda v: urllib.parse.quote(str(v), safe="~")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
pool_name = inputs.get("pool_name")
|
||||
if not pool_name:
|
||||
raise Exception("pool_name is required")
|
||||
member_name = inputs.get("member_name")
|
||||
if not member_name:
|
||||
raise Exception("member_name is required")
|
||||
return request(
|
||||
"PATCH",
|
||||
"/ltm/pool/" + qn(pool_name) + "/members/" + qn(member_name),
|
||||
cfg,
|
||||
body={"session": "user-disabled", "state": "user-down"},
|
||||
)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,63 @@
|
||||
import json, os, sys, base64, 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 _auth(cfg):
|
||||
raw = str(cfg.get("username", "")) + ":" + str(cfg.get("password", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + "/mgmt/tm" + 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": _auth(cfg), "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)
|
||||
|
||||
|
||||
qn = lambda v: urllib.parse.quote(str(v), safe="~")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
pool_name = inputs.get("pool_name")
|
||||
if not pool_name:
|
||||
raise Exception("pool_name is required")
|
||||
return request("GET", "/ltm/pool/" + qn(pool_name) + "/members", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,60 @@
|
||||
import json, os, sys, base64, 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 _auth(cfg):
|
||||
raw = str(cfg.get("username", "")) + ":" + str(cfg.get("password", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + "/mgmt/tm" + 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": _auth(cfg), "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)
|
||||
|
||||
|
||||
qn = lambda v: urllib.parse.quote(str(v), safe="~")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/ltm/pool", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,60 @@
|
||||
import json, os, sys, base64, 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 _auth(cfg):
|
||||
raw = str(cfg.get("username", "")) + ":" + str(cfg.get("password", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + "/mgmt/tm" + 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": _auth(cfg), "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)
|
||||
|
||||
|
||||
qn = lambda v: urllib.parse.quote(str(v), safe="~")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/ltm/virtual", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,61 @@
|
||||
import json, os, sys, base64, 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 _auth(cfg):
|
||||
raw = str(cfg.get("username", "")) + ":" + str(cfg.get("password", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = str(cfg.get("base_url", "")).rstrip("/") + "/mgmt/tm" + 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": _auth(cfg), "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)
|
||||
|
||||
|
||||
qn = lambda v: urllib.parse.quote(str(v), safe="~")
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
request("GET", "/sys/version", cfg)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,66 @@
|
||||
id: imperva
|
||||
name: Imperva Cloud WAF
|
||||
version: 1.0.0
|
||||
description: "Imperva Cloud WAF (Cloud Application Security API v1) — edge containment: list sites, read a site's status, block/unblock IPs via the site ACL, and set a security setting. API-ID/API-key authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: list sites, get site status, configure ACL (block IPs), configure security setting."
|
||||
category: network
|
||||
|
||||
# Per-instance configuration. api_id + api_key are sent as form parameters.
|
||||
config_schema:
|
||||
properties:
|
||||
api_id:
|
||||
type: string
|
||||
description: "Imperva API ID"
|
||||
api_key:
|
||||
type: string
|
||||
description: "Imperva API key"
|
||||
x-soar-sensitive: true
|
||||
required:
|
||||
- api_id
|
||||
- api_key
|
||||
|
||||
commands:
|
||||
- id: list_sites
|
||||
name: imperva-list-sites
|
||||
description: "List sites in the account."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_site_status
|
||||
name: imperva-get-site-status
|
||||
description: "Get a site's status and configuration."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
site_id: { type: string, description: "Site ID" }
|
||||
required: [site_id]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: block_ips
|
||||
name: imperva-block-ips
|
||||
description: "Set the site's blacklisted-IPs ACL (replaces the current list)."
|
||||
inputs_schema:
|
||||
properties:
|
||||
site_id: { type: string, description: "Site ID" }
|
||||
ips: { type: string, description: "Comma-separated IPs/subnets to blacklist" }
|
||||
required: [site_id, ips]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: whitelist_ips
|
||||
name: imperva-whitelist-ips
|
||||
description: "Set the site's whitelisted-IPs ACL (replaces the current list)."
|
||||
inputs_schema:
|
||||
properties:
|
||||
site_id: { type: string, description: "Site ID" }
|
||||
ips: { type: string, description: "Comma-separated IPs/subnets to whitelist" }
|
||||
required: [site_id, ips]
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: imperva-test-connection
|
||||
description: "Verify the API credentials (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,52 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://my.imperva.com/api/prov/v1"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def post(path, cfg, fields=None):
|
||||
body = {"api_id": str(cfg.get("api_id", "")), "api_key": str(cfg.get("api_key", ""))}
|
||||
if fields:
|
||||
body.update({k: v for k, v in fields.items() if v not in (None, "")})
|
||||
data = urllib.parse.urlencode(body).encode("utf-8")
|
||||
req = urllib.request.Request(BASE + path, data=data,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
site_id = inputs.get("site_id")
|
||||
if not site_id:
|
||||
raise Exception("site_id is required")
|
||||
ips = inputs.get("ips")
|
||||
if not ips:
|
||||
raise Exception("ips is required")
|
||||
return post("/sites/configure/acl", cfg, {
|
||||
"site_id": site_id,
|
||||
"rule_id": "api.acl.blacklisted_ips",
|
||||
"ips": ips,
|
||||
})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,45 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://my.imperva.com/api/prov/v1"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def post(path, cfg, fields=None):
|
||||
body = {"api_id": str(cfg.get("api_id", "")), "api_key": str(cfg.get("api_key", ""))}
|
||||
if fields:
|
||||
body.update({k: v for k, v in fields.items() if v not in (None, "")})
|
||||
data = urllib.parse.urlencode(body).encode("utf-8")
|
||||
req = urllib.request.Request(BASE + path, data=data,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
site_id = inputs.get("site_id")
|
||||
if not site_id:
|
||||
raise Exception("site_id is required")
|
||||
return post("/sites/status", cfg, {"site_id": site_id})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,42 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://my.imperva.com/api/prov/v1"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def post(path, cfg, fields=None):
|
||||
body = {"api_id": str(cfg.get("api_id", "")), "api_key": str(cfg.get("api_key", ""))}
|
||||
if fields:
|
||||
body.update({k: v for k, v in fields.items() if v not in (None, "")})
|
||||
data = urllib.parse.urlencode(body).encode("utf-8")
|
||||
req = urllib.request.Request(BASE + path, data=data,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return post("/sites/list", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,43 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://my.imperva.com/api/prov/v1"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def post(path, cfg, fields=None):
|
||||
body = {"api_id": str(cfg.get("api_id", "")), "api_key": str(cfg.get("api_key", ""))}
|
||||
if fields:
|
||||
body.update({k: v for k, v in fields.items() if v not in (None, "")})
|
||||
data = urllib.parse.urlencode(body).encode("utf-8")
|
||||
req = urllib.request.Request(BASE + path, data=data,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
post("/sites/list", cfg)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,52 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://my.imperva.com/api/prov/v1"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def post(path, cfg, fields=None):
|
||||
body = {"api_id": str(cfg.get("api_id", "")), "api_key": str(cfg.get("api_key", ""))}
|
||||
if fields:
|
||||
body.update({k: v for k, v in fields.items() if v not in (None, "")})
|
||||
data = urllib.parse.urlencode(body).encode("utf-8")
|
||||
req = urllib.request.Request(BASE + path, data=data,
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Accept": "application/json"}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
site_id = inputs.get("site_id")
|
||||
if not site_id:
|
||||
raise Exception("site_id is required")
|
||||
ips = inputs.get("ips")
|
||||
if not ips:
|
||||
raise Exception("ips is required")
|
||||
return post("/sites/configure/acl", cfg, {
|
||||
"site_id": site_id,
|
||||
"rule_id": "api.acl.whitelisted_ips",
|
||||
"ips": ips,
|
||||
})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,72 @@
|
||||
id: signalsciences
|
||||
name: Signal Sciences
|
||||
version: 1.0.0
|
||||
description: "Signal Sciences (Fastly NGWAF, API v0) — web-attack visibility and containment: list sites, read suspicious IPs and events, and add an IP to a site list (block). API-token authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: list sites, get suspicious IPs, list events, add IP to list."
|
||||
category: network
|
||||
|
||||
# Per-instance configuration. Auth headers 'x-api-user' (email) and 'x-api-token'.
|
||||
config_schema:
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
description: "API user email"
|
||||
api_token:
|
||||
type: string
|
||||
description: "API token"
|
||||
x-soar-sensitive: true
|
||||
corp_name:
|
||||
type: string
|
||||
description: "Corp (organization) short name"
|
||||
required:
|
||||
- email
|
||||
- api_token
|
||||
- corp_name
|
||||
|
||||
commands:
|
||||
- id: list_sites
|
||||
name: sigsci-list-sites
|
||||
description: "List sites in the corp."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_suspicious_ips
|
||||
name: sigsci-get-suspicious-ips
|
||||
description: "List a site's suspicious IPs."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
site_name: { type: string, description: "Site short name" }
|
||||
required: [site_name]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_events
|
||||
name: sigsci-list-events
|
||||
description: "List a site's flagged-IP events."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
site_name: { type: string, description: "Site short name" }
|
||||
limit: { type: number, description: "Max events (default 50)" }
|
||||
required: [site_name]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: add_ip_to_list
|
||||
name: sigsci-add-ip-to-list
|
||||
description: "Add an IP to a site custom list (e.g. a block list)."
|
||||
inputs_schema:
|
||||
properties:
|
||||
site_name: { type: string, description: "Site short name" }
|
||||
list_id: { type: string, description: "Custom list ID" }
|
||||
ip: { type: string, description: "IP or CIDR to add" }
|
||||
required: [site_name, list_id, ip]
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: sigsci-test-connection
|
||||
description: "Verify the API token (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,70 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://dashboard.signalsciences.net/api/v0"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _corp(cfg):
|
||||
return "/corps/" + urllib.parse.quote(str(cfg.get("corp_name", "")), safe="")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = BASE + path
|
||||
if params:
|
||||
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||
if clean:
|
||||
url += "?" + urllib.parse.urlencode(clean)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {
|
||||
"x-api-user": str(cfg.get("email", "")),
|
||||
"x-api-token": str(cfg.get("api_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) 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):
|
||||
site_name = inputs.get("site_name")
|
||||
if not site_name:
|
||||
raise Exception("site_name is required")
|
||||
list_id = inputs.get("list_id")
|
||||
if not list_id:
|
||||
raise Exception("list_id is required")
|
||||
ip = inputs.get("ip")
|
||||
if not ip:
|
||||
raise Exception("ip is required")
|
||||
return request(
|
||||
"PATCH",
|
||||
_corp(cfg) + "/sites/" + q(site_name) + "/lists/" + q(list_id),
|
||||
cfg,
|
||||
body={"entries": {"additions": [ip], "deletions": []}},
|
||||
)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,59 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://dashboard.signalsciences.net/api/v0"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _corp(cfg):
|
||||
return "/corps/" + urllib.parse.quote(str(cfg.get("corp_name", "")), safe="")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = BASE + path
|
||||
if params:
|
||||
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||
if clean:
|
||||
url += "?" + urllib.parse.urlencode(clean)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {
|
||||
"x-api-user": str(cfg.get("email", "")),
|
||||
"x-api-token": str(cfg.get("api_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) 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):
|
||||
site_name = inputs.get("site_name")
|
||||
if not site_name:
|
||||
raise Exception("site_name is required")
|
||||
return request("GET", _corp(cfg) + "/sites/" + q(site_name) + "/suspiciousIPs", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,65 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://dashboard.signalsciences.net/api/v0"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _corp(cfg):
|
||||
return "/corps/" + urllib.parse.quote(str(cfg.get("corp_name", "")), safe="")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = BASE + path
|
||||
if params:
|
||||
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||
if clean:
|
||||
url += "?" + urllib.parse.urlencode(clean)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {
|
||||
"x-api-user": str(cfg.get("email", "")),
|
||||
"x-api-token": str(cfg.get("api_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) 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):
|
||||
site_name = inputs.get("site_name")
|
||||
if not site_name:
|
||||
raise Exception("site_name is required")
|
||||
limit = inputs.get("limit")
|
||||
return request(
|
||||
"GET",
|
||||
_corp(cfg) + "/sites/" + q(site_name) + "/events",
|
||||
cfg,
|
||||
params={"limit": int(limit or 50)},
|
||||
)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,53 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://dashboard.signalsciences.net/api/v0"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _corp(cfg):
|
||||
return "/corps/" + urllib.parse.quote(str(cfg.get("corp_name", "")), safe="")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = BASE + path
|
||||
if params:
|
||||
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||
if clean:
|
||||
url += "?" + urllib.parse.urlencode(clean)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {
|
||||
"x-api-user": str(cfg.get("email", "")),
|
||||
"x-api-token": str(cfg.get("api_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) 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", _corp(cfg) + "/sites", cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,54 @@
|
||||
import json, os, sys, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
BASE = "https://dashboard.signalsciences.net/api/v0"
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _corp(cfg):
|
||||
return "/corps/" + urllib.parse.quote(str(cfg.get("corp_name", "")), safe="")
|
||||
|
||||
|
||||
def request(method, path, cfg, body=None, params=None):
|
||||
url = BASE + path
|
||||
if params:
|
||||
clean = {k: v for k, v in params.items() if v not in (None, "")}
|
||||
if clean:
|
||||
url += "?" + urllib.parse.urlencode(clean)
|
||||
data = json.dumps(body).encode("utf-8") if body is not None else None
|
||||
headers = {
|
||||
"x-api-user": str(cfg.get("email", "")),
|
||||
"x-api-token": str(cfg.get("api_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) 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", _corp(cfg) + "/sites", cfg)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
Reference in New Issue
Block a user