Hide Forgot
Description of problem: Compliance scan of a Docker image/container using oscap-docker reports incorrectly that there was an error even if scan was successful but incompliance of the assessed system was found. ========== $ oscap-docker image rhel7 xccdf eval --profile standard /usr/share/xml/scap/ssg/content/ssg-rhel7-xccdf.xml WARNING: Skipping http://www.redhat.com/security/data/oval/Red_Hat_Enterprise_Linux_7.xml file which is referenced from XCCDF content Command: oscap xccdf eval --profile standard /usr/share/xml/scap/ssg/content/ssg-rhel7-xccdf.xml failed! Error was: Command '['oscap', 'xccdf', 'eval', '--profile', 'standard', '/usr/share/xml/scap/ssg/content/ssg-rhel7-xccdf.xml']' returned non-zero exit status 2 ========== It is an issue in oscap-docker script when processing exit status of oscap which is according to oscap(8) man page: Normally, the exit status is 0 when operation finished successfully and 1 otherwise. In cases when oscap performs evaluation of the system it may return 2 indicating success of the operation but incompliance of the assessed system. Also, in case of incompliance, oscap-docker should print the evaluation results to pinpoint which rules did not pass the scan. Version-Release number of selected component (if applicable): openscap-utils-1.2.10-2.el7 scap-security-guide-0.1.30-3.el7 How reproducible: always Steps to Reproduce: 1. Run: $ oscap-docker image rhel7 xccdf eval --profile standard /usr/share/xml/scap/ssg/content/ssg-rhel7-xccdf.xml Actual results: oscap-docker reports incorrectly that there was an error even if scan was successful but incompliance of the assessed system was found. Expected results: oscap-docker reports that scan was successful but incompliance of the assessed system was found. It will also print the evaluation results to pinpoint which rules did not pass the scan. Additional info:
Also reported upstream.
Fixed upstream in https://github.com/OpenSCAP/openscap/commit/5ffdcf51b500494ac235a6a0160c126fc6f2144c
Since this is a bug, will RHEL 7.3 errata be released (vs waiting for 7.4)?
VERIFIED as fixed for openscap-utils-1.2.14-1.el7 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ LOG ] :: Test: Scan a docker image :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ PASS ] :: Command 'oscap-docker image rhel7:7.2 xccdf eval --profile xccdf_test_profile_failing --report ./report.html --results-arf ./results_arf.xml --results ./results.xml /mnt/tests/CoreOS/openscap/Sanity/oscap-docker/simple-xccdf.xml > ./output.stdout 2> ./output.stderr' (Expected 0, got 0) :: [ PASS ] :: File ./results.xml should exist :: [ PASS ] :: Command 'file -b './results.xml' | grep '^XML' --quiet' (Expected 0, got 0) :: [ PASS ] :: File ./results_arf.xml should exist :: [ PASS ] :: Command 'file -b './results_arf.xml' | grep '^XML' --quiet' (Expected 0, got 0) :: [ PASS ] :: File ./report.html should exist :: [ PASS ] :: Command 'grep -q '<!DOCTYPE[^>]*html[^>]*>' './report.html'' (Expected 0, got 0) :: [ PASS ] :: File './output.stderr' should not contain '.' :: [ PASS ] :: File './output.stdout' should contain 'elpmaxe.www_rule_2' :: [ PASS ] :: File './output.stdout' should contain '^Result.*fail$'
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2017:2291