Skip to content

modified get_docker_configuration_file_args jq command to remove null response #553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2024

Conversation

spedersen-emailage
Copy link
Contributor

By default, jq will return "null" (string) when no results are found, which means get_docker_configuration_file_args would return "null" instead of "" or true null. Checks like check_2_3 that accept a blank/null response to pass would fail.

This modifies the jq command to look for $OPTION and if found, return the value of $OPTION, otherwise return no data.

@spedersen-emailage
Copy link
Contributor Author

Rudimentary tests passed. A full scan returned expected/same results as previous scans on the same host. Check 2.3 specifically passes now.

# ./docker-bench-security.sh -c check_2_3
# --------------------------------------------------------------------------------------------
# Docker Bench for Security v1.6.0
#
# Docker, Inc. (c) 2015-2024
#
# Checks for dozens of common best-practices around deploying Docker containers in production.
# Based on the CIS Docker Benchmark 1.6.0.
# --------------------------------------------------------------------------------------------

Initializing 2024-05-15T17:31:42+00:00

Section A - Check results
[PASS] 2.3 - Ensure the logging level is set to 'info' (Scored)

Section C - Score

[INFO] Checks: 1
[INFO] Score: 1

@konstruktoid
Copy link
Collaborator

Thanks @spedersen-emailage looks good but will do some testing before merge.

@spedersen-emailage
Copy link
Contributor Author

No problem, thanks!

@konstruktoid
Copy link
Collaborator

LGTM

current:

++ CONFIG_FILE=/etc/docker/daemon.json
++ return
++ true
++ jq --monochrome-output --raw-output '.["log-level"]' /etc/docker/daemon.json
+ '[' -z null ']'
+ warn -s '2.3 - Ensure the logging level is set to '\''info'\'' (Scored)'

with PR:

++ CONFIG_FILE=/etc/docker/daemon.json
++ return
++ true
++ jq --monochrome-output --raw-output 'if has("log-level") then .["log-level"] else "" end' /etc/docker/daemon.json
+ '[' -z '' ']'
+ pass -s '2.3 - Ensure the logging level is set to '\''info'\'' (Scored)'

@konstruktoid konstruktoid merged commit 5c42b8a into docker:master May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants