aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/cvetool13
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/cvetool b/bin/cvetool
index d6c2f6d..b8aa5ca 100755
--- a/bin/cvetool
+++ b/bin/cvetool
@@ -15,6 +15,9 @@ URI_BASE = 'https://glsamaker.gentoo.org'
class CVETool:
""" Interface to GLSAMaker's CVETool """
+ class NotFoundError(RuntimeError):
+ pass
+
def __init__(self, auth, command, args):
self.auth = auth
@@ -46,7 +49,11 @@ class CVETool:
sys.exit(1)
def info(self, cve):
- data = self.json_request('/cve/info/' + cve + '.json')
+ try:
+ data = self.json_request('/cve/info/' + cve + '.json')
+ except self.NotFoundError as e:
+ print('{} not found in Gentoo\'s CVE database!'.format(cve))
+ sys.exit(0)
print(' CVE ID: ' + data['cve_id'])
print(' Summary: ' + data['summary'])
@@ -107,7 +114,9 @@ class CVETool:
response, content = client.request(full_uri, method, headers = { 'Authorization': 'Basic ' + self.auth })
status = response['status']
- if (status[0] != '2' and status != '304'):
+ if (status == '404'):
+ raise self.NotFoundError(full_uri + ': ' + status)
+ elif (status[0] != '2' and status != '304'):
raise RuntimeError(full_uri + ': ' + status)
return content.decode('utf-8')