Skip to content

Commit

Permalink
fix iava issues #61 #62
Browse files Browse the repository at this point in the history
  • Loading branch information
ryran committed Dec 1, 2016
1 parent 07f9856 commit 31d3559
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ CVE-2016-4979 (https://access.redhat.com/security/cve/CVE-2016-4979)
## Full help page

```
$ rhsecapi --help
usage: rhsecapi [--q-before YYYY-MM-DD] [--q-after YYYY-MM-DD] [--q-bug BZID]
[--q-advisory RHSA] [--q-severity IMPACT] [--q-package PKG]
[--q-cwe CWEID] [--q-cvss SCORE] [--q-cvss3 SCORE] [--q-empty]
Expand Down
18 changes: 12 additions & 6 deletions rhsda.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def __get(self, url, params={}):
baseurl = r.url.split("/")[-2]
logger.debug("Return '.../{0}': Status {1}, Content-Type {2}".format(baseurl, r.status_code, r.headers['Content-Type'].split(";")[0]))
r.raise_for_status()
if 'application/xml' in r.headers['Content-Type']:
if r.content == 'No match found.' or 'application/json' not in r.headers['Content-Type']:
return r.content
else:
return r.json()
Expand Down Expand Up @@ -564,14 +564,19 @@ def _get_and_parse_iava(self, iava):
# Store json
J = self.get_iava(iava)
except requests.exceptions.HTTPError as e:
### LEAVING THIS HERE FOR NOW IN ANTICIPATION OF FUTURE API CHANGE
# IAVA not in RH IAVA DB
logger.info(e)
if self.cfg.onlyCount or self.cfg.outFormat in ['list', 'json', 'jsonpretty']:
return False, ""
return False, "", 0
else:
out.append("{0}\n Not present in Red Hat IAVA database".format(iava))
out.append("")
return False, "\n".join(out)
return False, "{0}\n Not present in Red Hat IAVA database\n".format(iava), 0
if J == 'No match found.':
# IAVA not in RH IAVA DB
if self.cfg.onlyCount or self.cfg.outFormat in ['list', 'json', 'jsonpretty']:
return False, "", 0
else:
return False, "{0}\n Not present in Red Hat IAVA database\n".format(iava), 0
numCves = len(J['cvelist'])
# If json output requested
if self.cfg.outFormat.startswith('json'):
Expand Down Expand Up @@ -846,7 +851,8 @@ def mget_iavas(self, iavas, numThreads=0, onlyCount=False, outFormat='plaintext'
n_hidden = successValues.count(None)
n_valid = successValues.count(True)
logger.log(25, "Valid Red Hat IAVA results retrieved: {0} of {1}".format(n_valid + n_hidden, n_total))
logger.log(25, "Number of CVEs mapped from retrieved IAVAs: {0}".format(sum(numCves)))
if sum(numCves):
logger.log(25, "Number of CVEs mapped from retrieved IAVAs: {0}".format(sum(numCves)))
if outFormat == 'list':
cves = []
for cvelist in iavaOutput:
Expand Down

0 comments on commit 31d3559

Please sign in to comment.