meaningful exception handling for vulnix

This commit is contained in:
Alex Tau 2025-08-16 13:24:47 +03:00
parent d78d21c312
commit c355583f59

View file

@ -2,7 +2,6 @@ from socket import gethostname
from lego_monitoring.alerting.alert import Alert from lego_monitoring.alerting.alert import Alert
from lego_monitoring.alerting.enum import AlertType, Severity from lego_monitoring.alerting.enum import AlertType, Severity
from lego_monitoring.alerting.sender import send_alert
from ..utils import format_for_healthchecks_slug from ..utils import format_for_healthchecks_slug
from .vulnix import get_vulnix_output from .vulnix import get_vulnix_output
@ -16,15 +15,14 @@ async def vulnix_check() -> list[Alert]:
try: try:
vulnix_output = get_vulnix_output(IS_TESTING) vulnix_output = get_vulnix_output(IS_TESTING)
except Exception as e: except Exception as e:
await send_alert( return [
Alert( Alert(
alert_type=AlertType.ERROR, AlertType.VULN,
message=f"Exception {type(e).__name__} while calling vulnix: {e}", message=f"Exception {type(e).__name__} while calling vulnix: {e}",
severity=Severity.CRITICAL, severity=Severity.CRITICAL,
healthchecks_slug=slug, healthchecks_slug=slug,
) )
) ]
return []
for finding in vulnix_output: for finding in vulnix_output:
if not IS_TESTING: if not IS_TESTING:
non_whitelisted_cves = [k for k in finding.description if k not in finding.whitelisted] non_whitelisted_cves = [k for k in finding.description if k not in finding.whitelisted]