Yield CWE Weakness objects
(self)
| 513 | |
| 514 | |
| 515 | def 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 | |
| 538 | Database.get_cwes = get_cwes |