mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
40 lines
2.0 KiB
Bash
40 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_check123="1.23"
|
|
CHECK_TITLE_check123="[check123] Do not setup access keys during initial user setup for all IAM users that have a console password (Not Scored)"
|
|
CHECK_SCORED_check123="NOT_SCORED"
|
|
CHECK_ALTERNATE_check123="check123"
|
|
|
|
check123(){
|
|
# "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_USERS_KEY1_ACTIVE=$(for user in $LIST_USERS_KEY1_NA; do grep "^${user}," $TEMP_REPORT_FILE|awk -F, '{ print $1,$9 }'|grep "true$"|awk '{ print $1 }'|sed 's/[[:blank:]]+/,/g' ; done)
|
|
if [[ $LIST_USERS_KEY1_ACTIVE ]]; then
|
|
for user in $LIST_USERS_KEY1_ACTIVE; do
|
|
textInfo "$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_USERS_KEY2_ACTIVE=$(for user in $LIST_USERS_KEY2_NA; do grep "^${user}," $TEMP_REPORT_FILE|awk -F, '{ print $1,$14 }'|grep "true$" |awk '{ print $1 }' ; done)
|
|
if [[ $LIST_USERS_KEY2_ACTIVE ]]; then
|
|
for user in $LIST_USERS_KEY2_ACTIVE; do
|
|
textInfo "$user has never used Access Key 2"
|
|
done
|
|
else
|
|
textPass "No users found with Access Key 2 never used"
|
|
fi
|
|
}
|