mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
39 lines
2.1 KiB
Bash
39 lines
2.1 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_check36="3.6,3.06"
|
|
CHECK_TITLE_check36="[check36] Ensure a log metric filter and alarm exist for AWS Management Console authentication failures (Scored)"
|
|
CHECK_SCORED_check36="SCORED"
|
|
CHECK_ALTERNATE_check306="check36"
|
|
|
|
check36(){
|
|
# "Ensure a log metric filter and alarm exist for AWS Management Console authentication failures (Scored)"
|
|
CLOUDWATCH_GROUP=$($AWSCLI cloudtrail describe-trails $PROFILE_OPT --region $REGION --query 'trailList[*].CloudWatchLogsLogGroupArn' --output text | tr ' ' '
|
|
' | awk -F: '{ print $7 }')
|
|
if [[ $CLOUDWATCH_GROUP ]];then
|
|
for group in $CLOUDWATCH_GROUP; do
|
|
CLOUDWATCH_LOGGROUP_REGION=$($AWSCLI cloudtrail describe-trails $PROFILE_OPT --region $REGION --query 'trailList[*].CloudWatchLogsLogGroupArn' --output text | awk -F: '{ print $4 }')
|
|
METRICFILTER_SET=$($AWSCLI logs describe-metric-filters --log-group-name $group $PROFILE_OPT --region $CLOUDWATCH_LOGGROUP_REGION --query 'metricFilters' | grep -E 'ConsoleLogin.*Failed')
|
|
if [[ $METRICFILTER_SET ]];then
|
|
HAS_ALARM_ASSOCIATED=$($AWSCLI cloudwatch describe-alarms $PROFILE_OPT --region $CLOUDWATCH_LOGGROUP_REGION --query 'MetricAlarms[].MetricName' --output text | awk 'BEGIN {IGNORECASE=1}; /FailedLogin/ || /ConsoleLogin/ || /Failed/;')
|
|
if [[ $HAS_ALARM_ASSOCIATED ]];then
|
|
textPass "CloudWatch group $group found with metric filters and alarms for AWS Management Console authentication failures"
|
|
else
|
|
textFail "CloudWatch group $group found with metric filters but no alarms associated"
|
|
fi
|
|
else
|
|
textFail "CloudWatch group $group found but no metric filters or alarms associated"
|
|
fi
|
|
done
|
|
else
|
|
textFail "No CloudWatch group found for CloudTrail events"
|
|
fi
|
|
}
|