chore(aws): add support for trusted aws accounts in cross account checks for s3, eventbridge bus, eventbridge schema and dynamodb #9692
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
As of present, cross account checks for aws in s3, eventbridge bus, eventbridge schema and dynamodb do not support a trusted account list. A trusted account list would help to reduce the noise on findings that have policies that have principals from other trusted accounts have them pass instead of fail.
Description
The major change made is to the
is_policy_public function(line 384 - 518) inprowler/providers/aws/services/iam/lib/policy.py. The following checks make use of theis_policy_publicfunction while passing through the argumentis_cross_account_allowed=False:The change majorly involves a logic change in adding a trusted account list that is iterated over and decides to flag the resource as public or private based on the passed trusted account list from the
config.yamlfile.Steps to review
is_policy_publicfunction ofprowler/providers/aws/services/iam/lib/policy.pytests/providers/aws/services/iam/lib/policy_test.pywith functionstest_cross_account_access_trusted_account_listandtest_cross_account_access_with_principal_list_trusted_account_listlines (1656 - 1697)Checklist
If so, do we need to update permissions for the provider? Please review this carefully.UI
API
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.