From 1b37a1e6bcdc20018a5dcc7820eac2ce1e94c3ac Mon Sep 17 00:00:00 2001 From: wilmardo Date: Wed, 4 Dec 2019 15:21:37 +0100 Subject: [PATCH] fix: allow combining include and exclude Signed-off-by: wilmardo --- docker-bench-security.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docker-bench-security.sh b/docker-bench-security.sh index 8d9a602..2d52a82 100755 --- a/docker-bench-security.sh +++ b/docker-bench-security.sh @@ -144,7 +144,15 @@ main () { else for i in $(echo "$check" | sed "s/,/ /g"); do if command -v "$i" 2>/dev/null 1>&2; then - "$i" + if [ "$checkexclude" ]; then + checkexcluded="$(echo ",$checkexclude" | sed -e 's/^/\^/g' -e 's/,/\$|/g' -e 's/$/\$/g')" + included_checks=$(sed -ne "/$i() {/,/}/{/check/p}" functions_lib.sh | grep -vE "$checkexcluded") + for check in $included_checks; do + "$check" + done + else + "$i" + fi else echo "Check \"$i\" doesn't seem to exist." continue