From 3edc64154550c61d2834cad515a07d1eb299cd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 2 Jan 2015 09:13:05 +0100 Subject: [PATCH] triage: write 'Not Found' errors in the report --- triage/theme1.css | 5 +++-- triage/triage.py | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/triage/theme1.css b/triage/theme1.css index 75df77464..e0483e732 100644 --- a/triage/theme1.css +++ b/triage/theme1.css @@ -24,7 +24,8 @@ td { border:1px solid gray; } +.tp { color:red; } +.fp { color:green; } +.notfound { color:blue; } .untriaged { color:black; } -.tp { color:black; } -.fp { color:lightgray; } diff --git a/triage/triage.py b/triage/triage.py index 658cc69f0..687c4046d 100644 --- a/triage/triage.py +++ b/triage/triage.py @@ -19,7 +19,7 @@ falsepositives = f.read() f.close(); fin = open(resultfile,'rt') -results = fin.readlines() +results = fin.read() fin.close() fout = open('report.html','wt') @@ -32,8 +32,9 @@ out = {} out['untriaged'] = '' out['fp'] = '' out['tp'] = '' +out['notfound'] = '' -for result in results: +for result in results.split('\n'): result = result.strip() res = re.match('\\[('+project+'.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', result) @@ -61,9 +62,41 @@ for result in results: out[css] += html +f = open(project + '/true-positives.txt', 'rt') +for line in f.readlines(): + line = line.strip() + if line.find('] -> [') > 0 or line.find('(error)') < 0: + continue + + res = re.match('\\[('+project+'.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', line) + if res == None: + continue + + if line in results: + continue + + filename = res.group(1) + linenr = res.group(2) + message = res.group(3) + classification = 'Not Found' + css = 'notfound' + + html = ' ' + html += ''+filename+'' + html += ''+linenr+'' + html += ''+message+'' + html += ''+classification+'' + html += '\n' + + out[css] += html + +f.close(); + + fout.write(out['tp']) -fout.write(out['fp']) +fout.write(out['notfound']) fout.write(out['untriaged']) +fout.write(out['fp']) fout.write('') fout.close()