mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-11 15:25:10 +00:00
50 lines
2.0 KiB
Bash
50 lines
2.0 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Prowler - the handy cloud security tool (c) by Toni de la Fuente
|
|
#
|
|
# This Prowler check is licensed under a
|
|
# Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
#
|
|
# You should have received a copy of the license along with this
|
|
# work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
|
|
|
|
CHECK_ID_check22="2.2"
|
|
CHECK_TITLE_check22="[check22] Ensure CloudTrail log file validation is enabled (Scored)"
|
|
CHECK_SCORED_check22="SCORED"
|
|
CHECK_TYPE_check22="LEVEL2"
|
|
CHECK_SEVERITY_check22="Medium"
|
|
CHECK_ASFF_TYPE_check22="Software and Configuration Checks/Industry and Regulatory Standards/CIS AWS Foundations Benchmark"
|
|
CHECK_ASFF_RESOURCE_TYPE_check22="AwsCloudTrailTrail"
|
|
CHECK_ALTERNATE_check202="check22"
|
|
CHECK_ASFF_COMPLIANCE_TYPE_check22="ens-op.exp.10.aws.trail.1"
|
|
CHECK_SERVICENAME_check22="cloudtrail"
|
|
|
|
check22(){
|
|
trail_count=0
|
|
# "Ensure CloudTrail log file validation is enabled (Scored)"
|
|
for regx in $REGIONS; do
|
|
TRAILS_AND_REGIONS=$($AWSCLI cloudtrail describe-trails $PROFILE_OPT --region $regx --query 'trailList[*].{Name:TrailARN, HomeRegion:HomeRegion}' --output text | tr " " ',')
|
|
if [[ $TRAILS_AND_REGIONS ]]; then
|
|
for reg_trail in $TRAILS_AND_REGIONS; do
|
|
TRAIL_REGION=$(echo $reg_trail | cut -d',' -f1)
|
|
if [ $TRAIL_REGION != $regx ]; then # Only report trails once in home region
|
|
continue
|
|
fi
|
|
trail=$(echo $reg_trail | cut -d',' -f2)
|
|
trail_count=$((trail_count + 1))
|
|
|
|
LOGFILEVALIDATION_TRAIL_STATUS=$($AWSCLI cloudtrail describe-trails $PROFILE_OPT --region $TRAIL_REGION --query 'trailList[*].LogFileValidationEnabled' --output text --trail-name-list $trail)
|
|
if [[ "$LOGFILEVALIDATION_TRAIL_STATUS" == 'False' ]];then
|
|
textFail "Trail $trail in $regx has not log file validation enabled"
|
|
else
|
|
textPass "Trail $trail in $regx has log file validation enabled"
|
|
fi
|
|
|
|
done
|
|
fi
|
|
done
|
|
if [[ $trail_count == 0 ]]; then
|
|
textFail "No CloudTrail trails were found in the account"
|
|
fi
|
|
}
|