Skip to content

Commit

Permalink
feat(aws): resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPBrito committed Aug 7, 2024
1 parent d7fd3e4 commit e1e3b96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from prowler.lib.check.models import Check, Check_Report_AWS
from prowler.providers.aws.services.s3.s3_client import s3_client
from prowler.providers.aws.services.s3.s3control_client import s3control_client


Expand All @@ -12,7 +11,7 @@ def execute(self):
report.resource_id = access_point.name
report.resource_arn = arn
report.status = "PASS"
report.status_extended = f"Access Point {access_point.name} of bucket {access_point.bucket} in account {s3_client.audited_account} does have Public Access Block enabled."
report.status_extended = f"Access Point {access_point.name} of bucket {access_point.bucket} does have Public Access Block enabled."

if not (
access_point.public_access_block.block_public_acls
Expand All @@ -21,7 +20,7 @@ def execute(self):
and access_point.public_access_block.restrict_public_buckets
):
report.status = "FAIL"
report.status_extended = f"Access Point {access_point.name} of bucket {access_point.bucket} in account {s3_client.audited_account} does not have Public Access Block enabled."
report.status_extended = f"Access Point {access_point.name} of bucket {access_point.bucket} does not have Public Access Block enabled."

findings.append(report)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from unittest.mock import patch

from prowler.providers.aws.services.s3.s3_service import (
S3,
AccessPoint,
PublicAccessBlock,
S3Control,
Expand All @@ -24,9 +23,6 @@ def test_no_access_points(self):
with mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=aws_provider,
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3_client",
new=S3(aws_provider),
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3control_client",
new=S3Control(aws_provider),
Expand Down Expand Up @@ -66,9 +62,6 @@ def test_access_points_with_public_access_block(self):
with mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=aws_provider,
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3_client",
new=S3(aws_provider),
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3control_client",
new=S3Control(aws_provider),
Expand Down Expand Up @@ -120,7 +113,7 @@ def test_access_points_with_public_access_block(self):
assert result[0].status == "PASS"
assert (
result[0].status_extended
== f"Access Point {ap_name_us} of bucket {bucket_name_us} in account {AWS_ACCOUNT_NUMBER} does have Public Access Block enabled."
== f"Access Point {ap_name_us} of bucket {bucket_name_us} does have Public Access Block enabled."
)
assert result[0].resource_id == ap_name_us
assert (
Expand All @@ -133,7 +126,7 @@ def test_access_points_with_public_access_block(self):
assert result[1].status == "PASS"
assert (
result[1].status_extended
== f"Access Point {ap_name_eu} of bucket {bucket_name_eu} in account {AWS_ACCOUNT_NUMBER} does have Public Access Block enabled."
== f"Access Point {ap_name_eu} of bucket {bucket_name_eu} does have Public Access Block enabled."
)
assert result[1].resource_id == ap_name_eu
assert (
Expand All @@ -160,9 +153,6 @@ def test_access_points_without_public_access_block(self):
with mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=aws_provider,
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3_client",
new=S3(aws_provider),
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3control_client",
new=S3Control(aws_provider),
Expand Down Expand Up @@ -214,7 +204,7 @@ def test_access_points_without_public_access_block(self):
assert result[0].status == "FAIL"
assert (
result[0].status_extended
== f"Access Point {ap_name_us} of bucket {bucket_name_us} in account {AWS_ACCOUNT_NUMBER} does not have Public Access Block enabled."
== f"Access Point {ap_name_us} of bucket {bucket_name_us} does not have Public Access Block enabled."
)
assert result[0].resource_id == ap_name_us
assert (
Expand All @@ -227,7 +217,7 @@ def test_access_points_without_public_access_block(self):
assert result[1].status == "FAIL"
assert (
result[1].status_extended
== f"Access Point {ap_name_eu} of bucket {bucket_name_eu} in account {AWS_ACCOUNT_NUMBER} does not have Public Access Block enabled."
== f"Access Point {ap_name_eu} of bucket {bucket_name_eu} does not have Public Access Block enabled."
)
assert result[1].resource_id == ap_name_eu
assert (
Expand All @@ -254,9 +244,6 @@ def test_access_points_without_one_public_access_block(self):
with mock.patch(
"prowler.providers.common.provider.Provider.get_global_provider",
return_value=aws_provider,
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3_client",
new=S3(aws_provider),
), mock.patch(
"prowler.providers.aws.services.s3.s3_access_point_public_access_block.s3_access_point_public_access_block.s3control_client",
new=S3Control(aws_provider),
Expand Down Expand Up @@ -308,7 +295,7 @@ def test_access_points_without_one_public_access_block(self):
assert result[0].status == "PASS"
assert (
result[0].status_extended
== f"Access Point {ap_name_us} of bucket {bucket_name_us} in account {AWS_ACCOUNT_NUMBER} does have Public Access Block enabled."
== f"Access Point {ap_name_us} of bucket {bucket_name_us} does have Public Access Block enabled."
)
assert result[0].resource_id == ap_name_us
assert (
Expand All @@ -321,7 +308,7 @@ def test_access_points_without_one_public_access_block(self):
assert result[1].status == "FAIL"
assert (
result[1].status_extended
== f"Access Point {ap_name_eu} of bucket {bucket_name_eu} in account {AWS_ACCOUNT_NUMBER} does not have Public Access Block enabled."
== f"Access Point {ap_name_eu} of bucket {bucket_name_eu} does not have Public Access Block enabled."
)
assert result[1].resource_id == ap_name_eu
assert (
Expand Down

0 comments on commit e1e3b96

Please sign in to comment.