-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New check 7162 CloudWatch log groups have 365 days retention @Obiakara
New check 7162 CloudWatch log groups have 365 days retention @Obiakara
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Prowler - the handy cloud security tool (copyright 2018) 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_extra7162="7.162" | ||
CHECK_TITLE_extra7162="[extra7162] Check if CloudWatch Log Groups have a retention policy of 365 days" | ||
CHECK_SCORED_extra7162="NOT_SCORED" | ||
CHECK_CIS_LEVEL_extra7162="EXTRA" | ||
CHECK_SEVERITY_extra7162="Medium" | ||
CHECK_ASFF_RESOURCE_TYPE_extra7162="AwsLogsLogGroup" | ||
CHECK_ALTERNATE_check7162="extra7162" | ||
CHECK_SERVICENAME_extra7162="cloudwatch" | ||
CHECK_RISK_extra7162='If log groups have a low retention policy of less than 365 days, crucial logs and data can be lost' | ||
CHECK_REMEDIATION_extra7162='Add Log Retention policy of 365 days to log groups. This will persist logs and traces for a long time.' | ||
CHECK_DOC_extra7162='https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Logs.html' | ||
CHECK_CAF_EPIC_extra7162='Data Retention' | ||
|
||
extra7162() { | ||
# "Check if CloudWatch Log Groups have a retention policy of 365 days" | ||
declare -i LOG_GROUP_RETENTION_PERIOD_DAYS=365 | ||
for regx in $REGIONS; do | ||
LIST_OF_365_RETENTION_LOG_GROUPS=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --query 'logGroups[?retentionInDays=="${LOG_GROUP_RETENTION_PERIOD_DAYS}"].[logGroupName]' --output text) | ||
if [[ $LIST_OF_365_RETENTION_LOG_GROUPS ]]; then | ||
for log in $LIST_OF_365_RETENTION_LOG_GROUPS; do | ||
textPass "$regx: $log Log Group has 365 days retention period!" "$regx" "$log" | ||
done | ||
fi | ||
LIST_OF_NON_365_RETENTION_LOG_GROUPS=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --query 'logGroups[?retentionInDays!="${LOG_GROUP_RETENTION_PERIOD_DAYS}"].[logGroupName]' --output text) | ||
if [[ $LIST_OF_NON_365_RETENTION_LOG_GROUPS ]]; then | ||
for log in $LIST_OF_NON_365_RETENTION_LOG_GROUPS; do | ||
textFail "$regx: $log Log Group does not have 365 days retention period!" "$regx" "$log" | ||
done | ||
fi | ||
REGION_NO_LOG_GROUP=$($AWSCLI logs describe-log-groups $PROFILE_OPT --region $regx --output text) | ||
if [[ $REGION_NO_LOG_GROUP ]]; then | ||
: | ||
else | ||
textInfo "$regx does not have a Log Group!" "$regx" | ||
|
||
fi | ||
done | ||
} |