Skip to content

Commit

Permalink
updated script to sort data with ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Anof-cyber committed Dec 13, 2024
1 parent 97539bf commit 1f76b94
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ def fetch_and_parse_cwe_data():
'description': weakness.find('./Description', namespaces=xml_namespaces).text,
})

# Sort the CWE list by 'name'
cwe_entries = sorted(cwe_entries, key=lambda cwe: cwe['name'])
# Sort the CWE list by CWE-ID (numerical order)
def extract_cwe_id(cwe):
# Extract numeric CWE-ID from "CWE-ID: Name"
return int(cwe['name'].split('-')[1].split(':')[0])

cwe_entries = sorted(cwe_entries, key=extract_cwe_id)

# Save the data to a JSON file
output_json_path = Path(__file__).parent / 'cwe.json'
Expand Down

0 comments on commit 1f76b94

Please sign in to comment.