mirror of https://github.com/MISP/misp-modules
fix: [crowdsec] set default version and expansion added
parent
c1168ac627
commit
fe778dd576
|
@ -4,12 +4,12 @@ from pymisp import MISPEvent, MISPObject
|
||||||
import pycountry
|
import pycountry
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
mispattributes = {"input": ["ip-dst", "ip-src"], "output": ["text"]}
|
mispattributes = {"input": ["ip-dst", "ip-src"], "output": ["text"], 'format': 'misp_standard'}
|
||||||
moduleinfo = {
|
moduleinfo = {
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"author": "Shivam Sandbhor <shivam@crowdsec.net>",
|
"author": "Shivam Sandbhor <shivam@crowdsec.net>",
|
||||||
"description": "Module to access CrowdSec CTI API.",
|
"description": "Module to access CrowdSec CTI API.",
|
||||||
"module-type": ["hover"],
|
"module-type": ["hover", "expansion"],
|
||||||
}
|
}
|
||||||
moduleconfig = ["api_key", "api_version"]
|
moduleconfig = ["api_key", "api_version"]
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ def handler(q=False):
|
||||||
return {"error": "Missing CrowdSec API key"}
|
return {"error": "Missing CrowdSec API key"}
|
||||||
|
|
||||||
if not request["config"].get("api_version"):
|
if not request["config"].get("api_version"):
|
||||||
return {"error": "Missing CrowdSec API version parameter"}
|
else:
|
||||||
|
request["config"] = "v2"
|
||||||
|
|
||||||
if request["config"]["api_version"] == "v2":
|
if request["config"]["api_version"] == "v2":
|
||||||
return _handler_v2(request)
|
return _handler_v2(request)
|
||||||
|
@ -43,7 +44,7 @@ def _handler_v2(request_data):
|
||||||
f"https://cti.api.crowdsec.net/v2/smoke/{ip}",
|
f"https://cti.api.crowdsec.net/v2/smoke/{ip}",
|
||||||
headers={
|
headers={
|
||||||
"x-api-key": request_data["config"]["api_key"],
|
"x-api-key": request_data["config"]["api_key"],
|
||||||
"User-Agent": "crowdsec-misp/v1.0.0",
|
"User-Agent": "crowdsec-misp/v1.0.0",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
crowdsec_cti.raise_for_status()
|
crowdsec_cti.raise_for_status()
|
||||||
|
|
Loading…
Reference in New Issue