1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import matplotlib.pyplot as plt
- class TypePlotter:
- def __init__(self, data, years):
- self.src2dsa = data.src2dsa
- self.dsa2cve = data.dsa2cve
- self.cvetable = data.cvetable
- self.pkg_with_cvss = data.pkg_with_cvss
- self.src2cwe = data.src2cwe
- self.years = years
- def plot_types(self):
- src2cwe_sum = []
- for i in range(0, 12*self.years):
- src2cwe_sum.append([0]*12)
-
- for pkg in self.src2cwe:
- for i in range(len(self.src2cwe[pkg])):
- for j in range(len(self.src2cwe[pkg][i])):
- src2cwe_sum[i][j] += self.src2cwe[pkg][i][j]
- src2cwe_sumofsums = [0]*12
- for month in src2cwe_sum:
- for j in range(len(month)):
- src2cwe_sumofsums[j] += month[j]
- print(src2cwe_sumofsums)
- cwe2month = dict()
- for j in range(12):
- cwe2month[j] = []
- for month in src2cwe_sum:
- for j in range(len(month)):
- cwe2month[j].append(month[j])
- print(cwe2month[1])
- print(sum(cwe2month[1]))
- for i in range(12):
- binned = []
- for j in range(self.years*3):
- binned.append(sum(cwe2month[i][4*j:4*j+4]))
- plt.plot(binned)
- plt.show()
- return 0
|