mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-18 16:22:33 +01:00
Merge pull request #525 from brsolomon-deloitte/bugfix/get_docker_configuration_file_args
fix: allow get_docker_configuration_file_args to parse minified json
This commit is contained in:
commit
1d29a1f405
3 changed files with 14 additions and 2 deletions
|
@ -7,7 +7,8 @@ LABEL \
|
||||||
|
|
||||||
RUN apk add --no-cache iproute2 \
|
RUN apk add --no-cache iproute2 \
|
||||||
docker-cli \
|
docker-cli \
|
||||||
dumb-init
|
dumb-init \
|
||||||
|
jq
|
||||||
|
|
||||||
COPY . /usr/local/bin/
|
COPY . /usr/local/bin/
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ cd docker-bench-security
|
||||||
sudo sh docker-bench-security.sh
|
sudo sh docker-bench-security.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> Note: [`jq`](https://jqlang.github.io/jq/) is an optional but recommended dependency.
|
||||||
|
|
||||||
### Run with Docker
|
### Run with Docker
|
||||||
|
|
||||||
_Please note that the `docker/docker-bench-security` image is out-of-date and and a manual build is required. See [#405](https://github.com/docker/docker-bench-security/issues/405) for more information._
|
_Please note that the `docker/docker-bench-security` image is out-of-date and and a manual build is required. See [#405](https://github.com/docker/docker-bench-security/issues/405) for more information._
|
||||||
|
|
|
@ -11,6 +11,11 @@ req_programs() {
|
||||||
for p in $1; do
|
for p in $1; do
|
||||||
command -v "$p" >/dev/null 2>&1 || { printf "Required program not found: %s\n" "$p"; exit 1; }
|
command -v "$p" >/dev/null 2>&1 || { printf "Required program not found: %s\n" "$p"; exit 1; }
|
||||||
done
|
done
|
||||||
|
if command -v jq >/dev/null 2>&1; then
|
||||||
|
HAVE_JQ=true
|
||||||
|
else
|
||||||
|
HAVE_JQ=false
|
||||||
|
fi
|
||||||
if command -v ss >/dev/null 2>&1; then
|
if command -v ss >/dev/null 2>&1; then
|
||||||
netbin=ss
|
netbin=ss
|
||||||
return
|
return
|
||||||
|
@ -117,7 +122,11 @@ get_docker_configuration_file_args() {
|
||||||
|
|
||||||
get_docker_configuration_file
|
get_docker_configuration_file
|
||||||
|
|
||||||
grep "$OPTION" "$CONFIG_FILE" | sed 's/.*://g' | tr -d '" ',
|
if "$HAVE_JQ"; then
|
||||||
|
jq --monochrome-output --raw-output ".[\"${OPTION}\"]" "$CONFIG_FILE"
|
||||||
|
else
|
||||||
|
cat "$CONFIG_FILE" | tr { '\n' | tr , '\n' | tr } '\n' | grep "$OPTION" | sed 's/.*://g' | tr -d '" ',
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_service_file() {
|
get_service_file() {
|
||||||
|
|
Loading…
Reference in a new issue