Skip to content

Commit a4e40a9

Browse files
committed
Refine cloud provider inference logic in ProwlerParser
- Update check_id prefixes for AWS detection to include "accessanalyzer_" and "account_" - Simplify Azure detection by removing unnecessary check_id prefixes - Streamline GCP detection to rely solely on title matching - Adjust Kubernetes detection to focus on "apiserver_" prefix in check_id
1 parent 46d5d33 commit a4e40a9

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

dojo/tools/prowler/parser.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,16 @@ def _parse_json_findings(self, data, test, *, file_name=""):
211211
if cloud_provider:
212212
finding.unsaved_tags.append(cloud_provider)
213213
# If no cloud provider but we can infer it from check_id or title
214-
elif check_id and any(prefix in check_id.lower() for prefix in ["iam_", "elb_", "ec2_", "s3_"]):
214+
elif check_id and any(prefix in check_id.lower() for prefix in ["accessanalyzer_", "account_"]):
215215
finding.unsaved_tags.append("aws")
216216
elif "azure" in title.lower() or (
217-
check_id and any(prefix in check_id.lower() for prefix in ["aks_", "aad_"])
217+
check_id and any(prefix in check_id.lower() for prefix in ["aks_"])
218218
):
219219
finding.unsaved_tags.append("azure")
220-
elif "gcp" in title.lower() or (
221-
check_id and any(prefix in check_id.lower() for prefix in ["gcp_", "gke_"])
222-
):
220+
elif "gcp" in title.lower():
223221
finding.unsaved_tags.append("gcp")
224222
elif "kubernetes" in title.lower() or (
225-
check_id and any(prefix in check_id.lower() for prefix in ["k8s_", "bc_k8s_"])
223+
check_id and any(prefix in check_id.lower() for prefix in ["apiserver_"])
226224
):
227225
finding.unsaved_tags.append("kubernetes")
228226
# If still no provider tag, try to detect from the file name
@@ -371,18 +369,16 @@ def _parse_csv_findings(self, csv_data, test, *, file_name=""):
371369
if provider:
372370
finding.unsaved_tags.append(provider)
373371
# If no provider in the CSV but we can infer it from check_id or title
374-
elif check_id and any(prefix in check_id.lower() for prefix in ["iam_", "elb_", "ec2_", "s3_"]):
372+
elif check_id and any(prefix in check_id.lower() for prefix in ["accessanalyzer_", "account_"]):
375373
finding.unsaved_tags.append("AWS")
376374
elif "azure" in title.lower() or (
377-
check_id and any(prefix in check_id.lower() for prefix in ["aks_", "aad_"])
375+
check_id and any(prefix in check_id.lower() for prefix in ["aks_"])
378376
):
379377
finding.unsaved_tags.append("AZURE")
380-
elif "gcp" in title.lower() or (
381-
check_id and any(prefix in check_id.lower() for prefix in ["gcp_", "gke_"])
382-
):
378+
elif "gcp" in title.lower():
383379
finding.unsaved_tags.append("GCP")
384380
elif "kubernetes" in title.lower() or (
385-
check_id and any(prefix in check_id.lower() for prefix in ["k8s_", "bc_k8s_"])
381+
check_id and any(prefix in check_id.lower() for prefix in ["apiserver_"])
386382
):
387383
finding.unsaved_tags.append("KUBERNETES")
388384

0 commit comments

Comments
 (0)