Skip to content

Commit e478cca

Browse files
committed
fix(aws): resolve the region matrix output path from the script location
write_regions_by_service() built its destination from os.path.realpath(__name__). __name__ is the module name, "__main__", not a path, so the path was resolved against the current working directory. It happened to be right only because the workflow runs the script from the repository root; an invocation from anywhere else wrote the matrix under <cwd>/prowler/ instead of the checkout. It is now resolved from __file__, so the destination follows the script. The changelog fragments are also shortened, and the one covering the regional clients is split in two so each entry describes a single change.
1 parent a7a8ef3 commit e478cca

5 files changed

Lines changed: 8 additions & 4 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
AWS ISO partitions (`aws-iso`, `aws-iso-b`, `aws-iso-e` and `aws-iso-f`) to the AWS service/region matrix, sourced from the endpoints data bundled with botocore, so services are now scanned in the ISO partitions instead of being silently skipped
1+
AWS ISO partitions (`aws-iso`, `aws-iso-b`, `aws-iso-e` and `aws-iso-f`) to the AWS service region matrix, generated from the endpoints data bundled with botocore
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
`get_global_region()` now returns a real region for the ISO partitions (`us-iso-east-1`, `us-isob-east-1`, `eu-isoe-west-1`, `us-isof-east-1`) instead of the `aws-iso-global` pseudo endpoint, which also collapsed the four ISO partitions into one
1+
`AwsProvider.get_global_region()` now returns a real region for each ISO partition instead of the `aws-iso-global` pseudo endpoint, which collapsed the four partitions into one answer
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
`AwsProvider.generate_regional_clients()` returns an empty dict instead of `None` when the regional clients cannot be built, and `AwsProvider.get_available_aws_service_regions()` returns an empty set for an unknown service or partition instead of raising, so a service unavailable in the audited partition is skipped rather than raising `AttributeError: 'NoneType' object has no attribute 'values'`
1+
`AwsProvider.generate_regional_clients()` now returns an empty dict instead of `None` when the regional clients cannot be built, a failure that surfaced later as `AttributeError: 'NoneType' object has no attribute 'values'`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`AwsProvider.get_available_aws_service_regions()` now returns an empty set for an unknown service or partition instead of raising `KeyError`, so a service unavailable in the audited partition is skipped

util/update_aws_services_regions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ def add_iso_partitions_regions(regions_by_service: dict) -> None:
278278

279279
def write_regions_by_service(regions_by_service: dict) -> None:
280280
"""Write the AWS regions matrix to the file read by the AWS provider."""
281-
parsed_matrix_regions_aws = f"{os.path.dirname(os.path.realpath(__name__))}/prowler/providers/aws/aws_regions_by_service.json"
281+
repository_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
282+
parsed_matrix_regions_aws = (
283+
f"{repository_root}/prowler/providers/aws/aws_regions_by_service.json"
284+
)
282285
logging.info(f"Writing {parsed_matrix_regions_aws}")
283286
with open(parsed_matrix_regions_aws, "w") as outfile:
284287
json.dump(regions_by_service, outfile, indent=2, sort_keys=True)

0 commit comments

Comments
 (0)