Beispiel #1
0
 def _fetch_by_id(self):
     if self.vcdb_id:
         self._vulnerability = Vulnerability.get_by_id(self.vcdb_id)
     elif self.cve_id:
         if not self.is_cve_id(self.cve_id):
             raise InvalidIdentifierException(
                 "Please provide a valid CVE ID.")
         self._vulnerability = Vulnerability.get_by_cve_id(self.cve_id)
Beispiel #2
0
def get_vulnerability(filter_by):
    if not isinstance(filter_by, dict):
        current_app.logger.error("Received invalid filter.")
        return None

    if "cve_id" in filter_by:
        vulnerability = Vulnerability.get_by_cve_id(filter_by["cve_id"])
    elif "commit_hash" in filter_by:
        vulnerability = Vulnerability.get_by_commit_hash(
            filter_by["commit_hash"])
    else:
        current_app.logger.error("Invalid filter option received.")
        return None
    return vulnerability
Beispiel #3
0
def getVulnerability(filter_by):
    if not isinstance(filter_by, dict):
        current_app.logger.error('Received invalid filter.')
        return None

    if 'cve_id' in filter_by:
        vulnerability = Vulnerability.get_by_cve_id(filter_by['cve_id'])
    elif 'commit_hash' in filter_by:
        vulnerability = Vulnerability.get_by_commit_hash(
            filter_by['commit_hash'])
    else:
        current_app.logger.error('Invalid filter option received.')
        return None
    return vulnerability
Beispiel #4
0
 def _fetch_by_id(self):
     if self.vuln_id:
         logging.debug("Loading vuln by vulnid %r", self.vuln_id)
         self._vulnerability = Vulnerability.get_by_id(self.vuln_id)
     elif self.vcdb_id:
         logging.debug("Loading vuln by vcdbid %r", self.vcdb_id)
         self._vulnerability = Vulnerability.get_by_vcdb_id(self.vcdb_id)
     elif self.cve_id:
         logging.debug("Loading vuln by cveid %r", self.cve_id)
         logging.warning(
             "No identifier available to load vulnerability entry")
         if not self.is_cve_id(self.cve_id):
             raise InvalidIdentifierException(
                 "Please provide a valid CVE ID.")
         self._vulnerability = Vulnerability.get_by_cve_id(self.cve_id)
     else:
         logging.warning(
             "No identifier available to load vulnerability entry")