Fix #6325 - Prevent XML header from outputting to ossec.conf

This commit is contained in:
Jason Ertel
2021-11-23 10:57:21 -05:00
parent 4672b0c15c
commit af4c04be59

View File

@@ -23,7 +23,6 @@ import sys
import argparse import argparse
import re import re
from lxml import etree as ET from lxml import etree as ET
from xml.dom import minidom
from datetime import datetime as dt from datetime import datetime as dt
from datetime import timezone as tz from datetime import timezone as tz
@@ -87,12 +86,7 @@ def wazuh_enabled() -> bool:
def root_to_str(root: ET.ElementTree) -> str: def root_to_str(root: ET.ElementTree) -> str:
xml_str = ET.tostring(root, encoding='unicode', method='xml').replace('\n', '') return ET.tostring(root, encoding='unicode', method='xml', xml_declaration=False, pretty_print=True)
xml_str = re.sub(r'(?:(?<=>) *)', '', xml_str)
xml_str = re.sub(r' -', '', xml_str)
xml_str = re.sub(r' -->', ' -->', xml_str)
dom = minidom.parseString(xml_str)
return dom.toprettyxml(indent=" ")
def add_wl(ip): def add_wl(ip):