mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-19 00:32:34 +01:00
add check option, and function names
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
This commit is contained in:
parent
ddf231e377
commit
6ec6ee0638
1 changed files with 18 additions and 3 deletions
|
@ -9,8 +9,9 @@
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Load dependencies
|
# Load dependencies
|
||||||
. ./output_lib.sh
|
. ./functions_lib.sh
|
||||||
. ./helper_lib.sh
|
. ./helper_lib.sh
|
||||||
|
. ./output_lib.sh
|
||||||
|
|
||||||
# Setup the paths
|
# Setup the paths
|
||||||
this_path=$(abspath "$0") ## Path of this file including filenamel
|
this_path=$(abspath "$0") ## Path of this file including filenamel
|
||||||
|
@ -35,18 +36,20 @@ usage () {
|
||||||
usage: ${myname} [options]
|
usage: ${myname} [options]
|
||||||
|
|
||||||
-h optional Print this help message
|
-h optional Print this help message
|
||||||
-l PATH optional Log output in PATH
|
-l FILE optional Log output in FILE
|
||||||
|
-c CHECK optional Run specific check
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the flags
|
# Get the flags
|
||||||
# If you add an option here, please
|
# If you add an option here, please
|
||||||
# remember to update usage() above.
|
# remember to update usage() above.
|
||||||
while getopts hl: args
|
while getopts hl:c: args
|
||||||
do
|
do
|
||||||
case $args in
|
case $args in
|
||||||
h) usage; exit 0 ;;
|
h) usage; exit 0 ;;
|
||||||
l) logger="$OPTARG" ;;
|
l) logger="$OPTARG" ;;
|
||||||
|
c) check="$OPTARG" ;;
|
||||||
*) usage; exit 1 ;;
|
*) usage; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -95,11 +98,23 @@ main () {
|
||||||
# List all running containers except docker-bench (use names to improve readability in logs)
|
# List all running containers except docker-bench (use names to improve readability in logs)
|
||||||
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont")
|
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont")
|
||||||
|
|
||||||
|
if [ -z "$containers" ]; then
|
||||||
|
running_containers=0
|
||||||
|
else
|
||||||
|
running_containers=1
|
||||||
|
fi
|
||||||
|
|
||||||
for test in tests/*.sh
|
for test in tests/*.sh
|
||||||
do
|
do
|
||||||
. ./"$test"
|
. ./"$test"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -z "$check" ]; then
|
||||||
|
cis
|
||||||
|
else
|
||||||
|
"$check"
|
||||||
|
fi
|
||||||
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
info "Checks: $totalChecks"
|
info "Checks: $totalChecks"
|
||||||
info "Score: $currentScore"
|
info "Score: $currentScore"
|
||||||
|
|
Loading…
Reference in a new issue