mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 06:45:08 +00:00
61 lines
2.9 KiB
Bash
61 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Prowler - the handy cloud security tool (copyright 2019) by Toni de la Fuente
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
# use this file except in compliance with the License. You may obtain a copy
|
|
# of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software distributed
|
|
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations under the License.
|
|
|
|
CHECK_ID_check22="2.2"
|
|
CHECK_TITLE_check22="[check22] Ensure CloudTrail log file validation is enabled"
|
|
CHECK_SCORED_check22="SCORED"
|
|
CHECK_CIS_LEVEL_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"
|
|
CHECK_RISK_check22='Enabling log file validation will provide additional integrity checking of CloudTrail logs. '
|
|
CHECK_REMEDIATION_check22='Ensure LogFileValidationEnabled is set to true for each trail.'
|
|
CHECK_DOC_check22='http://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-log-filevalidation-enabling.html'
|
|
CHECK_CAF_EPIC_check22='Logging and Monitoring'
|
|
|
|
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 2>&1 | tr " " ',')
|
|
if [[ $(echo "$TRAILS_AND_REGIONS" | grep AccessDenied) ]]; then
|
|
textInfo "$regx: Access Denied trying to describe trails" "$regx" "$trail"
|
|
continue
|
|
fi
|
|
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 "$regx: Trail $trail log file validation disabled" "$regx" "$trail"
|
|
else
|
|
textPass "$regx: Trail $trail log file validation enabled" "$regx" "$trail"
|
|
fi
|
|
|
|
done
|
|
fi
|
|
done
|
|
if [[ $trail_count == 0 ]]; then
|
|
textFail "$REGION: No CloudTrail trails were found in the account" "$REGION" "$trail"
|
|
fi
|
|
}
|