Skip to content

Commit 3f12394

Browse files
committed
risk-service fixing the pydantic errors
1 parent af15d66 commit 3f12394

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

backend/services/risks_service.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ def get_risks(user_id):
3333
for scan in scans:
3434
scan_result = scan.scan_result
3535
scan_type = scan.scan_type
36-
failed_checks = scan_result.get("results", {}).get("failed_checks", [])
36+
failed_checks = scan_result.get("failed_checks", [])
3737

3838
for check in failed_checks:
39-
severity = check.get("severity", "INFO")
40-
severity_counts[severity] = severity_counts.get(severity, 0) + 1
39+
severity = check.get("severity") or "INFO" # <-- FIXED: Handles None explicitly
40+
# Normalize to uppercase for counting (in case Checkov uses "high" or "High")
41+
severity_upper = severity.upper() if severity else "INFO"
42+
# Only count if it's one of our expected keys (avoids errors if weird values)
43+
if severity_upper in severity_counts:
44+
severity_counts[severity_upper] += 1
45+
else:
46+
severity_counts["INFO"] += 1 # Fallback for unknown severities
4147
detailed_risks.append({
4248
"severity": severity,
4349
"check_id": check.get("check_id"),

frontend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ This section has moved here: [https://facebook.github.io/create-react-app/docs/d
6767

6868
### `npm run build` fails to minify
6969

70-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify]
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

0 commit comments

Comments
 (0)