mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 23:05:05 +00:00
45 lines
2.4 KiB
Bash
45 lines
2.4 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Prowler - the handy cloud security tool (copyright 2019) 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_extra758="7.58"
|
|
CHECK_TITLE_extra758="[extra758] Check EC2 Instances older than 12 months "
|
|
CHECK_SCORED_extra758="NOT_SCORED"
|
|
CHECK_CIS_LEVEL_extra758="EXTRA"
|
|
CHECK_SEVERITY_extra758="Medium"
|
|
CHECK_ASFF_RESOURCE_TYPE_extra758="AwsEc2Instance"
|
|
CHECK_ALTERNATE_check758="extra758"
|
|
CHECK_SERVICENAME_extra758="ec2"
|
|
CHECK_RISK_extra758='Having old instances within your AWS account could increase the risk of having vulnerable software.'
|
|
CHECK_REMEDIATION_extra758='Check if software running in the instance is up to date and patched accordingly. Use AWS Systems Manager to patch instances and view patching compliance information.'
|
|
CHECK_DOC_extra758='https://docs.aws.amazon.com/systems-manager/latest/userguide/viewing-patch-compliance-results.html'
|
|
CHECK_CAF_EPIC_extra758='Infrastructure Security'
|
|
|
|
extra758(){
|
|
# OLDAGE has the following format: YYYY-MM-DD
|
|
OLDAGE="$(get_date_previous_than_months 12)"
|
|
for regx in ${REGIONS}; do
|
|
INSTACES_OLD_THAN_AGE=$("${AWSCLI}" ec2 describe-instances --query "Reservations[].Instances[?LaunchTime<='${OLDAGE}'][].[InstanceId, LaunchTime, State.Name]" ${PROFILE_OPT} --region "${regx}" --output text 2>&1)
|
|
if [[ $(echo "${INSTACES_OLD_THAN_AGE}" | grep -E 'AccessDenied|UnauthorizedOperation|AuthorizationError') ]]; then
|
|
textInfo "${regx}: Access Denied trying to describe instances" "${regx}"
|
|
continue
|
|
fi
|
|
if [[ "${INSTACES_OLD_THAN_AGE}" ]]; then
|
|
while read -r EC2_ID LAUNCH_DATE STATE
|
|
do
|
|
textFail "${regx}: EC2 Instance ${EC2_ID} launched before than ${OLDAGE}. Launch date: ${LAUNCH_DATE} - State: ${STATE}" "${regx}" "${EC2_ID}"
|
|
done <<< "${INSTACES_OLD_THAN_AGE}"
|
|
else
|
|
textPass "${regx}: No EC2 Instances found older than 12 months" "${regx}"
|
|
fi
|
|
done
|
|
}
|