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

To be on the safe side, force ansible XCCDF values to be interpreted as str… #3050

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion ssg/build_remediations.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,15 @@ def expand_xccdf_subs(fix, remediation_type, remediation_functions):
"substituting directly."
)

# we use the horrid "!!str |-" syntax to force strings without using
# quotes. quotes enable yaml escaping rules so we'd have to escape all
# the backslashes and at this point we don't know if there are any.
fix_text = re.sub(
r"- \(xccdf-var\s+(\S+)\)",
r"- name: XCCDF Value \1 # promote to variable\n"
r" set_fact:\n"
r' \1: "(ansible-populate \1)"\n'
r" \1: !!str |-\n"
r" (ansible-populate \1)\n"
r" tags:\n"
r" - always",
fix_text
Expand Down