openscap icon indicating copy to clipboard operation
openscap copied to clipboard

Remediation scripts are a mix of Bash and Ansible code

Open jan-cerny opened this issue 9 years ago • 4 comments

The Bash remediation script, generated from SSG Datastream, contains both Ansible and Bash code.

That means the script cannot be run!

I use this command:

oscap xccdf generate fix --profile xccdf_org.ssgproject.content_profile_common ../scap-security-guide-0.1.34/ssg-fedora-ds.xml > fix.sh

See the attached file fix.sh.zip

I used OpenSCAP build from current upstream head, and SSG 0.1.34 from tarball downloaded from GitHub. The issue is reproducible with openscap-1.2.14-1.fc24.x86_64 as well.

bash fix.sh
Remediating rule 1/74: 'xccdf_org.ssgproject.content_rule_ensure_gpgcheck_globally_activated'
fix.sh: line 24: -: command not found
fix.sh: line 25: stat:: command not found
fix.sh: line 26: path:: command not found
fix.sh: line 27: register:: command not found
fix.sh: line 28: check_mode:: command not found

......
.....

jan-cerny avatar Jul 04 '17 10:07 jan-cerny

If --template is specified, the issue doesn't happen. But if no --template is provided, it simply takes the last <xccdf:fix>, no matter what language is it. That's wrong. It should take bash as default.

jan-cerny avatar Jul 04 '17 12:07 jan-cerny

@jan-cerny See PR https://github.com/OpenSCAP/openscap/pull/777

kjankov avatar Jul 05 '17 20:07 kjankov

@kjankov @jan-cerny offered a fix in #776 , it looks like your fix is a duplicate.

mpreisler avatar Jul 06 '17 14:07 mpreisler

Fixed in https://github.com/OpenSCAP/openscap/commit/a6c35af3f8cbb19f799323a912d816d6e13b6a31

jan-cerny avatar Jul 24 '17 15:07 jan-cerny