triage: added folder for triage data
This commit is contained in:
parent
d2caf89706
commit
8751dc7c81
|
@ -0,0 +1,14 @@
|
|||
|
||||
This folder is for triage data of cppcheck results.
|
||||
|
||||
You can scan these projects with arbitrary cppcheck version and get triaged reports.
|
||||
|
||||
Usage:
|
||||
|
||||
1. Pick a project.. for example linux-3.11.
|
||||
2. Scan linux-3.11 on your computer with cppcheck (arbitrary version).
|
||||
3. run the triage.py script:
|
||||
python triage.py linux-3.11 path-to-cppcheck-results.txt
|
||||
4. A report.html is generated
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
th {
|
||||
font-size:80%;
|
||||
color:#ffffff;
|
||||
background-color:#555555;
|
||||
border:1px solid #555555;
|
||||
padding:3px;
|
||||
vertical-align:top;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
td {
|
||||
font-size:80%;
|
||||
border:1px solid #d4d4d4;
|
||||
padding:5px;
|
||||
padding-top:7px;
|
||||
padding-bottom:7px;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
.code {
|
||||
font-family:courier;
|
||||
background-color:lightgray;
|
||||
border:1px solid gray;
|
||||
}
|
||||
|
||||
.untriaged { color:black; }
|
||||
.tp { color:black; }
|
||||
.fp { color:lightgray; }
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
|
||||
import glob
|
||||
import sys
|
||||
import re
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print('usage: triage.py project resultsfile.txt')
|
||||
sys.exit(1)
|
||||
|
||||
project = sys.argv[1]
|
||||
resultfile = sys.argv[2]
|
||||
|
||||
f = open(project + '/true-positives.txt', 'rt')
|
||||
truepositives = f.read()
|
||||
f.close();
|
||||
|
||||
f = open(project + '/false-positives.txt', 'rt')
|
||||
falsepositives = f.read()
|
||||
f.close();
|
||||
|
||||
fin = open(resultfile,'rt')
|
||||
results = fin.readlines()
|
||||
fin.close()
|
||||
|
||||
fout = open('report.html','wt')
|
||||
fout.write('<html><head><title>Cppcheck results for ' + project + '</title><link rel="stylesheet" type="text/css" href="theme1.css"></head><body>\n')
|
||||
fout.write('<h1>Cppcheck results for ' + project + '</h1>\n')
|
||||
fout.write('<table border="0">\n')
|
||||
fout.write('<tr><th>Filename</th><th>Line</th><th>Message</th><th>Classification</th></tr>\n')
|
||||
|
||||
out = {}
|
||||
out['untriaged'] = ''
|
||||
out['fp'] = ''
|
||||
out['tp'] = ''
|
||||
|
||||
for result in results:
|
||||
result = result.strip()
|
||||
|
||||
res = re.match('\\[('+project+'.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', result)
|
||||
if res == None:
|
||||
continue
|
||||
|
||||
filename = res.group(1)
|
||||
linenr = res.group(2)
|
||||
message = res.group(3)
|
||||
css = 'untriaged'
|
||||
classification = 'Untriaged'
|
||||
if result in truepositives:
|
||||
css = 'tp'
|
||||
classification = 'Bug'
|
||||
elif result in falsepositives:
|
||||
css = 'fp'
|
||||
classification = 'Not bug'
|
||||
|
||||
html = ' <tr>'
|
||||
html += '<td class='+css+'>'+filename+'</td>'
|
||||
html += '<td class='+css+'>'+linenr+'</td>'
|
||||
html += '<td class='+css+'>'+message+'</td>'
|
||||
html += '<td class='+css+'>'+classification+'</td>'
|
||||
html += '</tr>\n'
|
||||
|
||||
out[css] += html
|
||||
|
||||
fout.write(out['tp'])
|
||||
fout.write(out['fp'])
|
||||
fout.write(out['untriaged'])
|
||||
|
||||
fout.write('</table></body></html>')
|
||||
fout.close()
|
Loading…
Reference in New Issue