Skip to content

fix(compliance): handle ZeroDivision error from Prowler ThreatScore#9653

Merged
pedrooot merged 2 commits intomasterfrom
PROWLER-518-fix-zero-division-error-from-prowler-threat-score
Dec 23, 2025
Merged

fix(compliance): handle ZeroDivision error from Prowler ThreatScore#9653
pedrooot merged 2 commits intomasterfrom
PROWLER-518-fix-zero-division-error-from-prowler-threat-score

Conversation

@pedrooot
Copy link
Member

@pedrooot pedrooot commented Dec 23, 2025

Description

This pull request improves the robustness and clarity of the threat score calculation and display logic in the prowler_threatscore.py output module. The key changes ensure that division by zero is avoided and that the threat score output is accurate and visually consistent, even when all findings are muted or a pillar's maximum score is zero.

Improvements to threat score calculation and display:

  • Added a check to handle cases where max_score_per_pillar[pillar] is zero, setting the pillar score to 100% and using a green color to indicate no risk; otherwise, the score is calculated as before and shown in red.
  • Updated the calculation of the generic threat score to handle division by zero when max_generic_score is zero, defaulting the score to 100% in this case.

Steps to review

Please add a detailed description of how to review this PR.

Checklist

UI

  • All issue/task requirements work as expected on the UI
  • Screenshots/Video of the functionality flow (if applicable) - Mobile (X < 640px)
  • Screenshots/Video of the functionality flow (if applicable) - Table (640px > X < 1024px)
  • Screenshots/Video of the functionality flow (if applicable) - Desktop (X > 1024px)
  • Ensure new entries are added to CHANGELOG.md, if applicable.

API

  • Verify if API specs need to be regenerated.
  • Check if version updates are required (e.g., specs, Poetry, etc.).
  • Ensure new entries are added to CHANGELOG.md, if applicable.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@pedrooot pedrooot requested review from a team as code owners December 23, 2025 08:15
@github-actions github-actions bot added the compliance Issues/PRs related with the Compliance Frameworks label Dec 23, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

✅ All necessary CHANGELOG.md files have been updated.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

Conflict Markers Resolved

All conflict markers have been successfully resolved in this pull request.

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.53%. Comparing base (43875b6) to head (be88488).
⚠️ Report is 7 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (43875b6) and HEAD (be88488). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (43875b6) HEAD (be88488)
prowler-py3.9-config 1 0
prowler-py3.11-config 1 0
prowler-py3.10-config 1 0
prowler-py3.12-config 1 0
prowler-py3.11-gcp 1 0
prowler-py3.9-gcp 1 0
prowler-py3.10-gcp 1 0
prowler-py3.12-gcp 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #9653       +/-   ##
===========================================
- Coverage   92.27%   69.53%   -22.74%     
===========================================
  Files         128       84       -44     
  Lines        3210     5896     +2686     
===========================================
+ Hits         2962     4100     +1138     
- Misses        248     1796     +1548     
Flag Coverage Δ
prowler-py3.10-config ?
prowler-py3.10-gcp ?
prowler-py3.10-lib 69.53% <0.00%> (?)
prowler-py3.11-config ?
prowler-py3.11-gcp ?
prowler-py3.11-lib 69.53% <0.00%> (?)
prowler-py3.12-config ?
prowler-py3.12-gcp ?
prowler-py3.12-lib 69.53% <0.00%> (?)
prowler-py3.9-config ?
prowler-py3.9-gcp ?
prowler-py3.9-lib 69.53% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
prowler 69.53% <0.00%> (-22.74%) ⬇️
api ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 23, 2025

🔒 Container Security Scan

Image: prowler:eab425b
Last scan: 2025-12-23 08:26:10 UTC

📊 Vulnerability Summary

Severity Count
🔴 Critical 3
Total 3

3 package(s) affected

⚠️ Action Required

Critical severity vulnerabilities detected. These should be addressed before merging:

  • Review the detailed scan results
  • Update affected packages to patched versions
  • Consider using a different base image if updates are unavailable

📋 Resources:

@pedrooot pedrooot added the backport-to-v5.16 Backport PR to the v5.16 branch label Dec 23, 2025
@pedrooot pedrooot merged commit be75921 into master Dec 23, 2025
36 of 42 checks passed
@pedrooot pedrooot deleted the PROWLER-518-fix-zero-division-error-from-prowler-threat-score branch December 23, 2025 08:29
@prowler-bot
Copy link
Collaborator

💚 All backports created successfully

Status Branch Result
v5.16

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

@prowler-bot prowler-bot added the was-backported The PR was successfully backported to the target branch label Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v5.16 Backport PR to the v5.16 branch compliance Issues/PRs related with the Compliance Frameworks was-backported The PR was successfully backported to the target branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants