mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-12 07:45:16 +00:00
Fix finding customer kms keys in cli v2 for checks extra737 extra736
Key id is in position 6 in aws cli version 2.2.5, but in position 4 in aws cli 1.x Use --query to select only the data necessary and output in a consistent format
This commit is contained in:
@@ -19,7 +19,7 @@ CHECK_ALTERNATE_check736="extra736"
|
|||||||
extra736(){
|
extra736(){
|
||||||
textInfo "Looking for KMS keys in all regions... "
|
textInfo "Looking for KMS keys in all regions... "
|
||||||
for regx in $REGIONS; do
|
for regx in $REGIONS; do
|
||||||
LIST_OF_CUSTOMER_KMS_KEYS=$($AWSCLI kms list-aliases $PROFILE_OPT --region $regx --output text |grep -v :alias/aws/ |awk '{ print $4 }')
|
LIST_OF_CUSTOMER_KMS_KEYS=$($AWSCLI kms list-aliases $PROFILE_OPT --region $regx --query "Aliases[].[AliasName,TargetKeyId]" --output text |grep -v ^alias/aws/ |awk '{ print $2 }')
|
||||||
if [[ $LIST_OF_CUSTOMER_KMS_KEYS ]];then
|
if [[ $LIST_OF_CUSTOMER_KMS_KEYS ]];then
|
||||||
for key in $LIST_OF_CUSTOMER_KMS_KEYS; do
|
for key in $LIST_OF_CUSTOMER_KMS_KEYS; do
|
||||||
CHECK_POLICY=$($AWSCLI kms get-key-policy --key-id $key --policy-name default $PROFILE_OPT --region $regx --output text|awk '/Principal/{n=NR+1} n>=NR' |grep AWS\"\ :\ \"\\*\"$)
|
CHECK_POLICY=$($AWSCLI kms get-key-policy --key-id $key --policy-name default $PROFILE_OPT --region $regx --output text|awk '/Principal/{n=NR+1} n>=NR' |grep AWS\"\ :\ \"\\*\"$)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ CHECK_ALTERNATE_check737="extra737"
|
|||||||
extra737(){
|
extra737(){
|
||||||
textInfo "Looking for KMS keys in all regions... "
|
textInfo "Looking for KMS keys in all regions... "
|
||||||
for regx in $REGIONS; do
|
for regx in $REGIONS; do
|
||||||
LIST_OF_CUSTOMER_KMS_KEYS=$($AWSCLI kms list-aliases $PROFILE_OPT --region $regx --output text |grep -v :alias/aws/ |awk '{ print $4 }')
|
LIST_OF_CUSTOMER_KMS_KEYS=$($AWSCLI kms list-aliases $PROFILE_OPT --region $regx --query "Aliases[].[AliasName,TargetKeyId]" --output text |grep -v ^alias/aws/ |awk '{ print $2 }')
|
||||||
if [[ $LIST_OF_CUSTOMER_KMS_KEYS ]];then
|
if [[ $LIST_OF_CUSTOMER_KMS_KEYS ]];then
|
||||||
for key in $LIST_OF_CUSTOMER_KMS_KEYS; do
|
for key in $LIST_OF_CUSTOMER_KMS_KEYS; do
|
||||||
CHECK_ROTATION=$($AWSCLI kms get-key-rotation-status --key-id $key $PROFILE_OPT --region $regx --output text)
|
CHECK_ROTATION=$($AWSCLI kms get-key-rotation-status --key-id $key $PROFILE_OPT --region $regx --output text)
|
||||||
|
|||||||
Reference in New Issue
Block a user