[PATCH] [*/utils/verify-input-sanity.py] Enhance 7031613 change -- show also what kind of error happened & line number it happened at

Shawn Wells shawn at redhat.com
Mon Jul 7 15:40:14 UTC 2014


On 7/7/14, 9:23 AM, Jan Lieskovsky wrote:
> This patch enhances the change introduced in:
>    [1]https://git.fedorahosted.org/cgit/scap-security-guide.git/commit/?id=7031613
>
> it to be yet more verbose. Instead of reporting just file name, the error happened in,
> report also what kind of error happened & particular line number of that processed file,
> causing / leading to this error.
>
> Current verify-input-sanity.py output:
>
>    utils]$ ./verify-input-sanity.py
>
>    XML syntax error in file: src/input/checks/platform/rhel6-cpe-dictionary.xml
>    XML syntax error in file: src/input/auxiliary/stig_overlay.xml
>
> Output once the change is applied:
>
>    utils]$ ./verify-input-sanity.py
>
>    XML syntax error in file src/input/checks/platform/rhel6-cpe-dictionary.xml:
>    XML declaration allowed only at the start of the document, line 1, column 49
>
>    XML syntax error in file src/input/auxiliary/stig_overlay.xml:
>    XML declaration allowed only at the start of the document, line 1, column 49
>
> The patch changes the behaviour all across the content (i.e. for verify-input-sanity.py
> foreach of RHEL/6, RHEL/7, Fedora, Openstack & RHEVM3 -- tested for all cases, works fine).
>
> Please review.
>
> Thank you && Regards, Jan.
> --
> Jan iankko Lieskovsky / Red Hat Security Technologies Team
>
> 0001-utils-verify-input-sanity.py-Enhance-7031613-change-.patch
>
>
>  From 3de86a9c94c5b2fdf804183b54c2585802d65841 Mon Sep 17 00:00:00 2001
> From: Jan Lieskovsky<jlieskov at redhat.com>
> Date: Mon, 7 Jul 2014 15:05:52 +0200
> Subject: [PATCH] [*/utils/verify-input-sanity.py] Enhance 7031613 change --
>   together with reporting in which file the error happened, report also what
>   kind of error is it & particular line number of the corresponding file
>   causing it
>
> Signed-off-by: Jan Lieskovsky<jlieskov at redhat.com>
> ---
>   Fedora/utils/verify-input-sanity.py    | 5 +++--
>   OpenStack/utils/verify-input-sanity.py | 5 +++--
>   RHEL/6/utils/verify-input-sanity.py    | 5 +++--
>   RHEL/7/utils/verify-input-sanity.py    | 5 +++--
>   RHEVM3/utils/verify-input-sanity.py    | 5 +++--
>   5 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/Fedora/utils/verify-input-sanity.py b/Fedora/utils/verify-input-sanity.py
> index 1e0ec2c..c685a9e 100755
> --- a/Fedora/utils/verify-input-sanity.py
> +++ b/Fedora/utils/verify-input-sanity.py
> @@ -129,8 +129,9 @@ for xccdf_file in xccdf_xml_files:
>           # parse the XML at this point
>           try:
>               tree = ET.fromstring(xccdf_xml_contents)
> -        except ET.XMLSyntaxError:
> -            print "  XML syntax error in file: %s" % xccdf_file.replace("./", "src/input/")
> +        except ET.XMLSyntaxError as e:
> +            print "  XML syntax error in file %s:" % xccdf_file.replace("./", "src/input/")
> +            print " ", e.msg, "\n"
>           # 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/OpenStack/utils/verify-input-sanity.py b/OpenStack/utils/verify-input-sanity.py
> index 1e0ec2c..c685a9e 100755
> --- a/OpenStack/utils/verify-input-sanity.py
> +++ b/OpenStack/utils/verify-input-sanity.py
> @@ -129,8 +129,9 @@ for xccdf_file in xccdf_xml_files:
>           # parse the XML at this point
>           try:
>               tree = ET.fromstring(xccdf_xml_contents)
> -        except ET.XMLSyntaxError:
> -            print "  XML syntax error in file: %s" % xccdf_file.replace("./", "src/input/")
> +        except ET.XMLSyntaxError as e:
> +            print "  XML syntax error in file %s:" % xccdf_file.replace("./", "src/input/")
> +            print " ", e.msg, "\n"
>           # 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/RHEL/6/utils/verify-input-sanity.py b/RHEL/6/utils/verify-input-sanity.py
> index 1e0ec2c..c685a9e 100755
> --- a/RHEL/6/utils/verify-input-sanity.py
> +++ b/RHEL/6/utils/verify-input-sanity.py
> @@ -129,8 +129,9 @@ for xccdf_file in xccdf_xml_files:
>           # parse the XML at this point
>           try:
>               tree = ET.fromstring(xccdf_xml_contents)
> -        except ET.XMLSyntaxError:
> -            print "  XML syntax error in file: %s" % xccdf_file.replace("./", "src/input/")
> +        except ET.XMLSyntaxError as e:
> +            print "  XML syntax error in file %s:" % xccdf_file.replace("./", "src/input/")
> +            print " ", e.msg, "\n"
>           # 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/RHEL/7/utils/verify-input-sanity.py b/RHEL/7/utils/verify-input-sanity.py
> index 1e0ec2c..c685a9e 100755
> --- a/RHEL/7/utils/verify-input-sanity.py
> +++ b/RHEL/7/utils/verify-input-sanity.py
> @@ -129,8 +129,9 @@ for xccdf_file in xccdf_xml_files:
>           # parse the XML at this point
>           try:
>               tree = ET.fromstring(xccdf_xml_contents)
> -        except ET.XMLSyntaxError:
> -            print "  XML syntax error in file: %s" % xccdf_file.replace("./", "src/input/")
> +        except ET.XMLSyntaxError as e:
> +            print "  XML syntax error in file %s:" % xccdf_file.replace("./", "src/input/")
> +            print " ", e.msg, "\n"
>           # 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 1e0ec2c..c685a9e 100755
> --- a/RHEVM3/utils/verify-input-sanity.py
> +++ b/RHEVM3/utils/verify-input-sanity.py
> @@ -129,8 +129,9 @@ for xccdf_file in xccdf_xml_files:
>           # parse the XML at this point
>           try:
>               tree = ET.fromstring(xccdf_xml_contents)
> -        except ET.XMLSyntaxError:
> -            print "  XML syntax error in file: %s" % xccdf_file.replace("./", "src/input/")
> +        except ET.XMLSyntaxError as e:
> +            print "  XML syntax error in file %s:" % xccdf_file.replace("./", "src/input/")
> +            print " ", e.msg, "\n"
>           # extract all of the rules that are defined within the XCCDF
>           xccdf_rules = tree.findall(".//Rule")
>           for xccdf_rule in xccdf_rules:
> -- 1.8.3.1

ack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/scap-security-guide/attachments/20140707/7c50b787/attachment.html>


More information about the scap-security-guide mailing list