Compare commits
3 Commits
9cffefbb36
...
ac2203f9a5
| Author | SHA1 | Date | |
|---|---|---|---|
| ac2203f9a5 | |||
| 8248c60da8 | |||
| 4206b44e78 |
@@ -0,0 +1,36 @@
|
|||||||
|
id: feed_cisa_kev
|
||||||
|
name: CISA KEV Feed
|
||||||
|
version: 1.0.0
|
||||||
|
description: "CISA Known Exploited Vulnerabilities (KEV) feed connector — pull the authoritative catalog of CVEs known to be actively exploited in the wild and emit normalized IOCs (CVE + type, with vendor/product/due-date/ransomware flag) for import into the Threat Indicator Manager. Free, no authentication required; stdlib-only, no extra Python dependencies."
|
||||||
|
changelog: "1.0.0 — Initial release: fetch the CISA KEV catalog."
|
||||||
|
category: feed
|
||||||
|
|
||||||
|
# The CISA KEV catalog is a free JSON file served over HTTPS. No key required.
|
||||||
|
config_schema:
|
||||||
|
properties:
|
||||||
|
insecure:
|
||||||
|
type: boolean
|
||||||
|
description: "Trust any TLS certificate (not secure)"
|
||||||
|
default: false
|
||||||
|
required: []
|
||||||
|
|
||||||
|
commands:
|
||||||
|
- id: fetch_indicators
|
||||||
|
name: feed-cisa-kev-fetch-indicators
|
||||||
|
description: "Fetch the CISA KEV catalog and return normalized CVE indicators."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
ransomware_only: { type: boolean, description: "Only return CVEs linked to known ransomware campaigns (default false)" }
|
||||||
|
max_indicators: { type: number, description: "Max indicators to return (0 = no limit, default 0)" }
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
|
||||||
|
- id: test_connection
|
||||||
|
name: feed-cisa-kev-test-connection
|
||||||
|
description: "Verify the CISA KEV feed is reachable (used by the Test button)."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties: {}
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import json, os, sys, ssl, urllib.request, urllib.error
|
||||||
|
|
||||||
|
URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"
|
||||||
|
|
||||||
|
|
||||||
|
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 _get(url, cfg):
|
||||||
|
req = urllib.request.Request(
|
||||||
|
url, headers={"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
|
||||||
|
)
|
||||||
|
with urllib.request.urlopen(req, timeout=120, context=_ctx(cfg)) as r:
|
||||||
|
return r.read()
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
ransomware_only = bool(inputs.get("ransomware_only"))
|
||||||
|
raw = _get(URL, cfg)
|
||||||
|
data = json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
maxn = int(inputs.get("max_indicators") or 0)
|
||||||
|
out = []
|
||||||
|
for v in data.get("vulnerabilities", []):
|
||||||
|
if not isinstance(v, dict):
|
||||||
|
continue
|
||||||
|
cid = v.get("cveID")
|
||||||
|
if not cid:
|
||||||
|
continue
|
||||||
|
ransom = v.get("knownRansomwareCampaignUse")
|
||||||
|
if ransomware_only and str(ransom).lower() != "known":
|
||||||
|
continue
|
||||||
|
out.append({
|
||||||
|
"value": cid,
|
||||||
|
"type": "cve",
|
||||||
|
"vendor": v.get("vendorProject"),
|
||||||
|
"product": v.get("product"),
|
||||||
|
"name": v.get("vulnerabilityName"),
|
||||||
|
"date_added": v.get("dateAdded"),
|
||||||
|
"due_date": v.get("dueDate"),
|
||||||
|
"ransomware": ransom,
|
||||||
|
"tags": ["cisa-kev", "exploited"],
|
||||||
|
})
|
||||||
|
if maxn and len(out) >= maxn:
|
||||||
|
break
|
||||||
|
|
||||||
|
return {
|
||||||
|
"source": "cisa:kev",
|
||||||
|
"count": len(out),
|
||||||
|
"indicators": out,
|
||||||
|
"catalog_version": data.get("catalogVersion"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import json, os, sys, ssl, urllib.request, urllib.error
|
||||||
|
|
||||||
|
URL = "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"
|
||||||
|
|
||||||
|
|
||||||
|
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 _get(url, cfg):
|
||||||
|
req = urllib.request.Request(
|
||||||
|
url, headers={"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
|
||||||
|
)
|
||||||
|
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||||
|
return r.read()
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
raw = _get(URL, cfg)
|
||||||
|
data = json.loads(raw) if raw else {}
|
||||||
|
n = data.get("count") or len(data.get("vulnerabilities", []))
|
||||||
|
return {"ok": True, "sample_count": n, "catalog_version": data.get("catalogVersion")}
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
id: feed_first_epss
|
||||||
|
name: FIRST EPSS Feed
|
||||||
|
version: 1.0.0
|
||||||
|
description: "FIRST EPSS (Exploit Prediction Scoring System) feed connector — pull the CVEs with the highest probability of being exploited in the next 30 days and emit normalized IOCs (CVE + type, with EPSS score and percentile) for import into the Threat Indicator Manager. Free public API, no authentication required; stdlib-only, no extra Python dependencies."
|
||||||
|
changelog: "1.0.0 — Initial release: fetch top-EPSS CVEs from the FIRST EPSS API."
|
||||||
|
category: feed
|
||||||
|
|
||||||
|
# The FIRST EPSS API is free and served over HTTPS. No key required.
|
||||||
|
config_schema:
|
||||||
|
properties:
|
||||||
|
min_epss:
|
||||||
|
type: string
|
||||||
|
description: "Optional: only return CVEs with EPSS score greater than this (0-1, e.g. 0.5)"
|
||||||
|
insecure:
|
||||||
|
type: boolean
|
||||||
|
description: "Trust any TLS certificate (not secure)"
|
||||||
|
default: false
|
||||||
|
required: []
|
||||||
|
|
||||||
|
commands:
|
||||||
|
- id: fetch_indicators
|
||||||
|
name: feed-first-epss-fetch-indicators
|
||||||
|
description: "Fetch top-EPSS CVEs and return normalized indicators."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
min_epss: { type: string, description: "Only CVEs with EPSS > this value (overrides config)" }
|
||||||
|
max_indicators: { type: number, description: "Max indicators to return (default 100, max 1000)" }
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
|
||||||
|
- id: test_connection
|
||||||
|
name: feed-first-epss-test-connection
|
||||||
|
description: "Verify the FIRST EPSS API is reachable (used by the Test button)."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties: {}
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import json, os, sys, ssl, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
BASE = "https://api.first.org/data/v1/epss"
|
||||||
|
|
||||||
|
|
||||||
|
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 _get(url, cfg):
|
||||||
|
req = urllib.request.Request(
|
||||||
|
url, headers={"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
|
||||||
|
)
|
||||||
|
with urllib.request.urlopen(req, timeout=120, context=_ctx(cfg)) as r:
|
||||||
|
return r.read()
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
limit = int(inputs.get("max_indicators") or 0) or 100
|
||||||
|
limit = max(1, min(limit, 1000))
|
||||||
|
min_epss = inputs.get("min_epss") or cfg.get("min_epss")
|
||||||
|
|
||||||
|
params = {"order": "!epss", "limit": limit}
|
||||||
|
if min_epss not in (None, ""):
|
||||||
|
params["epss-gt"] = str(min_epss)
|
||||||
|
|
||||||
|
url = BASE + "?" + urllib.parse.urlencode(params)
|
||||||
|
raw = _get(url, cfg)
|
||||||
|
data = json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
out = []
|
||||||
|
for e in data.get("data", []):
|
||||||
|
if not isinstance(e, dict):
|
||||||
|
continue
|
||||||
|
cve = e.get("cve")
|
||||||
|
if not cve:
|
||||||
|
continue
|
||||||
|
out.append({
|
||||||
|
"value": cve,
|
||||||
|
"type": "cve",
|
||||||
|
"epss": e.get("epss"),
|
||||||
|
"percentile": e.get("percentile"),
|
||||||
|
"date": e.get("date"),
|
||||||
|
})
|
||||||
|
|
||||||
|
return {"source": "first:epss", "count": len(out), "indicators": out}
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import json, os, sys, ssl, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
BASE = "https://api.first.org/data/v1/epss"
|
||||||
|
|
||||||
|
|
||||||
|
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 _get(url, cfg):
|
||||||
|
req = urllib.request.Request(
|
||||||
|
url, headers={"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
|
||||||
|
)
|
||||||
|
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||||
|
return r.read()
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
url = BASE + "?" + urllib.parse.urlencode({"limit": 1})
|
||||||
|
raw = _get(url, cfg)
|
||||||
|
data = json.loads(raw) if raw else {}
|
||||||
|
return {"ok": True, "status": data.get("status"), "total": data.get("total")}
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
id: feed_nvd
|
||||||
|
name: NVD CVE Feed
|
||||||
|
version: 1.0.0
|
||||||
|
description: "NIST National Vulnerability Database (NVD) feed connector — pull recently-published CVEs from the NVD 2.0 API and emit normalized IOCs (CVE + type, with description/CVSS/status) for import into the Threat Indicator Manager. Works without a key; an optional free NVD API key raises the rate limit. Stdlib-only, no extra Python dependencies."
|
||||||
|
changelog: "1.0.0 — Initial release: fetch recent CVEs from the NVD 2.0 API."
|
||||||
|
category: feed
|
||||||
|
|
||||||
|
# The NVD 2.0 API is free. An optional API key (sent as the apiKey header)
|
||||||
|
# raises the request rate limit.
|
||||||
|
config_schema:
|
||||||
|
properties:
|
||||||
|
api_key:
|
||||||
|
type: string
|
||||||
|
description: "Optional NVD API key (free — raises the rate limit)"
|
||||||
|
x-soar-sensitive: true
|
||||||
|
days:
|
||||||
|
type: number
|
||||||
|
description: "Look-back window in days for recently-published CVEs (default 7, max 120)"
|
||||||
|
default: 7
|
||||||
|
insecure:
|
||||||
|
type: boolean
|
||||||
|
description: "Trust any TLS certificate (not secure)"
|
||||||
|
default: false
|
||||||
|
required: []
|
||||||
|
|
||||||
|
commands:
|
||||||
|
- id: fetch_indicators
|
||||||
|
name: feed-nvd-fetch-indicators
|
||||||
|
description: "Fetch recently-published CVEs from NVD and return normalized indicators."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties:
|
||||||
|
days: { type: number, description: "Look-back window in days (overrides config, max 120)" }
|
||||||
|
max_indicators: { type: number, description: "Max indicators to return (0 = API page size 2000, default 0)" }
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
|
|
||||||
|
- id: test_connection
|
||||||
|
name: feed-nvd-test-connection
|
||||||
|
description: "Verify the NVD API is reachable (used by the Test button)."
|
||||||
|
risk: read
|
||||||
|
inputs_schema:
|
||||||
|
properties: {}
|
||||||
|
required: []
|
||||||
|
outputs_schema: { properties: {} }
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
import json, os, sys, ssl, datetime, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
BASE = "https://services.nvd.nist.gov/rest/json/cves/2.0"
|
||||||
|
|
||||||
|
|
||||||
|
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 _headers(cfg):
|
||||||
|
h = {"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
|
||||||
|
k = cfg.get("api_key")
|
||||||
|
if k:
|
||||||
|
h["apiKey"] = str(k)
|
||||||
|
return h
|
||||||
|
|
||||||
|
|
||||||
|
def _get(url, cfg):
|
||||||
|
req = urllib.request.Request(url, headers=_headers(cfg))
|
||||||
|
with urllib.request.urlopen(req, timeout=120, context=_ctx(cfg)) as r:
|
||||||
|
return r.read()
|
||||||
|
|
||||||
|
|
||||||
|
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 _cvss(metrics):
|
||||||
|
for key in ("cvssMetricV31", "cvssMetricV30", "cvssMetricV2"):
|
||||||
|
arr = metrics.get(key)
|
||||||
|
if arr and isinstance(arr, list) and isinstance(arr[0], dict):
|
||||||
|
d = arr[0].get("cvssData", {})
|
||||||
|
return d.get("baseScore"), d.get("baseSeverity") or arr[0].get("baseSeverity")
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
|
def main(cfg, inputs):
|
||||||
|
days = int(inputs.get("days") or cfg.get("days") or 7)
|
||||||
|
days = max(1, min(days, 120))
|
||||||
|
|
||||||
|
end = datetime.datetime.now(datetime.timezone.utc)
|
||||||
|
start = end - datetime.timedelta(days=days)
|
||||||
|
fmt = "%Y-%m-%dT%H:%M:%S.000"
|
||||||
|
|
||||||
|
per = int(inputs.get("max_indicators") or 0) or 2000
|
||||||
|
per = max(1, min(per, 2000))
|
||||||
|
|
||||||
|
params = {
|
||||||
|
"pubStartDate": start.strftime(fmt),
|
||||||
|
"pubEndDate": end.strftime(fmt),
|
||||||
|
"resultsPerPage": per,
|
||||||
|
}
|
||||||
|
url = BASE + "?" + urllib.parse.urlencode(params)
|
||||||
|
raw = _get(url, cfg)
|
||||||
|
data = json.loads(raw) if raw else {}
|
||||||
|
|
||||||
|
maxn = int(inputs.get("max_indicators") or 0)
|
||||||
|
out = []
|
||||||
|
for v in data.get("vulnerabilities", []):
|
||||||
|
cve = v.get("cve", {}) if isinstance(v, dict) else {}
|
||||||
|
cid = cve.get("id")
|
||||||
|
if not cid:
|
||||||
|
continue
|
||||||
|
desc = ""
|
||||||
|
for d in cve.get("descriptions", []):
|
||||||
|
if d.get("lang") == "en":
|
||||||
|
desc = d.get("value")
|
||||||
|
break
|
||||||
|
score, severity = _cvss(cve.get("metrics", {}))
|
||||||
|
out.append({
|
||||||
|
"value": cid,
|
||||||
|
"type": "cve",
|
||||||
|
"description": desc,
|
||||||
|
"cvss": score,
|
||||||
|
"severity": severity,
|
||||||
|
"published": cve.get("published"),
|
||||||
|
"status": cve.get("vulnStatus"),
|
||||||
|
})
|
||||||
|
if maxn and len(out) >= maxn:
|
||||||
|
break
|
||||||
|
|
||||||
|
return {
|
||||||
|
"source": "nvd:recent",
|
||||||
|
"count": len(out),
|
||||||
|
"indicators": out,
|
||||||
|
"total_results": data.get("totalResults"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import json, os, sys, ssl, urllib.parse, urllib.request, urllib.error
|
||||||
|
|
||||||
|
BASE = "https://services.nvd.nist.gov/rest/json/cves/2.0"
|
||||||
|
|
||||||
|
|
||||||
|
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 _headers(cfg):
|
||||||
|
h = {"User-Agent": "Riposte-SOAR", "Accept": "application/json"}
|
||||||
|
k = cfg.get("api_key")
|
||||||
|
if k:
|
||||||
|
h["apiKey"] = str(k)
|
||||||
|
return h
|
||||||
|
|
||||||
|
|
||||||
|
def _get(url, cfg):
|
||||||
|
req = urllib.request.Request(url, headers=_headers(cfg))
|
||||||
|
with urllib.request.urlopen(req, timeout=60, context=_ctx(cfg)) as r:
|
||||||
|
return r.read()
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
url = BASE + "?" + urllib.parse.urlencode({"resultsPerPage": 1})
|
||||||
|
raw = _get(url, cfg)
|
||||||
|
data = json.loads(raw) if raw else {}
|
||||||
|
return {"ok": True, "total_results": data.get("totalResults")}
|
||||||
|
|
||||||
|
|
||||||
|
_run(main)
|
||||||
Reference in New Issue
Block a user