1
1
from colorama import Fore , Style
2
2
3
3
from prowler .config .config import orange_color
4
+ from prowler .lib .check .models import Severity
4
5
from prowler .lib .logger import logger
6
+ from prowler .lib .outputs .common import Status
7
+ from prowler .lib .outputs .finding import Finding
5
8
6
9
7
10
def stdout_report (finding , color , verbose , status , fix ):
@@ -89,7 +92,7 @@ def set_report_color(status: str, muted: bool = False) -> str:
89
92
return color
90
93
91
94
92
- def extract_findings_statistics (findings : list ) -> dict :
95
+ def extract_findings_statistics (findings : list [ Finding ] ) -> dict :
93
96
"""
94
97
extract_findings_statistics takes a list of findings and returns the following dict with the aggregated statistics
95
98
{
@@ -121,38 +124,46 @@ def extract_findings_statistics(findings: list) -> dict:
121
124
medium_severity_fail = 0
122
125
low_severity_pass = 0
123
126
low_severity_fail = 0
127
+ informational_severity_pass = 0
128
+ informational_severity_fail = 0
124
129
125
130
for finding in findings :
126
- # Save the resource_id
127
- resources .add (finding .resource_id )
131
+ resources .add (finding .resource_uid )
128
132
129
- if finding .status == "PASS" :
130
- if finding .check_metadata .Severity == "critical" :
133
+ if finding .status == Status .PASS :
134
+ findings_count += 1
135
+ total_pass += 1
136
+ if finding .metadata .Severity == Severity .critical :
131
137
critical_severity_pass += 1
132
- if finding .check_metadata .Severity == " high" :
138
+ if finding .metadata .Severity == Severity . high :
133
139
high_severity_pass += 1
134
- if finding .check_metadata .Severity == " medium" :
140
+ if finding .metadata .Severity == Severity . medium :
135
141
medium_severity_pass += 1
136
- if finding .check_metadata .Severity == " low" :
142
+ if finding .metadata .Severity == Severity . low :
137
143
low_severity_pass += 1
138
- total_pass += 1
139
- findings_count += 1
144
+ if finding .metadata .Severity == Severity .informational :
145
+ informational_severity_pass += 1
146
+
140
147
if finding .muted is True :
141
148
muted_pass += 1
142
149
143
- if finding .status == "FAIL" :
144
- if finding .check_metadata .Severity == "critical" :
150
+ if finding .status == Status .FAIL :
151
+ findings_count += 1
152
+ total_fail += 1
153
+ if finding .metadata .Severity == Severity .critical :
145
154
critical_severity_fail += 1
146
- if finding .check_metadata .Severity == " high" :
155
+ if finding .metadata .Severity == Severity . high :
147
156
high_severity_fail += 1
148
- if finding .check_metadata .Severity == " medium" :
157
+ if finding .metadata .Severity == Severity . medium :
149
158
medium_severity_fail += 1
150
- if finding .check_metadata .Severity == " low" :
159
+ if finding .metadata .Severity == Severity . low :
151
160
low_severity_fail += 1
152
- total_fail += 1
153
- findings_count += 1
161
+ if finding .metadata .Severity == Severity .informational :
162
+ informational_severity_fail += 1
163
+
154
164
if finding .muted is True :
155
165
muted_fail += 1
166
+
156
167
if not finding .muted and all_fails_are_muted :
157
168
all_fails_are_muted = False
158
169
@@ -168,8 +179,10 @@ def extract_findings_statistics(findings: list) -> dict:
168
179
stats ["total_high_severity_pass" ] = high_severity_pass
169
180
stats ["total_medium_severity_fail" ] = medium_severity_fail
170
181
stats ["total_medium_severity_pass" ] = medium_severity_pass
171
- stats ["total_low_severity_fail" ] = medium_severity_fail
172
- stats ["total_low_severity_pass" ] = medium_severity_pass
182
+ stats ["total_low_severity_fail" ] = low_severity_fail
183
+ stats ["total_low_severity_pass" ] = low_severity_pass
184
+ stats ["total_informational_severity_pass" ] = informational_severity_pass
185
+ stats ["total_informational_severity_fail" ] = informational_severity_fail
173
186
stats ["all_fails_are_muted" ] = all_fails_are_muted
174
187
175
188
return stats
0 commit comments