first commit
This commit is contained in:
26
core/evaluation.py
Normal file
26
core/evaluation.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from core.schemas.config import Config, ResolvedConfig
|
||||
from core.schemas.results import AuditResults
|
||||
from core.schemas.status import AuditSeverity
|
||||
|
||||
SEVERITY_WEIGHTS = {
|
||||
AuditSeverity.LOW: 1,
|
||||
AuditSeverity.MEDIUM: 2,
|
||||
AuditSeverity.HIGH: 3,
|
||||
AuditSeverity.CRITICAL: 4,
|
||||
}
|
||||
|
||||
|
||||
def evaluate_exit_code(results: list[AuditResults], config: Config | ResolvedConfig) -> int:
|
||||
severity_threshold = SEVERITY_WEIGHTS.get(
|
||||
config.allow_failures_below, SEVERITY_WEIGHTS[AuditSeverity.HIGH]
|
||||
)
|
||||
|
||||
threshold_crossed = any(
|
||||
SEVERITY_WEIGHTS.get(finding.severity, 1) >= severity_threshold
|
||||
for result in results
|
||||
for finding in result.findings
|
||||
)
|
||||
|
||||
if threshold_crossed and config.strict_mode:
|
||||
return 1
|
||||
return 0
|
||||
Reference in New Issue
Block a user