Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
fix: CVE
Browse files Browse the repository at this point in the history
  • Loading branch information
jjeff07 committed Dec 21, 2021
1 parent 1059227 commit 87c7d7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion examples/tools/cve_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
if __name__ == "__main__":
ipf = IPFClient()
# ipf = IPFClient('https://demo3.ipfabric.io/', token='token', verify=False, timeout=15)
vuln = Vulnerabilities(ipf)
vuln = Vulnerabilities(ipf, timeout=30, cve_limit=20)
# Increasing cve_limit will increase the amount of time NIST responds


device = vuln.check_device('L47R6')
pprint(device)
Expand Down
6 changes: 5 additions & 1 deletion ipfabric/tools/nist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ class CVEs(BaseModel):


class NIST(Client):
def __init__(self, timeout, cve_limit):
super().__init__(base_url='https://services.nvd.nist.gov/rest/json/cves/1.0', timeout=timeout)
self.cve_limit = cve_limit

@property
def params(self):
return {
'cpeMatchString': 'cpe:2.3:*:',
'startIndex': 0,
'resultsPerPage': 50
'resultsPerPage': self.cve_limit
}

def check_cve(self, vendor: str, family: str, version: str):
Expand Down
4 changes: 2 additions & 2 deletions ipfabric/tools/vulnerabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class Version(BaseModel):


class Vulnerabilities:
def __init__(self, ipf):
def __init__(self, ipf, timeout: int = 30, cve_limit: int = 20):
self.ipf = ipf
self.nist = NIST(base_url='https://services.nvd.nist.gov/rest/json/cves/1.0', timeout=30)
self.nist = NIST(timeout=timeout, cve_limit=cve_limit)

def __del__(self):
try:
Expand Down

0 comments on commit 87c7d7e

Please sign in to comment.