parent
bdc024bd7c
commit
c090ed2fc9
|
@ -275,7 +275,9 @@ class AnnotateCodeFormatter(HtmlFormatter):
|
||||||
if error['line'] == line_no:
|
if error['line'] == line_no:
|
||||||
try:
|
try:
|
||||||
if error['inconclusive'] == 'true':
|
if error['inconclusive'] == 'true':
|
||||||
if error.get('verbose') and (error['verbose'] != error['msg']): # only print verbose msg if it really differs from actual message
|
# only print verbose msg if it really differs
|
||||||
|
# from actual message
|
||||||
|
if error.get('verbose') and (error['verbose'] != error['msg']):
|
||||||
index = t.rfind('\n')
|
index = t.rfind('\n')
|
||||||
t = t[:index] + HTML_EXPANDABLE_INCONCLUSIVE % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index + 1:]
|
t = t[:index] + HTML_EXPANDABLE_INCONCLUSIVE % (error['msg'], html_escape(error['verbose'].replace("\\012", '\n'))) + t[index + 1:]
|
||||||
else:
|
else:
|
||||||
|
@ -584,7 +586,6 @@ if __name__ == '__main__':
|
||||||
'w') as css_file:
|
'w') as css_file:
|
||||||
css_file.write(STYLE_FILE)
|
css_file.write(STYLE_FILE)
|
||||||
|
|
||||||
|
|
||||||
print("Creating stats.html (statistics)\n")
|
print("Creating stats.html (statistics)\n")
|
||||||
stats_countlist = {}
|
stats_countlist = {}
|
||||||
|
|
||||||
|
@ -609,27 +610,30 @@ if __name__ == '__main__':
|
||||||
_sum = 0
|
_sum = 0
|
||||||
stats_templist = {}
|
stats_templist = {}
|
||||||
|
|
||||||
try: # if the we have an style warning but we are checking for portability, we have to skip it to prevent KeyError
|
# if the we have an style warning but we are checking for
|
||||||
|
# portability, we have to skip it to prevent KeyError
|
||||||
|
try:
|
||||||
for filename in stats_countlist:
|
for filename in stats_countlist:
|
||||||
try: # also bail out if we have a file with no sev-results
|
try: # also bail out if we have a file with no sev-results
|
||||||
_sum += stats_countlist[filename][sev]
|
_sum += stats_countlist[filename][sev]
|
||||||
stats_templist[filename] = (int)(stats_countlist[filename][sev]) # file : amount,
|
stats_templist[filename] = (int)(stats_countlist[filename][sev]) # file : amount,
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
if (_sum == 0): # don't print "0 style" etc, if no style warnings were found
|
# don't print "0 style" etc, if no style warnings were found
|
||||||
|
if (_sum == 0):
|
||||||
break
|
break
|
||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
stats_file.write("<p>Top 10 files for " + sev + " severity, total findings: " + str(_sum) + "</br>\n")
|
stats_file.write("<p>Top 10 files for " + sev + " severity, total findings: " + str(_sum) + "</br>\n")
|
||||||
|
|
||||||
|
|
||||||
# sort, so that the file with the most severities per type is first
|
# sort, so that the file with the most severities per type is first
|
||||||
stats_list_sorted = sorted(stats_templist.items(), key=operator.itemgetter(1, 0), reverse=True)
|
stats_list_sorted = sorted(stats_templist.items(), key=operator.itemgetter(1, 0), reverse=True)
|
||||||
it = 0
|
it = 0
|
||||||
LENGTH = 0
|
LENGTH = 0
|
||||||
|
|
||||||
for i in stats_list_sorted: # printing loop
|
for i in stats_list_sorted: # printing loop
|
||||||
# for aesthetics: if it's the first iteration of the loop, get the max length of the number string
|
# for aesthetics: if it's the first iteration of the loop, get
|
||||||
|
# the max length of the number string
|
||||||
if (it == 0):
|
if (it == 0):
|
||||||
LENGTH = len(str(i[1])) # <- length of longest number, now get the difference and try to make other numbers align to it
|
LENGTH = len(str(i[1])) # <- length of longest number, now get the difference and try to make other numbers align to it
|
||||||
|
|
||||||
|
@ -640,4 +644,3 @@ if __name__ == '__main__':
|
||||||
stats_file.write("</p>\n")
|
stats_file.write("</p>\n")
|
||||||
|
|
||||||
print("\nOpen '" + options.report_dir + "/index.html' to see the results.")
|
print("\nOpen '" + options.report_dir + "/index.html' to see the results.")
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ def upload(file_to_upload, destination):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# git push
|
# git push
|
||||||
|
|
||||||
|
|
||||||
def gitpush():
|
def gitpush():
|
||||||
try:
|
try:
|
||||||
password = sys.argv[1]
|
password = sys.argv[1]
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
|
||||||
class Token:
|
class Token:
|
||||||
Id = None
|
Id = None
|
||||||
str = None
|
str = None
|
||||||
|
@ -109,6 +110,7 @@ class Token:
|
||||||
return value
|
return value
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Scope:
|
class Scope:
|
||||||
Id = None
|
Id = None
|
||||||
classStartId = None
|
classStartId = None
|
||||||
|
@ -134,20 +136,24 @@ class Scope:
|
||||||
self.classEnd = IdMap[self.classEndId]
|
self.classEnd = IdMap[self.classEndId]
|
||||||
self.nestedIn = IdMap[self.nestedInId]
|
self.nestedIn = IdMap[self.nestedInId]
|
||||||
|
|
||||||
|
|
||||||
class Function:
|
class Function:
|
||||||
Id = None
|
Id = None
|
||||||
argument = None
|
argument = None
|
||||||
argumentId = None
|
argumentId = None
|
||||||
|
|
||||||
def __init__(self, element):
|
def __init__(self, element):
|
||||||
self.Id = element.get('id')
|
self.Id = element.get('id')
|
||||||
self.argument = {}
|
self.argument = {}
|
||||||
self.argumentId = {}
|
self.argumentId = {}
|
||||||
for arg in element:
|
for arg in element:
|
||||||
self.argumentId[arg.get('nr')] = arg.get('id')
|
self.argumentId[arg.get('nr')] = arg.get('id')
|
||||||
|
|
||||||
def setId(self, IdMap):
|
def setId(self, IdMap):
|
||||||
for argnr, argid in self.argumentId.items():
|
for argnr, argid in self.argumentId.items():
|
||||||
self.argument[argnr] = IdMap[argid]
|
self.argument[argnr] = IdMap[argid]
|
||||||
|
|
||||||
|
|
||||||
class Variable:
|
class Variable:
|
||||||
Id = None
|
Id = None
|
||||||
nameTokenId = None
|
nameTokenId = None
|
||||||
|
@ -185,10 +191,13 @@ class Variable:
|
||||||
self.typeStartToken = IdMap[self.typeStartTokenId]
|
self.typeStartToken = IdMap[self.typeStartTokenId]
|
||||||
self.typeEndToken = IdMap[self.typeEndTokenId]
|
self.typeEndToken = IdMap[self.typeEndTokenId]
|
||||||
|
|
||||||
|
|
||||||
class ValueFlow:
|
class ValueFlow:
|
||||||
|
|
||||||
class Value:
|
class Value:
|
||||||
intvalue = None
|
intvalue = None
|
||||||
condition = None
|
condition = None
|
||||||
|
|
||||||
def __init__(self, element):
|
def __init__(self, element):
|
||||||
self.intvalue = int(element.get('intvalue'))
|
self.intvalue = int(element.get('intvalue'))
|
||||||
self.condition = element.get('condition-line')
|
self.condition = element.get('condition-line')
|
||||||
|
@ -197,12 +206,14 @@ class ValueFlow:
|
||||||
|
|
||||||
Id = None
|
Id = None
|
||||||
values = None
|
values = None
|
||||||
|
|
||||||
def __init__(self, element):
|
def __init__(self, element):
|
||||||
self.Id = element.get('id')
|
self.Id = element.get('id')
|
||||||
self.values = []
|
self.values = []
|
||||||
for value in element:
|
for value in element:
|
||||||
self.values.append(ValueFlow.Value(value))
|
self.values.append(ValueFlow.Value(value))
|
||||||
|
|
||||||
|
|
||||||
class CppcheckData:
|
class CppcheckData:
|
||||||
tokenlist = []
|
tokenlist = []
|
||||||
scopes = []
|
scopes = []
|
||||||
|
@ -266,10 +277,13 @@ class CppcheckData:
|
||||||
for variable in self.variables:
|
for variable in self.variables:
|
||||||
variable.setId(IdMap)
|
variable.setId(IdMap)
|
||||||
|
|
||||||
|
|
||||||
def parsedump(filename):
|
def parsedump(filename):
|
||||||
return CppcheckData(filename)
|
return CppcheckData(filename)
|
||||||
|
|
||||||
# Check if type of ast node is float/double
|
# Check if type of ast node is float/double
|
||||||
|
|
||||||
|
|
||||||
def astIsFloat(token):
|
def astIsFloat(token):
|
||||||
if not token:
|
if not token:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -125,6 +125,7 @@ def removeLargeFiles(path):
|
||||||
elif g[-2:] != '.C' and g[-2:] != '.c' and g[-4:] != '.cc' and g[-4:] != '.cpp' and g[-4:] != '.cxx' and g[-2:] != '.h' and g[-2:] != '.H' and g[-4:] != '.c++' and g[-4:] != '.hpp' and g[-4:] != '.tpp' and g[-4:] != '.t++':
|
elif g[-2:] != '.C' and g[-2:] != '.c' and g[-4:] != '.cc' and g[-4:] != '.cpp' and g[-4:] != '.cxx' and g[-2:] != '.h' and g[-2:] != '.H' and g[-4:] != '.c++' and g[-4:] != '.hpp' and g[-4:] != '.tpp' and g[-4:] != '.t++':
|
||||||
os.remove(g)
|
os.remove(g)
|
||||||
|
|
||||||
|
|
||||||
def downloadpackage(filepath, outpath):
|
def downloadpackage(filepath, outpath):
|
||||||
# remove all files/folders
|
# remove all files/folders
|
||||||
removeAll()
|
removeAll()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def checknonnull(cfg, functionName, nonnull):
|
def checknonnull(cfg, functionName, nonnull):
|
||||||
pos1 = cfg.find('<function name="' + functionName + '">')
|
pos1 = cfg.find('<function name="' + functionName + '">')
|
||||||
if pos1 < 0:
|
if pos1 < 0:
|
||||||
|
@ -30,7 +31,6 @@ def checknonnull(cfg, functionName, nonnull):
|
||||||
print(functionName + '\tglibc:' + nonnull + '\tcfg:' + s)
|
print(functionName + '\tglibc:' + nonnull + '\tcfg:' + s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parseheader(cppcheckpath, filename):
|
def parseheader(cppcheckpath, filename):
|
||||||
f = open(filename, 'rt')
|
f = open(filename, 'rt')
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|
Loading…
Reference in New Issue