more_types.py 791 B

12345678910111213141516171819202122232425262728
  1. from load_data import load_DBs
  2. from plot_functions import plot_all
  3. from plot_types import TypePlotter
  4. import json
  5. class Mydata:
  6. def __init__(self, load):
  7. if load:
  8. (self.dsatable, self.src2dsa, self.dsa2cve, self.cvetable, self.src2month, self.src2sloccount, self.src2pop, self.src2deps, self.pkg_with_cvss, self.src2cwe) = load_DBs()
  9. else:
  10. print('no load command given')
  11. def main():
  12. data = Mydata(True)
  13. cwe_counts = dict()
  14. for cvenum in data.cvetable:
  15. cwe = data.cvetable[cvenum][5]
  16. if cwe not in cwe_counts:
  17. cwe_counts[cwe] = 1
  18. else:
  19. cwe_counts[cwe] += 1
  20. with open('cwecounts.json', 'w') as outfile:
  21. json.dump(cwe_counts, outfile)
  22. if __name__ == "__main__":
  23. main()