mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-03-28 19:10:11 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e37986c1b0 | ||
|
|
85d6d025c5 | ||
|
|
c32f7ba158 |
32
.github/workflows/pypi-release.yml
vendored
32
.github/workflows/pypi-release.yml
vendored
@@ -77,22 +77,22 @@ jobs:
|
||||
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
|
||||
poetry publish
|
||||
|
||||
- name: Create PR to update version in the branch
|
||||
run: |
|
||||
echo "### Description
|
||||
|
||||
This PR updates Prowler Version to ${{ env.RELEASE_TAG }}.
|
||||
|
||||
### License
|
||||
|
||||
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license." |\
|
||||
gh pr create \
|
||||
--base ${{ env.GITHUB_BASE_BRANCH }} \
|
||||
--head release-${{ env.RELEASE_TAG }} \
|
||||
--title "chore(release): update Prowler Version to ${{ env.RELEASE_TAG }}." \
|
||||
--body-file -
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.PROWLER_ACCESS_TOKEN }}
|
||||
- name: Create PR to update version in the branch
|
||||
run: |
|
||||
echo "### Description
|
||||
|
||||
This PR updates Prowler Version to ${{ env.RELEASE_TAG }}.
|
||||
|
||||
### License
|
||||
|
||||
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license." |\
|
||||
gh pr create \
|
||||
--base ${{ env.GITHUB_BASE_BRANCH }} \
|
||||
--head release-${{ env.RELEASE_TAG }} \
|
||||
--title "chore(release): update Prowler Version to ${{ env.RELEASE_TAG }}." \
|
||||
--body-file -
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.PROWLER_ACCESS_TOKEN }}
|
||||
|
||||
- name: Replicate PyPI package
|
||||
run: |
|
||||
|
||||
@@ -11,7 +11,7 @@ from prowler.lib.logger import logger
|
||||
|
||||
timestamp = datetime.today()
|
||||
timestamp_utc = datetime.now(timezone.utc).replace(tzinfo=timezone.utc)
|
||||
prowler_version = "3.15.1"
|
||||
prowler_version = "3.15.2"
|
||||
html_logo_url = "https://github.com/prowler-cloud/prowler/"
|
||||
html_logo_img = "https://user-images.githubusercontent.com/3985464/113734260-7ba06900-96fb-11eb-82bc-d4f68a1e2710.png"
|
||||
square_logo_img = "https://user-images.githubusercontent.com/38561120/235905862-9ece5bd7-9aa3-4e48-807a-3a9035eb8bfb.png"
|
||||
|
||||
@@ -20,7 +20,7 @@ class awslambda_function_invoke_api_operations_cloudtrail_logging_enabled(Check)
|
||||
f"Lambda function {function.name} is not recorded by CloudTrail."
|
||||
)
|
||||
lambda_recorded_cloudtrail = False
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
for data_event in trail.data_events:
|
||||
# classic event selectors
|
||||
if not data_event.is_advanced:
|
||||
|
||||
@@ -8,7 +8,7 @@ from prowler.providers.aws.services.s3.s3_client import s3_client
|
||||
class cloudtrail_bucket_requires_mfa_delete(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.is_logging:
|
||||
trail_bucket_is_in_account = False
|
||||
trail_bucket = trail.s3_bucket
|
||||
|
||||
@@ -11,7 +11,7 @@ maximum_time_without_logging = 1
|
||||
class cloudtrail_cloudwatch_logging_enabled(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.name:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = trail.region
|
||||
|
||||
@@ -7,7 +7,7 @@ from prowler.providers.aws.services.cloudtrail.cloudtrail_client import (
|
||||
class cloudtrail_insights_exist(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.is_logging:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = trail.region
|
||||
|
||||
@@ -7,7 +7,7 @@ from prowler.providers.aws.services.cloudtrail.cloudtrail_client import (
|
||||
class cloudtrail_kms_encryption_enabled(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.name:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = trail.region
|
||||
|
||||
@@ -7,7 +7,7 @@ from prowler.providers.aws.services.cloudtrail.cloudtrail_client import (
|
||||
class cloudtrail_log_file_validation_enabled(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.name:
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = trail.region
|
||||
|
||||
@@ -8,7 +8,7 @@ from prowler.providers.aws.services.s3.s3_client import s3_client
|
||||
class cloudtrail_logs_s3_bucket_access_logging_enabled(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.name:
|
||||
trail_bucket_is_in_account = False
|
||||
trail_bucket = trail.s3_bucket
|
||||
|
||||
@@ -8,7 +8,7 @@ from prowler.providers.aws.services.s3.s3_client import s3_client
|
||||
class cloudtrail_logs_s3_bucket_is_not_publicly_accessible(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.name:
|
||||
trail_bucket_is_in_account = False
|
||||
trail_bucket = trail.s3_bucket
|
||||
|
||||
@@ -10,8 +10,8 @@ class cloudtrail_multi_region_enabled(Check):
|
||||
for region in cloudtrail_client.regional_clients.keys():
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = region
|
||||
for trail in cloudtrail_client.trails:
|
||||
if trail.region == region:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.region == region or trail.is_multiregion:
|
||||
if trail.is_logging:
|
||||
report.status = "PASS"
|
||||
report.resource_id = trail.name
|
||||
|
||||
@@ -16,7 +16,7 @@ class cloudtrail_multi_region_enabled_logging_management_events(Check):
|
||||
report.resource_id = cloudtrail_client.audited_account
|
||||
report.resource_arn = cloudtrail_client.trail_arn_template
|
||||
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
if trail.is_logging:
|
||||
if trail.is_multiregion:
|
||||
for event in trail.data_events:
|
||||
|
||||
@@ -8,7 +8,7 @@ from prowler.providers.aws.services.s3.s3_client import s3_client
|
||||
class cloudtrail_s3_dataevents_read_enabled(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
for data_event in trail.data_events:
|
||||
# classic event selectors
|
||||
if not data_event.is_advanced:
|
||||
|
||||
@@ -8,7 +8,7 @@ from prowler.providers.aws.services.s3.s3_client import s3_client
|
||||
class cloudtrail_s3_dataevents_write_enabled(Check):
|
||||
def execute(self):
|
||||
findings = []
|
||||
for trail in cloudtrail_client.trails:
|
||||
for trail in cloudtrail_client.trails.values():
|
||||
for data_event in trail.data_events:
|
||||
# Classic event selectors
|
||||
if not data_event.is_advanced:
|
||||
|
||||
@@ -15,7 +15,7 @@ class Cloudtrail(AWSService):
|
||||
# Call AWSService's __init__
|
||||
super().__init__(__class__.__name__, audit_info)
|
||||
self.trail_arn_template = f"arn:{self.audited_partition}:cloudtrail:{self.region}:{self.audited_account}:trail"
|
||||
self.trails = []
|
||||
self.trails = {}
|
||||
self.__threading_call__(self.__get_trails__)
|
||||
self.__get_trail_status__()
|
||||
self.__get_insight_selectors__()
|
||||
@@ -45,27 +45,23 @@ class Cloudtrail(AWSService):
|
||||
kms_key_id = trail["KmsKeyId"]
|
||||
if "CloudWatchLogsLogGroupArn" in trail:
|
||||
log_group_arn = trail["CloudWatchLogsLogGroupArn"]
|
||||
self.trails.append(
|
||||
Trail(
|
||||
name=trail["Name"],
|
||||
is_multiregion=trail["IsMultiRegionTrail"],
|
||||
home_region=trail["HomeRegion"],
|
||||
arn=trail["TrailARN"],
|
||||
region=regional_client.region,
|
||||
is_logging=False,
|
||||
log_file_validation_enabled=trail[
|
||||
"LogFileValidationEnabled"
|
||||
],
|
||||
latest_cloudwatch_delivery_time=None,
|
||||
s3_bucket=trail["S3BucketName"],
|
||||
kms_key=kms_key_id,
|
||||
log_group_arn=log_group_arn,
|
||||
data_events=[],
|
||||
has_insight_selectors=trail.get("HasInsightSelectors"),
|
||||
)
|
||||
self.trails[trail["TrailARN"]] = Trail(
|
||||
name=trail["Name"],
|
||||
is_multiregion=trail["IsMultiRegionTrail"],
|
||||
home_region=trail["HomeRegion"],
|
||||
arn=trail["TrailARN"],
|
||||
region=regional_client.region,
|
||||
is_logging=False,
|
||||
log_file_validation_enabled=trail["LogFileValidationEnabled"],
|
||||
latest_cloudwatch_delivery_time=None,
|
||||
s3_bucket=trail["S3BucketName"],
|
||||
kms_key=kms_key_id,
|
||||
log_group_arn=log_group_arn,
|
||||
data_events=[],
|
||||
has_insight_selectors=trail.get("HasInsightSelectors"),
|
||||
)
|
||||
if trails_count == 0:
|
||||
self.trails.append(
|
||||
self.trails[self.__get_trail_arn_template__(regional_client.region)] = (
|
||||
Trail(
|
||||
region=regional_client.region,
|
||||
)
|
||||
@@ -79,7 +75,7 @@ class Cloudtrail(AWSService):
|
||||
def __get_trail_status__(self):
|
||||
logger.info("Cloudtrail - Getting trail status")
|
||||
try:
|
||||
for trail in self.trails:
|
||||
for trail in self.trails.values():
|
||||
for region, client in self.regional_clients.items():
|
||||
if trail.region == region and trail.name:
|
||||
status = client.get_trail_status(Name=trail.arn)
|
||||
@@ -97,7 +93,7 @@ class Cloudtrail(AWSService):
|
||||
def __get_event_selectors__(self):
|
||||
logger.info("Cloudtrail - Getting event selector")
|
||||
try:
|
||||
for trail in self.trails:
|
||||
for trail in self.trails.values():
|
||||
for region, client in self.regional_clients.items():
|
||||
if trail.region == region and trail.name:
|
||||
data_events = client.get_event_selectors(TrailName=trail.arn)
|
||||
@@ -131,7 +127,7 @@ class Cloudtrail(AWSService):
|
||||
logger.info("Cloudtrail - Getting trail insight selectors...")
|
||||
|
||||
try:
|
||||
for trail in self.trails:
|
||||
for trail in self.trails.values():
|
||||
for region, client in self.regional_clients.items():
|
||||
if trail.region == region and trail.name:
|
||||
insight_selectors = None
|
||||
@@ -180,7 +176,7 @@ class Cloudtrail(AWSService):
|
||||
def __list_tags_for_resource__(self):
|
||||
logger.info("CloudTrail - List Tags...")
|
||||
try:
|
||||
for trail in self.trails:
|
||||
for trail in self.trails.values():
|
||||
# Check if trails are in this account and region
|
||||
if (
|
||||
trail.region == trail.home_region
|
||||
|
||||
@@ -12,7 +12,7 @@ def check_cloudwatch_log_metric_filter(
|
||||
):
|
||||
# 1. Iterate for CloudWatch Log Group in CloudTrail trails
|
||||
log_groups = []
|
||||
for trail in trails:
|
||||
for trail in trails.values():
|
||||
if trail.log_group_arn:
|
||||
log_groups.append(trail.log_group_arn.split(":")[6])
|
||||
# 2. Describe metric filters for previous log groups
|
||||
|
||||
@@ -22,7 +22,7 @@ packages = [
|
||||
{include = "prowler"}
|
||||
]
|
||||
readme = "README.md"
|
||||
version = "3.15.1"
|
||||
version = "3.15.2"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
alive-progress = "3.1.5"
|
||||
|
||||
@@ -87,7 +87,7 @@ class Test_cloudtrail_cloudwatch_logging_enabled:
|
||||
cloudtrail_cloudwatch_logging_enabled,
|
||||
)
|
||||
|
||||
for trail in service_client.trails:
|
||||
for trail in service_client.trails.values():
|
||||
if trail.name == trail_name_us:
|
||||
trail.latest_cloudwatch_delivery_time = datetime.now().replace(
|
||||
tzinfo=timezone.utc
|
||||
@@ -174,7 +174,7 @@ class Test_cloudtrail_cloudwatch_logging_enabled:
|
||||
cloudtrail_cloudwatch_logging_enabled,
|
||||
)
|
||||
|
||||
for trail in service_client.trails:
|
||||
for trail in service_client.trails.values():
|
||||
if trail.name == trail_name_us:
|
||||
trail.latest_cloudwatch_delivery_time = datetime.now().replace(
|
||||
tzinfo=timezone.utc
|
||||
@@ -190,8 +190,8 @@ class Test_cloudtrail_cloudwatch_logging_enabled:
|
||||
|
||||
check = cloudtrail_cloudwatch_logging_enabled()
|
||||
result = check.execute()
|
||||
# len of result should be 3 -> (1 multiregion entry per region + 1 entry because of single region trail)
|
||||
assert len(result) == 3
|
||||
# len of result should be 2 -> (1 per trail)
|
||||
assert len(result) == 2
|
||||
for report in result:
|
||||
if report.resource_id == trail_name_us:
|
||||
assert report.resource_id == trail_name_us
|
||||
@@ -262,7 +262,7 @@ class Test_cloudtrail_cloudwatch_logging_enabled:
|
||||
cloudtrail_cloudwatch_logging_enabled,
|
||||
)
|
||||
|
||||
for trail in service_client.trails:
|
||||
for trail in service_client.trails.values():
|
||||
if trail.name == trail_name_us:
|
||||
trail.latest_cloudwatch_delivery_time = datetime.now().replace(
|
||||
tzinfo=timezone.utc
|
||||
|
||||
@@ -88,7 +88,7 @@ class Test_Cloudtrail_Service:
|
||||
)
|
||||
cloudtrail = Cloudtrail(audit_info)
|
||||
assert len(cloudtrail.trails) == 2
|
||||
for trail in cloudtrail.trails:
|
||||
for trail in cloudtrail.trails.values():
|
||||
if trail.name:
|
||||
assert trail.name == trail_name_us or trail.name == trail_name_eu
|
||||
assert not trail.is_multiregion
|
||||
@@ -145,7 +145,7 @@ class Test_Cloudtrail_Service:
|
||||
)
|
||||
cloudtrail = Cloudtrail(audit_info)
|
||||
assert len(cloudtrail.trails) == len(audit_info.audited_regions)
|
||||
for trail in cloudtrail.trails:
|
||||
for trail in cloudtrail.trails.values():
|
||||
if trail.name:
|
||||
if trail.name == trail_name_us:
|
||||
assert not trail.is_multiregion
|
||||
@@ -189,7 +189,7 @@ class Test_Cloudtrail_Service:
|
||||
)
|
||||
cloudtrail = Cloudtrail(audit_info)
|
||||
assert len(cloudtrail.trails) == len(audit_info.audited_regions)
|
||||
for trail in cloudtrail.trails:
|
||||
for trail in cloudtrail.trails.values():
|
||||
if trail.name:
|
||||
if trail.name == trail_name_us:
|
||||
assert not trail.is_multiregion
|
||||
@@ -237,7 +237,7 @@ class Test_Cloudtrail_Service:
|
||||
)
|
||||
cloudtrail = Cloudtrail(audit_info)
|
||||
assert len(cloudtrail.trails) == len(audit_info.audited_regions)
|
||||
for trail in cloudtrail.trails:
|
||||
for trail in cloudtrail.trails.values():
|
||||
if trail.name:
|
||||
if trail.name == trail_name_us:
|
||||
assert not trail.is_multiregion
|
||||
|
||||
Reference in New Issue
Block a user