-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
210 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ FROM outofcoffee/imposter:4.1.2 | |
COPY ./docker/mock-pay /opt/imposter/config/ | ||
|
||
USER imposter | ||
|
||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/sh | ||
echo "=== Starting Alpine Hardening Script ===" | ||
|
||
echo "add default user" | ||
adduser -D -s /bin/sh -u 1000 user && \ | ||
sed -i -r 's/^user:!:/user:x:/' /etc/shadow && \ | ||
chmod u-s /usr/sbin/login_duo | ||
|
||
echo "/etc/duo/login_duo.conf must be readable only by user 'user'." | ||
chown user:user /etc/duo/login_duo.conf && \ | ||
chmod 0400 /etc/duo/login_duo.conf | ||
|
||
echo "Ensure strict ownership and perms." | ||
chown root:root /usr/bin/github_pubkeys && \ | ||
chmod 0555 /usr/bin/github_pubkeys && \ | ||
echo -e "\n\nApp container image built on $(date)." > /etc/motd | ||
|
||
echo "Remove world-writeable permissions except for /tmp/" | ||
find / -xdev -type d -perm +0002 -exec chmod o-w {} + \ | ||
&& find / -xdev -type f -perm +0002 -exec chmod o-w {} + \ | ||
&& chmod 777 /tmp/ \ | ||
&& chown www-data:root /tmp/ | ||
|
||
echo "Remove unnecessary user accounts." | ||
sed -i -r '/^(user|root|sshd|www-data|nobody)/!d' /etc/group | ||
sed -i -r '/^(user|root|sshd|www-data|nobody)/!d' /etc/passwd | ||
|
||
echo "Remove existing crontabs, if any." | ||
rm -fr /var/spool/cron \ | ||
&& rm -fr /etc/crontabs \ | ||
&& rm -fr /etc/periodic | ||
|
||
echo "Remove interactive login shell for everybody but user." | ||
sed -i -r '/^user:/! s#^(.*):[^:]*$#\1:/sbin/nologin#' /etc/passwd | ||
|
||
sysdirs=" | ||
/bin | ||
/etc | ||
/lib | ||
/sbin | ||
/usr | ||
" | ||
echo "Remove apk configs." | ||
find $sysdirs -xdev -regex '.*apk.*' -exec rm -fr {} + | ||
find $sysdirs -xdev -type f -regex '.*-$' -exec rm -f {} + | ||
|
||
echo "Ensure system dirs are owned by root and not writable by anybody else." | ||
find $sysdirs -xdev -type d \ | ||
-exec chown root:root {} \; \ | ||
-exec chmod 0755 {} \; | ||
|
||
echo "Remove all suid files." | ||
find $sysdirs -xdev -type f -a -perm +4000 -delete | ||
find $sysdirs -xdev -type f -a \( -perm +4000 -o -perm +2000 \) -delete | ||
|
||
echo "Remove other programs that could be dangerous." | ||
find $sysdirs -xdev \( \ | ||
-name hexdump -o \ | ||
-name chgrp -o \ | ||
-name chmod -o \ | ||
-name chown -o \ | ||
-name ln -o \ | ||
-name od -o \ | ||
-name strings -o \ | ||
-name su \ | ||
-name sudo \ | ||
\) -delete | ||
|
||
echo "Remove init scripts since we do not use them." | ||
rm -fr /etc/init.d | ||
rm -fr /lib/rc | ||
rm -fr /etc/conf.d | ||
rm -fr /etc/inittab | ||
rm -fr /etc/runlevels | ||
rm -fr /etc/rc.conf | ||
rm -fr /etc/logrotate.d | ||
|
||
echo "Remove kernel tunables since we do not need them." | ||
rm -fr /etc/sysctl* | ||
rm -fr /etc/modprobe.d | ||
rm -fr /etc/modules | ||
rm -fr /etc/mdev.conf | ||
rm -fr /etc/acpi | ||
|
||
echo "Remove root homedir since we do not need it." | ||
rm -fr /root | ||
|
||
echo "Remove fstab since we do not need it." | ||
rm -f /etc/fstab | ||
|
||
echo "Remove all but a handful of admin commands." | ||
find /sbin /usr/sbin ! -type d -a ! -name apk -a ! -name ln -delete | ||
|
||
echo "Remove broken symlinks (because we removed the targets above)." | ||
find $sysdirs -xdev -type l -exec test ! -e {} \; -delete | ||
|
||
echo "Disable password login for everybody" | ||
while IFS=: read -r username _; do passwd -l "$username"; done < /etc/passwd || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters