Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
Add sleeping time between NVD API call (temporary solution for #22)
Browse files Browse the repository at this point in the history
  • Loading branch information
alb-uss committed Nov 16, 2021
1 parent 0c669d1 commit f2da700
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cve_poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def cvePoller(sender, receivers, smtp_login, smtp_password, smtpsrv, port, tls,
dest_language = getUserLanguage()
now_date = str(datetime.now()).split(" ")[0].split("-")
idx_date = now_date[2]+"/"+now_date[1]+"/"+now_date[0]
time.sleep(10)


# CPE
Expand All @@ -126,6 +127,7 @@ def cvePoller(sender, receivers, smtp_login, smtp_password, smtpsrv, port, tls,
if cpes != []:
print(bcolors.HEADER+"Polling NVD related to your product list (CPE based search)."+bcolors.ENDC+"\n")
for cpe in cpes:
time.sleep(30)
cve_ids = pollCveIdFromCpe(cpe)
cpe = cpe.replace("\n","").replace(" ","")
for cve_id in cve_ids:
Expand All @@ -136,6 +138,7 @@ def cvePoller(sender, receivers, smtp_login, smtp_password, smtpsrv, port, tls,
for result in db_result_tuple:
db_result_str+=result
if cve_id not in db_result_str:
time.sleep(10)
nvd_base_url = "https://services.nvd.nist.gov/rest/json/cve/1.0/"
nvd_query = nvd_base_url+cve_id
nvd_response = requests.get(url=nvd_query)
Expand Down Expand Up @@ -258,6 +261,7 @@ def cvePoller(sender, receivers, smtp_login, smtp_password, smtpsrv, port, tls,
for result in db_result_tuple:
db_result_str+=result
if cve_id not in db_result_str:
time.sleep(15)
nvd_base_url = "https://services.nvd.nist.gov/rest/json/cve/1.0/"
nvd_query = nvd_base_url+cve_id
nvd_response = requests.get(url=nvd_query)
Expand Down
2 changes: 2 additions & 0 deletions cve_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
print("No Github API configuration found.")
else:
for cve in cve_list:
time.sleep(30)
github_query = "https://api.github.com/search/repositories?q=exploit+"+cve
github_response = requests.get(url=github_query,auth=(user,key))
github_data = github_response.json()
Expand Down Expand Up @@ -87,6 +88,7 @@
try:
try:
before_update = getRegisteredCveInfos(cve, full=True)
time.sleep(5)
after_update = getUnregisteredCveInfos(cve)
except:
continue
Expand Down

0 comments on commit f2da700

Please sign in to comment.