diff --git a/integrations/pulsedive/manifest.yaml b/integrations/pulsedive/manifest.yaml new file mode 100644 index 0000000..fd81924 --- /dev/null +++ b/integrations/pulsedive/manifest.yaml @@ -0,0 +1,53 @@ +id: pulsedive +name: Pulsedive +version: 1.0.0 +description: "Pulsedive (API) — reputation and threat context for any indicator (IP, domain, URL or hash), plus on-demand scanning and scan-result retrieval. API-key authentication; stdlib-only, no extra Python dependencies." +changelog: "1.0.0 — Initial release: indicator lookup, scan submission and scan-result retrieval." +category: enrichment + +config_schema: + properties: + api_key: + type: string + description: "Pulsedive API key" + x-soar-sensitive: true + required: + - api_key + +commands: + - id: lookup_indicator + name: pulsedive-lookup-indicator + description: "Look up the reputation and threat context of an indicator (IP, domain, URL or hash)." + risk: read + inputs_schema: + properties: + indicator: { type: string, description: "Indicator value (IP, domain, URL or hash)" } + required: [indicator] + outputs_schema: { properties: {} } + - id: scan + name: pulsedive-scan + description: "Submit an indicator for an on-demand scan. Returns a qid; retrieve the report with pulsedive-scan-result once it finishes." + inputs_schema: + properties: + value: { type: string, description: "Indicator to scan (IP, domain or URL)" } + probe: { type: boolean, description: "Actively probe the indicator (default true)" } + required: [value] + outputs_schema: { properties: {} } + - id: scan_result + name: pulsedive-scan-result + description: "Retrieve the result of a scan by its qid." + risk: read + inputs_schema: + properties: + qid: { type: string, description: "Scan qid (from pulsedive-scan)" } + required: [qid] + outputs_schema: { properties: {} } + + - id: test_connection + name: pulsedive-test-connection + description: "Verify the API key (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/pulsedive/scripts/lookup_indicator.py b/integrations/pulsedive/scripts/lookup_indicator.py new file mode 100644 index 0000000..4a25ca2 --- /dev/null +++ b/integrations/pulsedive/scripts/lookup_indicator.py @@ -0,0 +1,43 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://pulsedive.com/api" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def request(method, path, params=None, body=None): + p = dict(params or {}) + p["key"] = str(_cfg().get("api_key") or "") + url = API + path + "?" + urllib.parse.urlencode({k: str(v) for k, v in p.items() if v not in (None, "")}) + data = urllib.parse.urlencode(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/x-www-form-urlencoded" + 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 {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + indicator = inputs.get("indicator") + if not indicator: + raise Exception("indicator is required") + res = request("GET", "/info.php", params={"indicator": indicator, "pretty": "1"}) + print(json.dumps(res)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/pulsedive/scripts/scan.py b/integrations/pulsedive/scripts/scan.py new file mode 100644 index 0000000..f4e11f6 --- /dev/null +++ b/integrations/pulsedive/scripts/scan.py @@ -0,0 +1,44 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://pulsedive.com/api" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def request(method, path, params=None, body=None): + p = dict(params or {}) + p["key"] = str(_cfg().get("api_key") or "") + url = API + path + "?" + urllib.parse.urlencode({k: str(v) for k, v in p.items() if v not in (None, "")}) + data = urllib.parse.urlencode(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/x-www-form-urlencoded" + 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 {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + value = inputs.get("value") + if not value: + raise Exception("value is required") + probe = inputs.get("probe", True) + res = request("POST", "/analyze.php", body={"value": value, "probe": "1" if probe else "0"}) + print(json.dumps(res)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/pulsedive/scripts/scan_result.py b/integrations/pulsedive/scripts/scan_result.py new file mode 100644 index 0000000..bb79c07 --- /dev/null +++ b/integrations/pulsedive/scripts/scan_result.py @@ -0,0 +1,43 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://pulsedive.com/api" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def request(method, path, params=None, body=None): + p = dict(params or {}) + p["key"] = str(_cfg().get("api_key") or "") + url = API + path + "?" + urllib.parse.urlencode({k: str(v) for k, v in p.items() if v not in (None, "")}) + data = urllib.parse.urlencode(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/x-www-form-urlencoded" + 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 {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + inputs = json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + qid = inputs.get("qid") + if not qid: + raise Exception("qid is required") + res = request("GET", "/analyze.php", params={"qid": qid, "pretty": "1"}) + print(json.dumps(res)) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) diff --git a/integrations/pulsedive/scripts/test_connection.py b/integrations/pulsedive/scripts/test_connection.py new file mode 100644 index 0000000..1a442d1 --- /dev/null +++ b/integrations/pulsedive/scripts/test_connection.py @@ -0,0 +1,43 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + +API = "https://pulsedive.com/api" + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def request(method, path, params=None, body=None): + p = dict(params or {}) + p["key"] = str(_cfg().get("api_key") or "") + url = API + path + "?" + urllib.parse.urlencode({k: str(v) for k, v in p.items() if v not in (None, "")}) + data = urllib.parse.urlencode(body).encode("utf-8") if body is not None else None + headers = {"Accept": "application/json"} + if data is not None: + headers["Content-Type"] = "application/x-www-form-urlencoded" + 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 {} + + +q = lambda v: urllib.parse.quote(str(v), safe="") + + +def main(): + res = request("GET", "/info.php", params={"indicator": "8.8.8.8"}) + if not isinstance(res, dict): + raise Exception("unexpected response") + if res.get("error"): + raise Exception(res["error"]) + print(json.dumps({"ok": True})) + + +try: + main() +except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) +except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1)