mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 23:05:05 +00:00
Use TrailARN property to query get-event-selectors in checks_extra725
This will work to query cloudtrail's that are in different accounts. e.g. in the case of organisation managed cloudtrails.
This commit is contained in:
@@ -33,15 +33,15 @@ extra725(){
|
||||
# now create a list with all trails available and their region
|
||||
TEMP_TRAILS_LIST_FILE=$(mktemp -t prowler.trails-list-XXXXXX)
|
||||
for regx in $REGIONS; do
|
||||
$AWSCLI cloudtrail describe-trails $PROFILE_OPT --region $regx --query trailList[?HomeRegion==\`$regx\`].[Name,HomeRegion] --output text >> $TEMP_TRAILS_LIST_FILE
|
||||
$AWSCLI cloudtrail describe-trails $PROFILE_OPT --region $regx --query trailList[?HomeRegion==\`$regx\`].[TrailARN,HomeRegion] --output text >> $TEMP_TRAILS_LIST_FILE
|
||||
done
|
||||
|
||||
# look for buckets being logged per trail and create a list with them
|
||||
TEMP_BUCKETS_LOGGING_LIST_FILE=$(mktemp -t prowler.buckets-logging-list-XXXXXX)
|
||||
while IFS='' read -r LINE || [[ -n "${LINE}" ]]; do
|
||||
TRAIL_REGION=$(echo "${LINE}" | awk '{ print $2 }')
|
||||
TRAIL_NAME=$(echo "${LINE}" | awk '{ print $1 }')
|
||||
BUCKETS_OBJECT_LOGGING_ENABLED=$($AWSCLI cloudtrail get-event-selectors --trail-name "${TRAIL_NAME}" $PROFILE_OPT --region $TRAIL_REGION --query "EventSelectors[*].DataResources[?Type == \`AWS::S3::Object\`].Values" --output text |xargs -n1 |cut -d: -f 6|sed 's/\///g')
|
||||
TRAIL_ARN=$(echo "${LINE}" | awk '{ print $1 }')
|
||||
BUCKETS_OBJECT_LOGGING_ENABLED=$($AWSCLI cloudtrail get-event-selectors --trail-name "${TRAIL_ARN}" $PROFILE_OPT --region $TRAIL_REGION --query "EventSelectors[*].DataResources[?Type == \`AWS::S3::Object\`].Values" --output text |xargs -n1 |cut -d: -f 6|sed 's/\///g')
|
||||
echo $BUCKETS_OBJECT_LOGGING_ENABLED |tr " " "\n"|sort >> $TEMP_BUCKETS_LOGGING_LIST_FILE
|
||||
if [[ $BUCKETS_OBJECT_LOGGING_ENABLED ]]; then
|
||||
for bucket in $BUCKETS_OBJECT_LOGGING_ENABLED; do
|
||||
|
||||
Reference in New Issue
Block a user