Skip to content

Commit

Permalink
fix #66
Browse files Browse the repository at this point in the history
  • Loading branch information
ryran committed Jun 27, 2017
1 parent 8e83d11 commit 653070f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
34 changes: 18 additions & 16 deletions rhsda.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def __stripjoin(self, input, oneLineEach=False):

def __check_field(self, field, jsoninput):
"""Return True if field is desired and exists in jsoninput."""
if field in self.cfg.desiredFields and jsoninput.has_key(field):
if field in self.cfg.desiredFields and field in jsoninput:
return True
return False

Expand Down Expand Up @@ -460,7 +460,7 @@ def _get_and_parse_cve(self, cve):
out.append(" CVSS3 : {0} ({1})".format(J['cvss3']['cvss3_base_score'], vector))
# BUGZILLA
if 'bugzilla' in self.cfg.desiredFields:
if J.has_key('bugzilla'):
if 'bugzilla' in J:
if self.cfg.urls:
bug = J['bugzilla']['url']
else:
Expand Down Expand Up @@ -506,7 +506,7 @@ def _get_and_parse_cve(self, cve):
# If product doesn't match spotlight, go to next
continue
pkg = ""
if release.has_key('package'):
if 'package' in release:
pkg = " [{0}]".format(release['package'])
advisory = release['advisory']
if self.cfg.urls:
Expand Down Expand Up @@ -534,7 +534,7 @@ def _get_and_parse_cve(self, cve):
# If product doesn't match spotlight, go to next
continue
pkg = ""
if state.has_key('package_name'):
if 'package_name' in state:
pkg = " [{0}]".format(state['package_name'])
out.append(" {0}: {1}{2}".format(state['fix_state'], state['product_name'], pkg))
if self.cfg.product and not foundProduct_package_state:
Expand Down Expand Up @@ -889,30 +889,32 @@ def cve_search_query(self, params, outFormat='list', urls=False):
rows.append(["CVE ID", "PUB DATE", "BUGZILLA", "SEVERITY", "CVSS2", "CVSS3", "RHSAS", "PKGS"])
for i in result:
date = ""
if i.has_key('public_date'):
if 'public_date' in i and i['public_date'] is not None:
date = i['public_date'].split("T")[0]
bz = ""
if urls:
cve = "https://access.redhat.com/security/cve/{0}".format(i['CVE'])
if i.has_key('bugzilla'):
if 'bugzilla' in i and i['bugzilla'] is not None:
bz = "https://bugzilla.redhat.com/show_bug.cgi?id={0}".format(i['bugzilla'])
else:
cve = i['CVE']
if i.has_key('bugzilla'):
if 'bugzilla' in i and i['bugzilla'] is not None:
bz = i['bugzilla']
severity = i['severity']
rhsas = ""
if i.has_key('advisories'):
rhsas = "{0: >2}".format(len(i['advisories']))
pkgs = ""
if i.has_key('affected_packages'):
pkgs = "{0: >2}".format(len(i['affected_packages']))
severity = ""
if 'severity' in i and i['severity'] is not None:
severity = i['severity']
cvss2 = ""
if i.has_key('cvss_score'):
if 'cvss_score' in i and i['cvss_score'] is not None:
cvss2 = str(i['cvss_score'])
cvss3 = ""
if i.has_key('cvss3_score'):
if 'cvss3_score' in i and i['cvss3_score'] is not None:
cvss3 = str(i['cvss3_score'])
rhsas = ""
if 'advisories' in i and i['advisories'] is not None:
rhsas = "{0: >2}".format(len(i['advisories']))
pkgs = ""
if 'affected_packages' in i and i['affected_packages'] is not None:
pkgs = "{0: >2}".format(len(i['affected_packages']))
line = [cve, date, bz, severity, cvss2, cvss3, rhsas, pkgs]
rows.append(line)
return self._columnize(rows, sep=" ")
Expand Down
6 changes: 3 additions & 3 deletions rhsecapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
# Globals
prog = 'rhsecapi'
vers = {}
vers['version'] = '1.0.0_rc10'
vers['date'] = '2017/01/05'
vers['version'] = '1.0.1'
vers['date'] = '2017/06/27'


# Logging
Expand Down Expand Up @@ -179,7 +179,7 @@ def parse_args():
help="Narrow down results by severity rating (specify one of 'low', 'moderate', 'important', or 'critical')")
g_listByAttr.add_argument(
'--q-product', metavar="PRODUCT",
help="Narrow down results by product name via case-insensitive regex (e.g.: 'linux 7' or openstack platform [89]'); the API checks this against the 'FIXED_RELEASES' field so will only match CVEs where PRODUCT matches the 'product_name' of some released errata")
help="Narrow down results by product name via case-insensitive regex (e.g.: 'linux 7' or 'openstack platform [89]'); the API checks this against the 'FIXED_RELEASES' field so will only match CVEs where PRODUCT matches the 'product_name' of some released errata")
g_listByAttr.add_argument(
'--q-package', metavar="PKG",
help="Narrow down results by package name (e.g.: 'samba' or 'thunderbird')")
Expand Down

0 comments on commit 653070f

Please sign in to comment.