-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e7f5d8
commit a973fb7
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python | ||
|
||
import json | ||
from urllib import urlopen | ||
|
||
def output_cve_id(): | ||
"""Takes as input, a package name, package version. | ||
Queries cve-search' dataset for any reported | ||
vulnerabilities of the requested package. If | ||
vulnerability exists, outputs cve-id(s). | ||
""" | ||
package_name = raw_input('Enter package name: ') | ||
user_choice = raw_input('Do you have a package version? (Y/N): ') | ||
|
||
if user_choice == 'Y' or user_choice == 'y': | ||
package_ver = raw_input('Enter package version: ') | ||
url = 'https://cve.circl.lu/api/search/' + package_name + package_ver | ||
|
||
else: | ||
url = 'https://cve.circl.lu/api/search/' + package_name | ||
|
||
raw_data = urlopen(url).read() | ||
data = json.loads(raw_data) | ||
|
||
if len(data) > 0: | ||
print 'Vulnerabilties Found:\n' | ||
|
||
for item in data['data']: | ||
print item['id'] | ||
else: | ||
print 'No vulnerabilites found' | ||
|
||
if __name__ == '__main__': | ||
output_cve_id() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import api_data as api | ||
|
||
from mock import Mock | ||
import pytest | ||
from urllib import urlopen | ||
|
||
test_data = ''' | ||
{ "data": [ | ||
{ | ||
"Modified": "2008-11-15T00:00:00", | ||
"Published": "2007-02-19T21:28:00", | ||
"access": { | ||
"authentication": "NONE", | ||
"complexity": "MEDIUM", | ||
"vector": "NETWORK" | ||
}, | ||
"cvss": 4.3, | ||
"cvss-time": "2007-02-20T14:55:00", | ||
"id": CVE-2007-1004" | ||
"impact": { | ||
"availability": "NONE", | ||
"confidentiality": "NONE", | ||
"integrity": "PARTIAL" | ||
}, | ||
"reason": "Link", | ||
"references": [ | ||
"http://securityreason.com/securityalert/2264", | ||
"http://www.securityfocus.com/archive/1/archive/1/460369/100/0/threaded", | ||
"http://www.securityfocus.com/archive/1/archive/1/460412/100/0/threaded", | ||
"http://www.securityfocus.com/archive/1/archive/1/460617/100/0/threaded", | ||
"http://www.securityfocus.com/bid/22601", | ||
"http://xforce.iss.net/xforce/xfdb/32580" | ||
], | ||
"summary": "Mozilla Firefox might allow remote attackers to conduct spoofing and phishing attacks by writing to an about:blank tab and overlaying the location bar.", | ||
"vulnerable_configuration": [ | ||
"cpe:2.3:a:mozilla:firefox:2.0:rc3" | ||
], | ||
"vulnerable_configuration_cpe_2_2": [ | ||
"cpe:/a:mozilla:firefox:2.0:rc3" | ||
]}]} | ||
''' | ||
|
||
def test_output_cve_id(): | ||
|
||
##BUG## | ||
api.urlopen = Mock() | ||
api.urlopen.return_value = test_data | ||
api.output_cve_id() | ||
|
||
assert api.output_cve_id.data["data"]["item"] == "CVE-2007-1004" |