mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-02-09 15:10:36 +00:00
fix(compliance): handle ZeroDivision error from Prowler ThreatScore (#9653)
This commit is contained in:
@@ -19,15 +19,20 @@ All notable changes to the **Prowler SDK** are documented in this file.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## [5.16.1] (Prowler UNRELEASED)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix ZeroDivision error from Prowler ThreatScore [(#9653)](https://github.com/prowler-cloud/prowler/pull/9653)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [5.16.0] (Prowler v5.16.0)
|
## [5.16.0] (Prowler v5.16.0)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `privilege-escalation` and `ec2-imdsv1` categories for AWS checks [(#9537)](https://github.com/prowler-cloud/prowler/pull/9537)
|
- `privilege-escalation` and `ec2-imdsv1` categories for AWS checks [(#9537)](https://github.com/prowler-cloud/prowler/pull/9537)
|
||||||
- Supported IaC formats and scanner documentation for the IaC provider [(#9553)](https://github.com/prowler-cloud/prowler/pull/9553)
|
- Supported IaC formats and scanner documentation for the IaC provider [(#9553)](https://github.com/prowler-cloud/prowler/pull/9553)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Update AWS Glue service metadata to new format [(#9258)](https://github.com/prowler-cloud/prowler/pull/9258)
|
- Update AWS Glue service metadata to new format [(#9258)](https://github.com/prowler-cloud/prowler/pull/9258)
|
||||||
- Update AWS Kafka service metadata to new format [(#9261)](https://github.com/prowler-cloud/prowler/pull/9261)
|
- Update AWS Kafka service metadata to new format [(#9261)](https://github.com/prowler-cloud/prowler/pull/9261)
|
||||||
- Update AWS KMS service metadata to new format [(#9263)](https://github.com/prowler-cloud/prowler/pull/9263)
|
- Update AWS KMS service metadata to new format [(#9263)](https://github.com/prowler-cloud/prowler/pull/9263)
|
||||||
|
|||||||
@@ -103,8 +103,16 @@ def get_prowler_threatscore_table(
|
|||||||
for pillar in pillars:
|
for pillar in pillars:
|
||||||
pillar_table["Provider"].append(compliance.Provider)
|
pillar_table["Provider"].append(compliance.Provider)
|
||||||
pillar_table["Pillar"].append(pillar)
|
pillar_table["Pillar"].append(pillar)
|
||||||
|
if max_score_per_pillar[pillar] == 0:
|
||||||
|
pillar_score = 100.0
|
||||||
|
score_color = Fore.GREEN
|
||||||
|
else:
|
||||||
|
pillar_score = (
|
||||||
|
score_per_pillar[pillar] / max_score_per_pillar[pillar]
|
||||||
|
) * 100
|
||||||
|
score_color = Fore.RED
|
||||||
pillar_table["Score"].append(
|
pillar_table["Score"].append(
|
||||||
f"{Style.BRIGHT}{Fore.RED}{(score_per_pillar[pillar] / max_score_per_pillar[pillar]) * 100:.2f}%{Style.RESET_ALL}"
|
f"{Style.BRIGHT}{score_color}{pillar_score:.2f}%{Style.RESET_ALL}"
|
||||||
)
|
)
|
||||||
if pillars[pillar]["FAIL"] > 0:
|
if pillars[pillar]["FAIL"] > 0:
|
||||||
pillar_table["Status"].append(
|
pillar_table["Status"].append(
|
||||||
@@ -148,9 +156,12 @@ def get_prowler_threatscore_table(
|
|||||||
print(
|
print(
|
||||||
f"\nFramework {Fore.YELLOW}{compliance_framework.upper()}{Style.RESET_ALL} Results:"
|
f"\nFramework {Fore.YELLOW}{compliance_framework.upper()}{Style.RESET_ALL} Results:"
|
||||||
)
|
)
|
||||||
print(
|
# Handle division by zero when all findings are muted
|
||||||
f"\nGeneric Threat Score: {generic_score / max_generic_score * 100:.2f}%"
|
if max_generic_score == 0:
|
||||||
)
|
generic_threat_score = 100.0
|
||||||
|
else:
|
||||||
|
generic_threat_score = generic_score / max_generic_score * 100
|
||||||
|
print(f"\nGeneric Threat Score: {generic_threat_score:.2f}%")
|
||||||
print(
|
print(
|
||||||
tabulate(
|
tabulate(
|
||||||
pillar_table,
|
pillar_table,
|
||||||
|
|||||||
Reference in New Issue
Block a user