2016-03-18 07:51:13 +01:00
import json
import requests
misperrors = { ' error ' : ' Error ' }
2016-03-24 21:44:15 +01:00
mispattributes = { ' input ' : [ ' vulnerability ' ] , ' output ' : [ ' text ' ] }
moduleinfo = { ' version ' : ' 0.2 ' , ' author ' : ' Alexandre Dulaunoy ' , ' description ' : ' An expansion hover module to expand information about CVE id. ' , ' module-type ' : [ ' hover ' ] }
2016-03-18 07:51:13 +01:00
moduleconfig = [ ]
cveapi_url = ' https://cve.circl.lu/api/cve/ '
def handler ( q = False ) :
if q is False :
return False
print ( q )
request = json . loads ( q )
if not request . get ( ' vulnerability ' ) :
misperrors [ ' error ' ] = ' Vulnerability id missing '
return misperrors
2016-04-11 11:07:11 +02:00
r = requests . get ( cveapi_url + request . get ( ' vulnerability ' ) )
2016-03-18 07:51:13 +01:00
if r . status_code == 200 :
vulnerability = json . loads ( r . text )
2016-03-24 21:44:15 +01:00
if vulnerability . get ( ' summary ' ) :
summary = vulnerability [ ' summary ' ]
2016-03-18 07:51:13 +01:00
else :
misperrors [ ' error ' ] = ' cve.circl.lu API not accessible '
return misperrors [ ' error ' ]
2016-03-24 21:44:15 +01:00
r = { ' results ' : [ { ' types ' : mispattributes [ ' output ' ] , ' values ' : summary } ] }
return r
2016-03-18 07:51:13 +01:00
def introspection ( ) :
return mispattributes
def version ( ) :
moduleinfo [ ' config ' ] = moduleconfig
return moduleinfo