MCPcopy Create free account
hub / github.com/aboutcode-org/vulnerablecode / get_cwes

Function get_cwes

vulnerabilities/models.py:515–535  ·  view source on GitHub ↗

Yield CWE Weakness objects

(self)

Source from the content-addressed store, hash-verified

513
514
515def get_cwes(self):
516 """Yield CWE Weakness objects"""
517 for cwe_category in self.cwe_files:
518 cwe_category.seek(0)
519 reader = csv.DictReader(cwe_category)
520 for row in reader:
521 yield DBWeakness(*list(row.values())[0:-1])
522 tree = ET.parse(xml_database_path)
523 root = tree.getroot()
524 for tag_num in [1, 2]: # Categories , Views
525 tag = root[tag_num]
526 for child in tag:
527 yield DBWeakness(
528 *[
529 child.attrib["ID"],
530 child.attrib.get("Name"),
531 None,
532 child.attrib.get("Status"),
533 child[0].text,
534 ]
535 )
536
537
538Database.get_cwes = get_cwes

Callers

nothing calls this directly

Calls 2

parseMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected