fix: [cves] catch cve search errors

pull/594/head
Terrtia 2023-05-12 09:59:18 +02:00
parent f4d20533cc
commit 98cbaad1ad
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 64 additions and 57 deletions

View File

@ -76,6 +76,7 @@ class Cve(AbstractDaterangeObject):
self._add(date, item_id) self._add(date, item_id)
def get_cve_search(self): def get_cve_search(self):
try:
response = requests.get(f'https://cvepremium.circl.lu/api/cve/{self.id}', timeout=10) response = requests.get(f'https://cvepremium.circl.lu/api/cve/{self.id}', timeout=10)
if response.status_code == 200: if response.status_code == 200:
json_response = response.json() json_response = response.json()
@ -87,6 +88,9 @@ class Cve(AbstractDaterangeObject):
return json_response return json_response
else: else:
return {'error': f'{response.status_code}'} return {'error': f'{response.status_code}'}
except requests.exceptions.ConnectionError:
return {'error': f'Connection Error'}
# TODO ADD SEARCH FUNCTION # TODO ADD SEARCH FUNCTION

View File

@ -47,6 +47,9 @@
</div> </div>
</li> </li>
{% if dict_object["metadata_card"]["cve_search"] %} {% if dict_object["metadata_card"]["cve_search"] %}
{% if 'error' in dict_object["metadata_card"]["cve_search"] %}
<b class="text-danger my-2"><i class="fas fa-exclamation-triangle"></i> CVE Search Error: {{ dict_object["metadata_card"]["cve_search"]["error"] }}</b>
{% else %}
<li class="list-group-item py-0"> <li class="list-group-item py-0">
<table class="table table-sm table-hover"> <table class="table table-sm table-hover">
<tbody> <tbody>
@ -97,7 +100,7 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% endif %}
{% endif %} {% endif %}
<li class="list-group-item py-0"> <li class="list-group-item py-0">
<br> <br>