Skip to content

Commit 165c7bb

Browse files
committed
shellcheck'ed
Ran shellcheck (shellcheck.net) on all of these scripts.
1 parent 88a78da commit 165c7bb

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

EC2/instances.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#List Instances In Each Region.
3-
for region in `aws ec2 describe-regions --output text | cut -f3`
3+
for region in $(aws ec2 describe-regions --output text | cut -f3)
44
do
5-
aws ec2 describe-instances --region $region --output text --query 'Reservations[*].Instances[*].[Placement.AvailabilityZone, InstanceId, InstanceType, ImageId, PublicIpAddress ]'
5+
aws ec2 describe-instances --region "$region" --output text --query 'Reservations[*].Instances[*].[Placement.AvailabilityZone, InstanceId, InstanceType, ImageId, PublicIpAddress ]'
66
done

EC2/noingress.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
#Find Bad Network Rules:
44
Open=$(aws ec2 describe-security-groups --filters "Name=ip-permission.cidr,Values=0.0.0.0/0" --query "SecurityGroups[].[GroupId, GroupName]" --output text)
55

6-
#Clear The Screen to make it pretty.
7-
printf "\033c"
6+
#Add a line
7+
printf "\n"
88

99
#Display Title.
1010
printf "The Following Security Groups Have No Ingress Filtering: \033[0K\r"
1111
printf '\n'
1212

1313
while read -r line; do
14-
GroupId=$(echo $line | awk '{print $1;}')
15-
GroupName=$(echo $line | awk '{print $2;}')
14+
GroupId=$(echo "$line" | awk '{print $1;}')
15+
GroupName=$(echo "$line" | awk '{print $2;}')
1616
Count=$(aws ec2 describe-network-interfaces --filters "Name=group-id,Values=$GroupId" --query "length(NetworkInterfaces)" --output text)
1717
if [[ $Count -ne 0 ]]
1818
then
19-
printf "$GroupName($GroupId) is being used on $Count EC2 Server(s)."
19+
printf "%s(%s) is being used on %s EC2 Server(s)." "$GroupName" "$GroupId" "$Count"
2020
printf '\n'
2121
else
2222
:

EC2/notused.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#!/bin/bash
22

33
#List SecurityGroups:
4-
Open=$(aws --profile Alpha ec2 describe-security-groups --query "SecurityGroups[].[GroupId, GroupName]" --output text)
4+
Open=$(aws ec2 describe-security-groups --query "SecurityGroups[].[GroupId, GroupName]" --output text)
55

6-
#Clear The Screen to make it pretty.
7-
printf "\033c"
6+
#Add a line
7+
printf "\n"
88

99
#Display Title.
1010
printf "The Following Security Groups Are Not Used: \033[0K\r"
1111
printf '\n'
1212

1313
while read -r line; do
14-
GroupId=$(echo $line | awk '{print $1;}')
15-
GroupName=$(echo $line | awk '{print $2;}')
14+
GroupId=$(echo "$line" | awk '{print $1;}')
15+
GroupName=$(echo "$line" | awk '{print $2;}')
1616
Count=$(aws ec2 describe-network-interfaces --filters "Name=group-id,Values=$GroupId" --query "length(NetworkInterfaces)" --output text)
1717
if [[ $Count -ne 0 ]]
1818
then
1919
:
2020
else
21-
printf "$GroupName($GroupId)"
21+
printf "%s(%s)" "$GroupName" "$GroupId"
2222
printf '\n'
2323
fi
2424
done <<< "$Open"

WAF/waf.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
#!/bin/bash
22
# Creates a WAF in AWS via CloudFromation
3-
# Remove >> /dev/null for verbose output.
3+
# Remove >> /dev/null for verbose output.
44

55
STACKNAME=$1
66

7-
#Uncomment 1 Line Below To Select Rule Set:
7+
#Uncomment 1 Line Below To Select Rule Set:
88

9-
#OWASP Default Rules:
9+
#OWASP Default Rules:
1010
TEMPLATELOCATION=https://raw.githubusercontent.com/awslabs/aws-waf-sample/master/waf-owasp-top-10/owasp_10_base.yml
1111

12-
#AWS Deafult Rules:
12+
#AWS Deafult Rules:
1313
#TEMPLATELOCATION=https://s3.amazonaws.com/solutions-reference/aws-waf-security-automations/latest/aws-waf-security-automations.template
1414

1515
#VILIDATION:
1616
printf '\n'
1717
printf "Validating WAF Template. \033[0K\r"
1818
printf '\n'
19-
aws cloudformation validate-template --template-body $TEMPLATELOCATION >> /dev/null
19+
aws cloudformation validate-template --template-body "$TEMPLATELOCATION" >> /dev/null
2020

2121
#CREATING STACK:
2222
printf '\n'
23-
printf "Creating WAF Template: \033[0K\r"
23+
printf "Creating WAF Template: \033[0K\r"
2424
printf '\n'
25-
aws cloudformation create-stack --stack-name $STACKNAME --template-body $TEMPLATELOCATION --capabilities CAPABILITY_NAMED_IAM
25+
aws cloudformation create-stack --stack-name "$STACKNAME" --template-body "$TEMPLATELOCATION" --capabilities CAPABILITY_NAMED_IAM
2626

2727
printf '\n'
2828
printf "Done! Check Cloud Formation Console For Build Process.\033[0K\r"
29-
printf '\n'
29+
printf '\n'

0 commit comments

Comments
 (0)