Skip to content
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

2.7 false positive when log_opt set #498

Open
dhrapson opened this issue Apr 29, 2022 · 5 comments
Open

2.7 false positive when log_opt set #498

dhrapson opened this issue Apr 29, 2022 · 5 comments
Assignees

Comments

@dhrapson
Copy link

I'm using this excellent utility to assess compliance. We set the following in our /etc/docker/daemon.json:

{
"log-opt": syslog-address=tcp://<some_ip>
}

Doing this causes check_2_7 to trigger incorrectly because of the logic in this line:

if [ $(get_docker_configuration_file_args 'tcp://') ] || \

The output is [WARN] * Docker daemon currently listening on TCP without TLS when it is not listening on TCP at all.

@konstruktoid konstruktoid self-assigned this Apr 29, 2022
@konstruktoid
Copy link
Collaborator

Thanks for creating this issue @dhrapson, I'll have a look as soon as possible.

@konstruktoid
Copy link
Collaborator

So sorry for the long delay @dhrapson, could you please test #501?

@aretandic
Copy link

aretandic commented May 27, 2022

Hello @konstruktoid. Wanted to notify you that this fix is not working as expected unfortunately. It now incorrectly work with 2.7 check and not providing positive results at all with some configuration of daemon.json.

"hosts": [
"tcp://127.0.0.1:2376",
"unix:///var/run/docker.sock"
],

I have such configuration of daemon.json and then grep -E "host.*tcp://" /etc/docker/daemon.json will not show anything.
if i will set configuration to:

"hosts": ["tcp://127.0.0.1:2376","unix:///var/run/docker.sock"],

Code will return error docker-bench-security.sh: 157: [: "hosts":: unexpected operator, I assume because grep will return [ in output.
I think that it could be fixed by grep -Ez, but it will return docker-bench-security.sh: 157: [: "hosts":: unexpected operator error.
Please take a look

@aretandic
Copy link

For me I solved issue like this:
$(grep -Ez 'host.*tcp://([0-9].)+' "$CONFIG_FILE" | grep -Ea 'tcp://([0-9].)+')
But it will not help if there are other tcp addresses in code, unfortunately didn't have enough time to take a dipper look into it

@konstruktoid
Copy link
Collaborator

Yeah, the drawbacks of parsing json using shell.
I guess the best way would be to add jq to the dependencies and use that to parse the config, and use the current semi-working code as fallback.

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

No branches or pull requests

3 participants