From c7c10d0b43ff74e570fee58ee34dc23b79a99501 Mon Sep 17 00:00:00 2001 From: Roberto Martelloni Date: Tue, 9 Aug 2016 23:15:31 +0100 Subject: [PATCH] added python script to list in CSV format all errors without a CWE --- tools/listErrorsWithoutCWE.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 tools/listErrorsWithoutCWE.py diff --git a/tools/listErrorsWithoutCWE.py b/tools/listErrorsWithoutCWE.py new file mode 100755 index 000000000..afebad60f --- /dev/null +++ b/tools/listErrorsWithoutCWE.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +import argparse +import xml.etree.ElementTree as ET + + +def main(): + + parser = argparse.ArgumentParser(description="List all error without a CWE assigned in CSV format") + parser.add_argument("-F", metavar="filename", required=True, help="XML file containing output from: ./cppcheck --errorlist --xml-version=2") + parsed = parser.parse_args() + + tree = ET.parse(vars(parsed)["F"]) + root = tree.getroot() + for child in root.iter("error"): + + if "cwe" not in child.attrib: + print child.attrib["id"], ",", child.attrib["severity"], ",", child.attrib["verbose"] + +if __name__ == "__main__": + main()