Skip to content

Commit

Permalink
Fix exit code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkiros committed Oct 18, 2024
1 parent 235cb09 commit 4b5ea9d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
21 changes: 10 additions & 11 deletions capec2technique.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,14 @@ def process_capec(cve_capec_data, capec_list, cve_year):
cve_entry = json.loads(line.strip())
cve_capec_data.update(cve_entry)

if not cve_capec_data:
if cve_capec_data:
# Load the CAPEC database
with open(CAPEC_FILE, 'r') as f:
capec_list = json.load(f)

cve_year = list(cve_capec_data.keys())[0].split('-')[1]

process_capec(cve_capec_data, capec_list, cve_year)
save_jsonl(cve_capec_data)
else:
print("[-]No new vulnerabilities found")
sys.exit(0)

# Load the CAPEC database
with open(CAPEC_FILE, 'r') as f:
capec_list = json.load(f)

cve_year = list(cve_capec_data.keys())[0].split('-')[1]

process_capec(cve_capec_data, capec_list, cve_year)
save_jsonl(cve_capec_data)
15 changes: 7 additions & 8 deletions cve2cwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ def save_jsonl(cve_cwe_data):
cve = json.loads(line.strip())
cve_cwe_data.update(cve)

if not cve_cwe_data:
print("[-]No new vulnerabilities found")
sys.exit(1)

cwe_db = load_db()

cve_year = list(cve_cwe_data.keys())[0].split('-')[1]
if cve_cwe_data:
cwe_db = load_db()

cve_year = list(cve_cwe_data.keys())[0].split('-')[1]

process_cve_to_cwe(cve_cwe_data, cve_year, cwe_db)
process_cve_to_cwe(cve_cwe_data, cve_year, cwe_db)
else:
print("[-]No new vulnerabilities found")
29 changes: 14 additions & 15 deletions cwe2capec.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,19 @@ def load_db():
cve = json.loads(line.strip())
cve_cwe_data.update(cve)

if not cve_cwe_data:
print("[-]No new vulnerabilities found")
sys.exit(0)

cwe_db = load_db()

# Get the year of the CVEs
cve_year = list(cve_cwe_data.keys())[0].split('-')[1]
if cve_cwe_data:
cwe_db = load_db()

# Get the year of the CVEs
cve_year = list(cve_cwe_data.keys())[0].split('-')[1]

# Process each CVE to extract the related CAPEC entries
cve_capec_data = {}
for cve in tqdm(cve_cwe_data, desc=f"Processing CWE to CAPEC for CVE-{cve_year}", unit="CVE"):
cwe_list = cve_cwe_data[cve]["CWE"]
cve_capec_data[cve] = {"CWE": cwe_list}
cve_capec_data[cve]["CAPEC"] = process_cwe_to_capec(cwe_list, cwe_db)
# Process each CVE to extract the related CAPEC entries
cve_capec_data = {}
for cve in tqdm(cve_cwe_data, desc=f"Processing CWE to CAPEC for CVE-{cve_year}", unit="CVE"):
cwe_list = cve_cwe_data[cve]["CWE"]
cve_capec_data[cve] = {"CWE": cwe_list}
cve_capec_data[cve]["CAPEC"] = process_cwe_to_capec(cwe_list, cwe_db)

save_jsonl(cve_capec_data)
save_jsonl(cve_capec_data)
else:
print("[-]No new vulnerabilities found")

0 comments on commit 4b5ea9d

Please sign in to comment.