Skip to content

check_2_3 doesnt appear to account for log-level default value #552

Closed
@spedersen-emailage

Description

@spedersen-emailage

CIS Docker Benchmark v1.6.0 recommendation 2.3, "Ensure the logging level is set to 'info' (Manual)," states that log-level should be set to info.

check_2_3() accounts for log-level being explicitly set via command-line options -l and --log-level and checks the contents of several possible config files, but doesn't appear to take into account that the default log-level for Docker is already info.

check_2_3() {
local id="2.3"
local desc="Ensure the logging level is set to 'info' (Scored)"
local remediation="Ensure that the Docker daemon configuration file has the following configuration included log-level: info. Alternatively, run the Docker daemon as following: dockerd --log-level=info"
local remediationImpact="None."
local check="$id - $desc"
starttestjson "$id" "$desc"
if get_docker_configuration_file_args 'log-level' >/dev/null 2>&1; then
if get_docker_configuration_file_args 'log-level' | grep info >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
if [ -z "$(get_docker_configuration_file_args 'log-level')" ]; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
if get_docker_effective_command_line_args '-l'; then
if get_docker_effective_command_line_args '-l' | grep "info" >/dev/null 2>&1; then
pass -s "$check"
logcheckresult "PASS"
return
fi
warn -s "$check"
logcheckresult "WARN"
return
fi
pass -s "$check"
logcheckresult "PASS"
}

$ dockerd --help|grep -i log
      --log-driver string                       Default driver for container logs (default "json-file")
      --log-format string                       Set the logging format ("text"|"json") (default "text")
  -l, --log-level string                        Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --log-opt map                             Default log driver options for containers (default map[])
      --raw-logs                                Full timestamps without ANSI coloring

Reference: https://docs.docker.com/reference/cli/dockerd/

Since this is a default value, it's not set explicitly and doesn't appear in any config files. In order for this check to be more accurate, should it assume that if no alternate value for log-level is found, the default is used, and the check has passed?

Of course, a work-around to pass the check is to explicitly set the log-level to info.

Thoughts?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions