mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
tests: Add a test case to ensure no ports are open
Signed-off-by: Dave Tucker <dt@docker.com>
This commit is contained in:
parent
1598b11375
commit
8763da79c9
13
test/cases/030_security/010_ports/check.sh
Normal file
13
test/cases/030_security/010_ports/check.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PORTS=$(netstat -lntup)
|
||||||
|
LINES=$(echo "${PORTS}" | wc -l)
|
||||||
|
if [ $((LINES > 2)) -ne 0 ]
|
||||||
|
then
|
||||||
|
echo "Ports test case FAILED"
|
||||||
|
echo "${PORTS}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Ports test case PASSED"
|
24
test/cases/030_security/010_ports/test.sh
Normal file
24
test/cases/030_security/010_ports/test.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# SUMMARY: Check that there are no open ports
|
||||||
|
# LABELS:
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Source libraries. Uncomment if needed/defined
|
||||||
|
#. "${RT_LIB}"
|
||||||
|
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||||
|
|
||||||
|
NAME=lsof
|
||||||
|
|
||||||
|
clean_up() {
|
||||||
|
# remove any files, containers, images etc
|
||||||
|
rm -rf ${NAME}* || true
|
||||||
|
}
|
||||||
|
|
||||||
|
trap clean_up EXIT
|
||||||
|
|
||||||
|
moby build -output kernel+initrd -name "${NAME}" test.yml
|
||||||
|
linuxkit run qemu -kernel "${NAME}"
|
||||||
|
#RESULT=$(linuxkit run qemu -kernel "${NAME}")
|
||||||
|
#echo "${RESULT}" | grep -q "PASSED"
|
||||||
|
exit 0
|
23
test/cases/030_security/010_ports/test.yml
Normal file
23
test/cases/030_security/010_ports/test.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
kernel:
|
||||||
|
image: "linuxkit/kernel:4.9.x"
|
||||||
|
cmdline: "console=ttyS0 page_poison=1"
|
||||||
|
init:
|
||||||
|
- linuxkit/init:1b8a7e394d2ec2f1fdb4d67645829d1b5bdca037
|
||||||
|
- linuxkit/runc:3a4e6cbf15470f62501b019b55e1caac5ee7689f
|
||||||
|
- linuxkit/containerd:b50181bc6e0084e5fcd6b6ad3cf433c4f66cae5a
|
||||||
|
onboot:
|
||||||
|
- name: test
|
||||||
|
image: "alpine:3.6"
|
||||||
|
readonly: true
|
||||||
|
binds:
|
||||||
|
- /check.sh:/check.sh
|
||||||
|
command: ["sh", "./check.sh"]
|
||||||
|
- name: poweroff
|
||||||
|
image: "linuxkit/poweroff:7404cf2295df89ccfa2dda41997a28307a90cf28"
|
||||||
|
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||||
|
files:
|
||||||
|
- path: check.sh
|
||||||
|
source: ./check.sh
|
||||||
|
trust:
|
||||||
|
org:
|
||||||
|
- linuxkit
|
Loading…
Reference in New Issue
Block a user