Skip to content

Commit

Permalink
fix: fix resource for kubernetes unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
AdriiiPRodri committed Feb 26, 2025
1 parent c3dff6a commit b803f4e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion prowler/lib/outputs/finding.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def transform_api_finding(cls, finding, provider) -> "Finding":
# Azure, GCP specified field
finding.location = resource.region
# K8s specified field
finding.namespace = resource.region.removeprefix("namespace: ")
if provider.type == "kubernetes":
finding.namespace = resource.region.removeprefix("namespace: ")
if provider.type == "azure":
finding.subscription = list(provider.identity.subscriptions.keys())[0]
elif provider.type == "gcp":
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/outputs/finding_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,14 +884,14 @@ def test_transform_api_finding_kubernetes(self):
api_finding.raw_result = {}
api_finding.resource_name = "k8s-resource-name"
api_finding.resource_id = "k8s-resource-uid"
api_finding.namespace = "default"
resource = DummyResource(
uid="k8s-resource-uid",
name="k8s-resource-name",
resource_arn="arn",
region="",
tags=[],
)
resource.region = "namespace: default"
api_finding.resources = DummyResources(resource)
finding_obj = Finding.transform_api_finding(api_finding, provider)
assert finding_obj.auth_method == "in-cluster"
Expand Down

0 comments on commit b803f4e

Please sign in to comment.