Skip to content

Commit

Permalink
OCP4: use utf-8 as default xml encoding
Browse files Browse the repository at this point in the history
This commit make UTF-8 as default xml encoding. In a recent change, when writing xccdf xml file, it uses the output encoding US-ASCII as default if not set, however this causes issues in Compliance Operator parser, using US-ASCII, the parser is not able to get the prefix of xml node, therefore crash the parser pod.
  • Loading branch information
Vincent056 committed Feb 22, 2024
1 parent b895bce commit ace1a53
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build-scripts/build_xccdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def link_benchmark(loader, xccdftree, args, benchmark=None):
if ocil is not None:
link_ocil(xccdftree, checks, args.ocil, ocil)

ssg.xml.ElementTree.ElementTree(xccdftree).write(args.xccdf)
ssg.xml.ElementTree.ElementTree(xccdftree).write(args.xccdf, encoding="utf-8")


def get_path(path, file_name):
Expand Down
4 changes: 2 additions & 2 deletions build-scripts/compose_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ def upgrade_ds_to_scap_13(ds):

def _store_ds(ds, output_13, output_12):
if output_12:
ds.write(output_12, xml_declaration=True)
ds.write(output_12, xml_declaration=True, encoding="utf-8")

ds_13 = upgrade_ds_to_scap_13(ds)
ds_13.write(output_13, xml_declaration=True)
ds_13.write(output_13, xml_declaration=True, encoding="utf-8")


def append_id_to_file_name(path, id_):
Expand Down
4 changes: 2 additions & 2 deletions ssg/build_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def to_xml_element(self, env_yaml=None, product_cpes=None):
def to_file(self, file_name, env_yaml=None):
root = self.to_xml_element(env_yaml)
tree = ET.ElementTree(root)
tree.write(file_name)
tree.write(file_name, encoding="utf-8")

def add_value(self, value):
if value is None:
Expand Down Expand Up @@ -1590,7 +1590,7 @@ def export_ocil_to_file(self, filename):
if root is None:
return
tree = ET.ElementTree(root)
tree.write(filename, xml_declaration=True)
tree.write(filename, encoding="utf-8", xml_declaration=True)


class Platform(XCCDFEntity):
Expand Down

0 comments on commit ace1a53

Please sign in to comment.