mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
- Move Security Hub related code to a dedicated include/securityhub_integration file - Check that Security Hub is enabled in the target region before beginning checks when -S is specified - Add error handling to the batch-import-findings call - Add CHECK_ASFF_TYPE variables to all CIS checks to override the default - Add support for CHECK_ASFF_RESOURCE_TYPE variables which override the default 'AwsAccount' value for the resource a finding relates to. - Add CHECK_ASFF_RESOURCE_TYPE variables to all checks where there is a suitable value in the schema - Remove json-asff output for info messages as they are not appropriate for possible submission to Security Hub - Update the README to cover Security Hub integration - Add an IAM policy JSON document that provides the necessary BatchImportFindings permission for Security Hub - Remove trailing whitespace and periods in pass/fail messages to be consistent with the majority of messages, to prevent future tidy-up from changing the finding IDs
44 lines
2.1 KiB
Bash
44 lines
2.1 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_check122="1.22"
|
|
CHECK_TITLE_check122="[check122] Ensure IAM policies that allow full \"*:*\" administrative privileges are not created (Scored)"
|
|
CHECK_SCORED_check122="SCORED"
|
|
CHECK_TYPE_check122="LEVEL1"
|
|
CHECK_ASFF_TYPE_check122="Software and Configuration Checks/Industry and Regulatory Standards/CIS AWS Foundations Benchmark"
|
|
CHECK_ASFF_RESOURCE_TYPE_check122="AwsIamPolicy"
|
|
CHECK_ALTERNATE_check122="check122"
|
|
|
|
check122(){
|
|
# "Ensure IAM policies that allow full \"*:*\" administrative privileges are not created (Scored)"
|
|
LIST_CUSTOM_POLICIES=$($AWSCLI iam list-policies --output text $PROFILE_OPT --region $REGION --scope Local --query 'Policies[*].[Arn,DefaultVersionId]' | grep -v -e '^None$' | awk -F '\t' '{print $1","$2"\n"}')
|
|
if [[ $LIST_CUSTOM_POLICIES ]]; then
|
|
textInfo "Looking for custom policies: (skipping default policies - it may take few seconds...)"
|
|
for policy in $LIST_CUSTOM_POLICIES; do
|
|
POLICY_ARN=$(echo $policy | awk -F ',' '{print $1}')
|
|
POLICY_VERSION=$(echo $policy | awk -F ',' '{print $2}')
|
|
POLICY_WITH_FULL=$($AWSCLI iam get-policy-version --output text --policy-arn $POLICY_ARN --version-id $POLICY_VERSION --query "[PolicyVersion.Document.Statement] | [] | [?Action!=null] | [?Effect == 'Allow' && Resource == '*' && Action == '*']" $PROFILE_OPT --region $REGION)
|
|
if [[ $POLICY_WITH_FULL ]]; then
|
|
POLICIES_ALLOW_LIST="$POLICIES_ALLOW_LIST $POLICY_ARN"
|
|
fi
|
|
done
|
|
if [[ $POLICIES_ALLOW_LIST ]]; then
|
|
textInfo "List of custom policies: "
|
|
for policy in $POLICIES_ALLOW_LIST; do
|
|
textFail "Policy $policy allows \"*:*\""
|
|
done
|
|
else
|
|
textPass "No custom policy found that allow full \"*:*\" administrative privileges"
|
|
fi
|
|
else
|
|
textPass "No custom policies found"
|
|
fi
|
|
}
|