OpenSCAP / openscap

NIST Certified SCAP 1.2 toolkit
https://www.open-scap.org/tools/openscap-base
GNU Lesser General Public License v2.1
1.39k stars 380 forks source link

Remediate does not work if called separately from eval cmd #2138

Open StevenYGui opened 4 months ago

StevenYGui commented 4 months ago

Thanks!

Description of Problem:

if I type cmd as below, fail items can be fixed correctly. # oscap xccdf eval --remediate --profile xccdf_org.ssgproject.content_profile_standard --results scan_results.xml ssg-xxx-ds.xml image

but if I seperate it into 2 cmds as below, fix will fail. # oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_standard --results scan_results.xml ssg-xxx-ds.xml image

# oscap xccdf remediate scan_results.xml image

So, what's the mistake in my cmd?

OpenSCAP Version:

1.3.9

Operating System & Version:

Steps to Reproduce:

Actual Results:

Expected Results:

Additional Information / Debugging Steps:

jan-cerny commented 3 months ago

I have investigated this issue. I have found that we have a bug related to CPE applicability of fixes. The remediation isn't performed because the fix is resolved as not applicable. Internally, it can't find any applicable fix. But, the XCCDF results file doesn't contain CPE definitions or CPE dictionaries, so it can't resolve the applicability.

Unfortunately, the oscap xccdf remediate module doesn't consume ARFs.

I'm not sure about how we can fix it. We can replace the call of _filter_fixes_by_applicability in src/XCCDF_POLICY/xccdf_policy_remediate.c in _find_suitable_fix by _get_fixes, which is a function that doesn't check CPE applicability. But this change would make the assertions in tests/API/XCCDF/applicability/test_remediate_fix_notapplicable.sh invalid.