feat(proofpoint-tap): new Proofpoint TAP email-threat integration
TAP SIEM API v2, 11 commands: SIEM events (all/messages/clicks blocked+delivered+ permitted), threat/campaign forensics, campaign get/list, URL Defense decode, top clickers. HTTP Basic (service principal) auth, stdlib-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
id: proofpoint_tap
|
||||
name: Proofpoint TAP
|
||||
version: 1.0.0
|
||||
description: "Proofpoint Targeted Attack Protection (TAP SIEM API v2) — email threat detection and forensics: pull blocked/delivered message and click events, get threat/campaign forensics, list campaigns, decode URL Defense links, and read top clickers. Service-principal (HTTP Basic) authentication; stdlib-only, no extra Python dependencies."
|
||||
changelog: "1.0.0 — Initial release: SIEM events (all/messages/clicks), forensics, campaign get/list, URL decode, top clickers."
|
||||
category: email
|
||||
|
||||
# Per-instance configuration. The service principal + secret authenticate via
|
||||
# HTTP Basic against the TAP API.
|
||||
config_schema:
|
||||
properties:
|
||||
url:
|
||||
type: string
|
||||
description: "TAP API base URL"
|
||||
default: "https://tap-api-v2.proofpoint.com"
|
||||
service_principal:
|
||||
type: string
|
||||
description: "TAP service principal"
|
||||
secret:
|
||||
type: string
|
||||
description: "TAP secret"
|
||||
x-soar-sensitive: true
|
||||
required:
|
||||
- service_principal
|
||||
- secret
|
||||
|
||||
commands:
|
||||
- id: get_events
|
||||
name: proofpoint-get-events
|
||||
description: "Get all TAP events (messages and clicks, blocked and permitted) in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
since_seconds: { type: number, description: "Look-back window in seconds, 60-3600 (default 3600)" }
|
||||
interval: { type: string, description: "Optional ISO-8601 interval (overrides since_seconds), e.g. 2024-01-01T00:00:00Z/2024-01-01T01:00:00Z" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: messages_blocked
|
||||
name: proofpoint-messages-blocked
|
||||
description: "Get messages blocked in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
since_seconds: { type: number, description: "Look-back window in seconds, 60-3600 (default 3600)" }
|
||||
interval: { type: string, description: "Optional ISO-8601 interval" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: messages_delivered
|
||||
name: proofpoint-messages-delivered
|
||||
description: "Get messages delivered (with threats) in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
since_seconds: { type: number, description: "Look-back window in seconds, 60-3600 (default 3600)" }
|
||||
interval: { type: string, description: "Optional ISO-8601 interval" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: clicks_blocked
|
||||
name: proofpoint-clicks-blocked
|
||||
description: "Get clicks to malicious URLs blocked in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
since_seconds: { type: number, description: "Look-back window in seconds, 60-3600 (default 3600)" }
|
||||
interval: { type: string, description: "Optional ISO-8601 interval" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: clicks_permitted
|
||||
name: proofpoint-clicks-permitted
|
||||
description: "Get clicks to malicious URLs permitted in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
since_seconds: { type: number, description: "Look-back window in seconds, 60-3600 (default 3600)" }
|
||||
interval: { type: string, description: "Optional ISO-8601 interval" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_forensics
|
||||
name: proofpoint-get-forensics
|
||||
description: "Get forensic evidence for a threat or campaign."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
threat_id: { type: string, description: "Threat ID (provide this or campaign_id)" }
|
||||
campaign_id: { type: string, description: "Campaign ID (provide this or threat_id)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
- id: get_campaign
|
||||
name: proofpoint-get-campaign
|
||||
description: "Get details for a single campaign."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
campaign_id: { type: string, description: "Campaign ID" }
|
||||
required: [campaign_id]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: list_campaigns
|
||||
name: proofpoint-list-campaigns
|
||||
description: "List campaign IDs active in a time window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
interval: { type: string, description: "ISO-8601 interval (e.g. 2024-01-01T00:00:00Z/2024-01-02T00:00:00Z)" }
|
||||
size: { type: number, description: "Page size (default 100)" }
|
||||
page: { type: number, description: "Page number (default 1)" }
|
||||
required: [interval]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: url_decode
|
||||
name: proofpoint-url-decode
|
||||
description: "Decode Proofpoint URL Defense rewritten URLs back to their original form."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
urls: { type: string, description: "Comma-separated rewritten URLs to decode" }
|
||||
required: [urls]
|
||||
outputs_schema: { properties: {} }
|
||||
- id: top_clickers
|
||||
name: proofpoint-top-clickers
|
||||
description: "Get the users who clicked the most malicious URLs in a window."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties:
|
||||
window: { type: number, description: "Look-back window in days: 14, 30, or 90 (default 30)" }
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
|
||||
- id: test_connection
|
||||
name: proofpoint-test-connection
|
||||
description: "Verify connectivity and credentials (used by the Test button)."
|
||||
risk: read
|
||||
inputs_schema:
|
||||
properties: {}
|
||||
required: []
|
||||
outputs_schema: { properties: {} }
|
||||
@@ -0,0 +1,65 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _time_params(inputs):
|
||||
interval = inputs.get("interval")
|
||||
if interval:
|
||||
return {"format": "json", "interval": interval}
|
||||
since_seconds = inputs.get("since_seconds")
|
||||
try:
|
||||
since = int(since_seconds) if since_seconds not in (None, "") else 3600
|
||||
except Exception:
|
||||
since = 3600
|
||||
since = max(60, min(3600, since))
|
||||
return {"format": "json", "sinceSeconds": since}
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/siem/clicks/blocked", cfg, params=_time_params(inputs))
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,65 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _time_params(inputs):
|
||||
interval = inputs.get("interval")
|
||||
if interval:
|
||||
return {"format": "json", "interval": interval}
|
||||
since_seconds = inputs.get("since_seconds")
|
||||
try:
|
||||
since = int(since_seconds) if since_seconds not in (None, "") else 3600
|
||||
except Exception:
|
||||
since = 3600
|
||||
since = max(60, min(3600, since))
|
||||
return {"format": "json", "sinceSeconds": since}
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/siem/clicks/permitted", cfg, params=_time_params(inputs))
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,56 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
campaign_id = inputs.get("campaign_id")
|
||||
if not campaign_id:
|
||||
raise Exception("campaign_id is required")
|
||||
path = "/campaign/" + urllib.parse.quote(str(campaign_id), safe="")
|
||||
return request("GET", path, cfg)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,65 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _time_params(inputs):
|
||||
interval = inputs.get("interval")
|
||||
if interval:
|
||||
return {"format": "json", "interval": interval}
|
||||
since_seconds = inputs.get("since_seconds")
|
||||
try:
|
||||
since = int(since_seconds) if since_seconds not in (None, "") else 3600
|
||||
except Exception:
|
||||
since = 3600
|
||||
since = max(60, min(3600, since))
|
||||
return {"format": "json", "sinceSeconds": since}
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/siem/all", cfg, params=_time_params(inputs))
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,60 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
threat_id = inputs.get("threat_id")
|
||||
campaign_id = inputs.get("campaign_id")
|
||||
if not threat_id and not campaign_id:
|
||||
raise Exception("threat_id or campaign_id is required")
|
||||
if threat_id:
|
||||
params = {"threatId": threat_id}
|
||||
else:
|
||||
params = {"campaignId": campaign_id}
|
||||
return request("GET", "/forensics", cfg, params=params)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,66 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
interval = inputs.get("interval")
|
||||
if not interval:
|
||||
raise Exception("interval is required")
|
||||
size = inputs.get("size")
|
||||
page = inputs.get("page")
|
||||
try:
|
||||
size = int(size) if size not in (None, "") else 100
|
||||
except Exception:
|
||||
size = 100
|
||||
try:
|
||||
page = int(page) if page not in (None, "") else 1
|
||||
except Exception:
|
||||
page = 1
|
||||
params = {"interval": interval, "size": size, "page": page}
|
||||
return request("GET", "/campaign/ids", cfg, params=params)
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,65 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _time_params(inputs):
|
||||
interval = inputs.get("interval")
|
||||
if interval:
|
||||
return {"format": "json", "interval": interval}
|
||||
since_seconds = inputs.get("since_seconds")
|
||||
try:
|
||||
since = int(since_seconds) if since_seconds not in (None, "") else 3600
|
||||
except Exception:
|
||||
since = 3600
|
||||
since = max(60, min(3600, since))
|
||||
return {"format": "json", "sinceSeconds": since}
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/siem/messages/blocked", cfg, params=_time_params(inputs))
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,65 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def _time_params(inputs):
|
||||
interval = inputs.get("interval")
|
||||
if interval:
|
||||
return {"format": "json", "interval": interval}
|
||||
since_seconds = inputs.get("since_seconds")
|
||||
try:
|
||||
since = int(since_seconds) if since_seconds not in (None, "") else 3600
|
||||
except Exception:
|
||||
since = 3600
|
||||
since = max(60, min(3600, since))
|
||||
return {"format": "json", "sinceSeconds": since}
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
return request("GET", "/siem/messages/delivered", cfg, params=_time_params(inputs))
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,53 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
request("GET", "/siem/all", cfg, params={"format": "json", "sinceSeconds": 3600})
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,57 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
window = inputs.get("window")
|
||||
try:
|
||||
window = int(window) if window not in (None, "") else 30
|
||||
except Exception:
|
||||
window = 30
|
||||
return request("GET", "/people/top-clickers", cfg, params={"window": window})
|
||||
|
||||
|
||||
_run(main)
|
||||
@@ -0,0 +1,58 @@
|
||||
import json, os, sys, base64, urllib.parse, urllib.request, urllib.error
|
||||
|
||||
|
||||
def _cfg():
|
||||
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
|
||||
|
||||
|
||||
def _inputs():
|
||||
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
|
||||
|
||||
|
||||
def _base(cfg):
|
||||
return (str(cfg.get("url") or "https://tap-api-v2.proofpoint.com")).rstrip("/") + "/v2"
|
||||
|
||||
|
||||
def _auth_header(cfg):
|
||||
raw = str(cfg.get("service_principal", "")) + ":" + str(cfg.get("secret", ""))
|
||||
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def request(method, path, cfg, 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 = {"Authorization": _auth_header(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=90) as r:
|
||||
raw = r.read()
|
||||
return json.loads(raw) if raw else {}
|
||||
|
||||
|
||||
def _run(fn):
|
||||
try:
|
||||
print(json.dumps(fn(_cfg(), _inputs())))
|
||||
except urllib.error.HTTPError as e:
|
||||
print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")}))
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(json.dumps({"error": str(e)}))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(cfg, inputs):
|
||||
urls = inputs.get("urls")
|
||||
if not urls:
|
||||
raise Exception("urls is required")
|
||||
urls_list = [u.strip() for u in str(urls).split(",") if u.strip()]
|
||||
if not urls_list:
|
||||
raise Exception("urls is required")
|
||||
return request("POST", "/url/decode", cfg, body={"urls": urls_list})
|
||||
|
||||
|
||||
_run(main)
|
||||
Reference in New Issue
Block a user