From f39b723af4c1187e41526b37feb18cd0f94fd67c Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 28 Mar 2019 21:47:35 +0000 Subject: [PATCH] Added cve.py --- modules/cve.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 modules/cve.py diff --git a/modules/cve.py b/modules/cve.py new file mode 100644 index 00000000..1c7f408e --- /dev/null +++ b/modules/cve.py @@ -0,0 +1,29 @@ +import datetime, json +from src import ModuleManager, utils + +URL_CVE = "https://cve.circl.lu/api/cve/%s" + +class Module(ModuleManager.BaseModule): + @utils.hook("received.command.cve", min_args=1) + def cve(self, event): + """ + :help: Get the definition of a provided term from Urban Dictionary + :usage: + """ + page = utils.http.request(URL_CVE % event["args"].upper(), json=True) + + if page and page.data: + cve_id = page.data["id"] + + published = "%sZ" % page.data["Published"].rsplit(".", 1)[0] + published = datetime.datetime.strptime(published, + utils.ISO8601_PARSE) + published = datetime.datetime.strftime(published, "%Y-%m-%d") + + rank = page.data["cvss"] + summary = page.data["summary"] + + event["stdout"].write("%s, %s (%s): %s" % + (cve_id, published, rank, summary)) + else: + raise utils.EventsResultsError()