mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-11 15:25:10 +00:00
49 lines
2.6 KiB
Bash
49 lines
2.6 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Prowler - the handy cloud security tool (copyright 2018) by Toni de la Fuente
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
# use this file except in compliance with the License. You may obtain a copy
|
|
# of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software distributed
|
|
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations under the License.
|
|
CHECK_ID_extra7124="7.124"
|
|
CHECK_TITLE_extra7124="[extra7124] Check if EC2 instances are managed by Systems Manager."
|
|
CHECK_SCORED_extra7124="NOT_SCORED"
|
|
CHECK_TYPE_extra7124="EXTRA"
|
|
CHECK_SEVERITY_extra7124="Medium"
|
|
CHECK_ASFF_RESOURCE_TYPE_extra7124="AwsEc2Instance"
|
|
CHECK_ALTERNATE_check7124="extra7124"
|
|
CHECK_ASFF_COMPLIANCE_TYPE_extra7124="ens-op.exp.1.aws.sys.1 ens-op.acc.4.aws.sys.1"
|
|
CHECK_SERVICENAME_extra7124="ssm"
|
|
CHECK_RISK_extra7124='AWS Config provides AWS Managed Rules; which are predefined; customizable rules that AWS Config uses to evaluate whether your AWS resource configurations comply with common best practices.'
|
|
CHECK_REMEDIATION_extra7124='Verify and apply Systems Manager Prerequisites.'
|
|
CHECK_DOC_extra7124='https://docs.aws.amazon.com/systems-manager/latest/userguide/managed_instances.html'
|
|
CHECK_CAF_EPIC_extra7124='Infrastructure Security'
|
|
|
|
extra7124(){
|
|
for regx in $REGIONS; do
|
|
# Filters running instances only
|
|
LIST_EC2_INSTANCES=$($AWSCLI ec2 describe-instances $PROFILE_OPT --query 'Reservations[*].Instances[*].[InstanceId]' --filters Name=instance-state-name,Values=running --region $regx --output text)
|
|
if [[ $LIST_EC2_INSTANCES ]]; then
|
|
LIST_SSM_MANAGED_INSTANCES=$($AWSCLI ssm describe-instance-information $PROFILE_OPT --query "InstanceInformationList[].InstanceId" --region $regx | jq -r '.[]')
|
|
LIST_EC2_UNMANAGED=$(echo ${LIST_SSM_MANAGED_INSTANCES[@]} ${LIST_EC2_INSTANCES[@]} | tr ' ' '\n' | sort | uniq -u)
|
|
if [[ $LIST_EC2_UNMANAGED ]]; then
|
|
for instance in $LIST_EC2_UNMANAGED; do
|
|
textFail "$regx: EC2 instance $instance is not managed by Systems Manager" "$regx"
|
|
done
|
|
fi
|
|
if [[ $LIST_SSM_MANAGED_INSTANCES ]]; then
|
|
for instance in $LIST_SSM_MANAGED_INSTANCES; do
|
|
textPass "$regx: EC2 instance $instance is managed by Systems Manager" "$regx"
|
|
done
|
|
fi
|
|
else
|
|
textInfo "$regx: No EC2 instances running found" "$regx"
|
|
fi
|
|
done
|
|
}
|