[PATCH] RHEL6 verify-input-sanity.py: Replace lxml.etree.XMLSyntaxError traceback with path to problematic XCCDF file. OpenStack ditto. RHEVM3 ditto.

Jeffrey Blank blank at eclipse.ncsc.mil
Tue Sep 17 03:44:10 UTC 2013


Yes, thanks.  There are likely other problems with this script, too.

On Mon, Sep 16, 2013 at 11:05 PM, Shawn Wells <shawn at redhat.com> wrote:
> On 9/16/13 12:12 PM, Jan Lieskovsky wrote:
>>
>> By verifying sanity of input this will substitute Python
>> lxml.etree.XMLSyntaxError traceback (former state) with (more informative)
>> path to problematic XCCDF file information (proposed state),
>> in which XML syntax error, during parsing of that particular XML file,
>> occurred. This should simplify further XML syntax correctness
>> investigation /
>> validation for those files.
>>
>> Signed-off-by: Jan Lieskovsky <jlieskov at redhat.com>
>> ---
>>   OpenStack/utils/verify-input-sanity.py | 5 ++++-
>>   RHEL6/utils/verify-input-sanity.py     | 5 ++++-
>>   RHEVM3/utils/verify-input-sanity.py    | 5 ++++-
>>   3 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/OpenStack/utils/verify-input-sanity.py
>> b/OpenStack/utils/verify-input-sanity.py
>> index 13046b6..1e0ec2c 100755
>> --- a/OpenStack/utils/verify-input-sanity.py
>> +++ b/OpenStack/utils/verify-input-sanity.py
>> @@ -127,7 +127,10 @@ for xccdf_file in xccdf_xml_files:
>>           # form valid XML so that we can parse it
>>           xccdf_xml_contents = xccdf_header + infile.read() + xccdf_footer
>>           # parse the XML at this point
>> -        tree = ET.fromstring(xccdf_xml_contents)
>> +        try:
>> +            tree = ET.fromstring(xccdf_xml_contents)
>> +        except ET.XMLSyntaxError:
>> +            print "  XML syntax error in file: %s" %
>> xccdf_file.replace("./", "src/input/")
>>           # extract all of the rules that are defined within the XCCDF
>>           xccdf_rules = tree.findall(".//Rule")
>>           for xccdf_rule in xccdf_rules:
>> diff --git a/RHEL6/utils/verify-input-sanity.py
>> b/RHEL6/utils/verify-input-sanity.py
>> index 13046b6..1e0ec2c 100755
>> --- a/RHEL6/utils/verify-input-sanity.py
>> +++ b/RHEL6/utils/verify-input-sanity.py
>> @@ -127,7 +127,10 @@ for xccdf_file in xccdf_xml_files:
>>           # form valid XML so that we can parse it
>>           xccdf_xml_contents = xccdf_header + infile.read() + xccdf_footer
>>           # parse the XML at this point
>> -        tree = ET.fromstring(xccdf_xml_contents)
>> +        try:
>> +            tree = ET.fromstring(xccdf_xml_contents)
>> +        except ET.XMLSyntaxError:
>> +            print "  XML syntax error in file: %s" %
>> xccdf_file.replace("./", "src/input/")
>>           # extract all of the rules that are defined within the XCCDF
>>           xccdf_rules = tree.findall(".//Rule")
>>           for xccdf_rule in xccdf_rules:
>> diff --git a/RHEVM3/utils/verify-input-sanity.py
>> b/RHEVM3/utils/verify-input-sanity.py
>> index 13046b6..1e0ec2c 100755
>> --- a/RHEVM3/utils/verify-input-sanity.py
>> +++ b/RHEVM3/utils/verify-input-sanity.py
>> @@ -127,7 +127,10 @@ for xccdf_file in xccdf_xml_files:
>>           # form valid XML so that we can parse it
>>           xccdf_xml_contents = xccdf_header + infile.read() + xccdf_footer
>>           # parse the XML at this point
>> -        tree = ET.fromstring(xccdf_xml_contents)
>> +        try:
>> +            tree = ET.fromstring(xccdf_xml_contents)
>> +        except ET.XMLSyntaxError:
>> +            print "  XML syntax error in file: %s" %
>> xccdf_file.replace("./", "src/input/")
>>           # extract all of the rules that are defined within the XCCDF
>>           xccdf_rules = tree.findall(".//Rule")
>>           for xccdf_rule in xccdf_rules:
>
>
> fantastic.
>
> ack.
>
>
> _______________________________________________
> scap-security-guide mailing list
> scap-security-guide at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/scap-security-guide


More information about the scap-security-guide mailing list