mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
Create `include/check_creds_last_used` and move all logic for checking last usages of passwords and access keys there Modify check13 and extra774 to call new function, specifying time-range of last 90 days and last 30 days respectively Modify messages in check14 and check121 so that all mentions of 'access key's are consistent Fixes #496
45 lines
2.4 KiB
Bash
45 lines
2.4 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_check121="1.21"
|
|
CHECK_TITLE_check121="[check121] Do not setup access keys during initial user setup for all IAM users that have a console password (Not Scored)"
|
|
CHECK_SCORED_check121="NOT_SCORED"
|
|
CHECK_TYPE_check121="LEVEL1"
|
|
CHECK_ASFF_TYPE_check121="Software and Configuration Checks/Industry and Regulatory Standards/CIS AWS Foundations Benchmark"
|
|
CHECK_ASFF_RESOURCE_TYPE_check121="AwsIamUser"
|
|
CHECK_ALTERNATE_check121="check121"
|
|
|
|
check121(){
|
|
# "Do not setup access keys during initial user setup for all IAM users that have a console password (Not Scored)"
|
|
LIST_USERS=$($AWSCLI iam list-users --query 'Users[*].UserName' --output text $PROFILE_OPT --region $REGION)
|
|
# List of USERS with KEY1 last_used_date as N/A
|
|
LIST_USERS_KEY1_NA=$(for user in $LIST_USERS; do grep "^${user}," $TEMP_REPORT_FILE|awk -F, '{ print $1,$11 }'|grep N/A |awk '{ print $1 }'; done)
|
|
# List of USERS with KEY1 active, last_used_date as N/A and have a console password
|
|
LIST_USERS_KEY1_ACTIVE=$(for user in $LIST_USERS_KEY1_NA; do grep "^${user}," $TEMP_REPORT_FILE|awk -F, '{ print $1,$4,$9 }'|grep "true true$"|awk '{ print $1 }'|sed 's/[[:blank:]]+/,/g' ; done)
|
|
if [[ $LIST_USERS_KEY1_ACTIVE ]]; then
|
|
for user in $LIST_USERS_KEY1_ACTIVE; do
|
|
textFail "User $user has never used access key 1"
|
|
done
|
|
else
|
|
textPass "No users found with access key 1 never used"
|
|
fi
|
|
# List of USERS with KEY2 last_used_date as N/A
|
|
LIST_USERS_KEY2_NA=$(for user in $LIST_USERS; do grep "^${user}," $TEMP_REPORT_FILE|awk -F, '{ print $1,$16 }'|grep N/A |awk '{ print $1 }' ; done)
|
|
# List of USERS with KEY2 active, last_used_date as N/A and have a console password
|
|
LIST_USERS_KEY2_ACTIVE=$(for user in $LIST_USERS_KEY2_NA; do grep "^${user}," $TEMP_REPORT_FILE|awk -F, '{ print $1,$4,$14 }'|grep "true true$" |awk '{ print $1 }' ; done)
|
|
if [[ $LIST_USERS_KEY2_ACTIVE ]]; then
|
|
for user in $LIST_USERS_KEY2_ACTIVE; do
|
|
textFail "User $user has never used access key 2"
|
|
done
|
|
else
|
|
textPass "No users found with access key 2 never used"
|
|
fi
|
|
}
|