mirror of
https://github.com/prowler-cloud/prowler.git
synced 2025-12-19 05:17:47 +00:00
41 lines
1.8 KiB
Bash
41 lines
1.8 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_check28="2.8,2.08"
|
|
CHECK_TITLE_check28="[check28] Ensure rotation for customer created CMKs is enabled (Scored)"
|
|
CHECK_SCORED_check28="SCORED"
|
|
CHECK_ALTERNATE_check208="check28"
|
|
|
|
check28(){
|
|
# "Ensure rotation for customer created CMKs is enabled (Scored)"
|
|
for regx in $REGIONS; do
|
|
CHECK_KMS_KEYLIST=$($AWSCLI kms list-keys $PROFILE_OPT --region $regx --output text --query 'Keys[*].KeyId')
|
|
if [[ $CHECK_KMS_KEYLIST ]];then
|
|
CHECK_KMS_KEYLIST_NO_DEFAULT=$(for key in $CHECK_KMS_KEYLIST ; do $AWSCLI kms describe-key --key-id $key $PROFILE_OPT --region $regx --output text --query 'KeyMetadata.[KeyId, KeyManager]'|grep -v 'AWS'|awk '{ print $1 }'; done)
|
|
for key in $CHECK_KMS_KEYLIST_NO_DEFAULT; do
|
|
CHECK_KMS_KEY_TYPE=$($AWSCLI kms describe-key --key-id $key $PROFILE_OPT --region $regx --query 'KeyMetadata.Origin' | sed 's/["]//g')
|
|
if [[ "$CHECK_KMS_KEY_TYPE" == "EXTERNAL" ]];then
|
|
textPass "Key $key in Region $regx Customer Uploaded Key Material." "$regx"
|
|
else
|
|
CHECK_KMS_KEY_ROTATION=$($AWSCLI kms get-key-rotation-status --key-id $key $PROFILE_OPT --region $regx --output text)
|
|
if [[ "$CHECK_KMS_KEY_ROTATION" == "True" ]];then
|
|
textPass "Key $key in Region $regx is set correctly"
|
|
else
|
|
textFail "Key $key in Region $regx is not set to rotate!!!" "$regx"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
else
|
|
textInfo "Region $regx doesn't have encryption keys" "$regx"
|
|
fi
|
|
done
|
|
}
|