widdix / aws-ec2-ssh

Manage AWS EC2 SSH access with IAM

Home Page:https://cloudonaut.io/manage-aws-ec2-ssh-access-with-iam/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shellcheck

michaelwittig opened this issue · comments

Hi,

I would like to add a tool called shellcheck to lint shell scripts before we merge them into master.

At the moment, the tool finds toe following issues:

$ find . -type f -name '*.sh' -exec shellcheck -s bash {} \;

In ./authorized_keys_command.sh line 8:
[ -f /etc/aws-ec2-ssh.conf ] && . /etc/aws-ec2-ssh.conf
                                ^-- SC1091: Not following: /etc/aws-ec2-ssh.conf was not specified as input (see shellcheck -x).


In ./authorized_keys_command.sh line 13:
: ${ASSUMEROLE:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 4:
[ -f /etc/aws-ec2-ssh.conf ] && . /etc/aws-ec2-ssh.conf
                                ^-- SC1091: Not following: /etc/aws-ec2-ssh.conf was not specified as input (see shellcheck -x).


In ./import_users.sh line 7:
: ${DONOTSYNC:=0}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 17:
: ${IAM_AUTHORIZED_GROUPS:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 20:
: ${LOCAL_MARKER_GROUP:="iam-synced-users"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 23:
: ${LOCAL_GROUPS:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 29:
: ${SUDOERSGROUP:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 34:
: ${SUDOERS_GROUPS:="${SUDOERSGROUP}"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 39:
: ${ASSUMEROLE:=""}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 42:
: ${USERADD_PROGRAM:="/usr/sbin/useradd"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 45:
: ${USERADD_ARGS:="--create-home --shell /bin/bash"}
  ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 78:
            aws --region $REGION ec2 describe-tags \
                         ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 95:
        for group in $(echo ${IAM_AUTHORIZED_GROUPS} | tr "," " "); do
                            ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 126:
            aws --region $REGION ec2 describe-tags \
                         ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 166:
    if [[ ! "${username}" =~ ^[0-9a-zA-Z\._\-]{1,32}$ ]]
                                           ^-- SC1001: This \- will be a regular '-' in this context.


In ./import_users.sh line 178:
        ${USERADD_PROGRAM} ${USERADD_ARGS} "${username}"
                           ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 179:
        /bin/chown -R "${username}:${username}" "$(eval echo ~$username)"
                                                              ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 250:
    intersection=$(echo ${local_users} ${iam_users} | tr " " "\n" | sort | uniq -D | uniq)
                        ^-- SC2086: Double quote to prevent globbing and word splitting.
                                       ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./import_users.sh line 251:
    removed_users=$(echo ${local_users} ${intersection} | tr " " "\n" | sort | uniq -u)
                         ^-- SC2086: Double quote to prevent globbing and word splitting.
                                        ^-- SC2086: Double quote to prevent globbing and word splitting.

If there are no doubts, I would like to activate the tool and I would also fix the existing findings.

Oh, I wish I'd noticed this sooner. I'm all about it. I'm happy to make a PR too, if you'd like.

I believe it would add value. Catch as many issued as possible with linting.