Skip to content

Commit

Permalink
Merge branch 'bridgecrewio-fix-check11'
Browse files Browse the repository at this point in the history
  • Loading branch information
toniblyx committed Feb 12, 2020
2 parents b9a4f2c + 35fc8cd commit 4d683a7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions checks/check11
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ CHECK_ALTERNATE_check101="check11"

check11(){
# "Avoid the use of the root account (Scored)."
COMMAND11=$(cat $TEMP_REPORT_FILE| grep '<root_account>' | cut -d, -f5,11,16 | sed 's/,/\ /g')
textInfo "Root account last accessed (password key_1 key_2): $COMMAND11"
MAX_DAYS=-1
last_login_date=$(cat $TEMP_REPORT_FILE|awk -F, '{ print $1,$5 }' |grep '<root_account>' | awk '{ print $2 }')
arn=$(cat $TEMP_REPORT_FILE|awk -F, '{ print $1,$2 }' |grep '<root_account>' | awk '{ print $2 }')

#check if last_login_date date is a valid date, if not, its a pass.
if [[ ${last_login_date%T*} =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]];then
days_not_in_use=$(how_many_days_from_today ${last_login_date%T*})
if [ "$days_not_in_use" -gt "$MAX_DAYS" ];then
textFail "Root Account $arn last accessed was less then ${MAX_DAYS#-} day ago"
else
textPass "Root Account $arn last accessed was more then ${MAX_DAYS#-} day ago"
fi
else
textPass "Root Account $arn last accessed was more then ${MAX_DAYS#-} day ago"
fi

}

0 comments on commit 4d683a7

Please sign in to comment.