mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-19 00:32:34 +01:00
Added $images to $exclude
Added $images $exclude logic so now containers and images are excluded. Added new $benchimagecont for images to replicate the $benchcont for containers. Signed-off-by: Niall T <jammasterj89@gmail.com>
This commit is contained in:
parent
af8b59f29d
commit
7f29aebd71
1 changed files with 12 additions and 0 deletions
|
@ -103,15 +103,27 @@ main () {
|
||||||
benchcont="$c"
|
benchcont="$c"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# get the image id of the docker_bench_security_image, memorize it:
|
||||||
|
benchimagecont="nil"
|
||||||
|
for c in $(docker images | sed '1d' | awk '{print $3}'); do
|
||||||
|
if docker inspect --format '{{ .Config.Labels }}' "$c" | \
|
||||||
|
grep -e 'docker.bench.security' >/dev/null 2>&1; then
|
||||||
|
benchimagecont="$c"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [ -n "$include" ]; then
|
if [ -n "$include" ]; then
|
||||||
pattern=$(echo "$include" | sed 's/,/|/g')
|
pattern=$(echo "$include" | sed 's/,/|/g')
|
||||||
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont" | grep -E "$pattern")
|
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont" | grep -E "$pattern")
|
||||||
|
images=$(docker images | grep -E "$pattern" | sed '1d' | awk '{print $3}' | grep -v "$benchimagecont")
|
||||||
elif [ -n "$exclude" ]; then
|
elif [ -n "$exclude" ]; then
|
||||||
pattern=$(echo "$exclude" | sed 's/,/|/g')
|
pattern=$(echo "$exclude" | sed 's/,/|/g')
|
||||||
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont" | grep -Ev "$pattern")
|
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont" | grep -Ev "$pattern")
|
||||||
|
images=$(docker images | grep -Ev "$pattern" | sed '1d' | awk '{print $3}' | grep -v "$benchimagecont")
|
||||||
else
|
else
|
||||||
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont")
|
containers=$(docker ps | sed '1d' | awk '{print $NF}' | grep -v "$benchcont")
|
||||||
|
images=$(docker images -q | grep -v "$benchcont")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$containers" ]; then
|
if [ -z "$containers" ]; then
|
||||||
|
|
Loading…
Reference in a new issue