Skip to content

Commit 5d24cee

Browse files
committed
feat(datasets): support parent/children relationships in CWE comparison to reduce false positives
1 parent 73bc0a3 commit 5d24cee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

codesectools/datasets/core/dataset.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class Dataset(ABC):
3434
name (str): The name of the dataset.
3535
supported_languages (list[str]): A list of programming languages supported
3636
by the dataset.
37+
license (str): The license under which the dataset is distributed.
38+
license_url (str): A URL to the full text of the license.
3739
3840
"""
3941

@@ -333,8 +335,7 @@ def validate(self, analysis_result: AnalysisResult) -> FileDatasetData:
333335

334336
for (filepath, cwe), defect in unique_reported_defects.items():
335337
has_vuln, expected_cwes = ground_truth.get(filepath, (False, set()))
336-
337-
if has_vuln and cwe in expected_cwes:
338+
if has_vuln and bool(cwe.extend() & expected_cwes):
338339
# Correctly identified a vulnerability
339340
tp_defects_map[(filepath, cwe)] = defect
340341
else:
@@ -609,7 +610,7 @@ def validate(self, analysis_results: list[AnalysisResult]) -> GitRepoDatasetData
609610
for (filename, cwe), defect in unique_reported_defects.items():
610611
# A reported defect is a TP if it's in a known vulnerable file
611612
# with a known CWE for that repo.
612-
if filename in repo.files and cwe in repo.cwes:
613+
if filename in repo.files and bool(cwe.extend() & set(repo.cwes)):
613614
tp_defects_map[(filename, cwe)] = defect
614615
else:
615616
fp_defects_map[(filename, cwe)] = defect

0 commit comments

Comments
 (0)