Skip to content

Commit f5dc47f

Browse files
committed
refactor(parser): rename sasts to sast_names to avoid confusion
1 parent 536c081 commit f5dc47f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

codesectools/sasts/all/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def report(
293293
</html>
294294
"""
295295
template = template.replace(
296-
"[sasts]", ", ".join(sast.name for sast in all_sast.sasts)
296+
"[sasts]", ", ".join(sast_name for sast_name in result.sast_names)
297297
)
298298

299299
home_page = Console(record=True, file=io.StringIO())

codesectools/sasts/all/parser.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, name: str, analysis_results: dict[str, AnalysisResult]) -> No
1919
self.source_path = None
2020
self.analysis_results = analysis_results
2121
self.lang = None
22-
self.sasts = []
22+
self.sast_names = []
2323
self.files = set()
2424
self.defects = []
2525

@@ -30,12 +30,12 @@ def __init__(self, name: str, analysis_results: dict[str, AnalysisResult]) -> No
3030
else:
3131
assert analysis_result.lang == self.lang
3232
assert analysis_result.source_path == self.source_path
33-
self.sasts.append(sast_name)
33+
self.sast_names.append(sast_name)
3434
self.files |= set(analysis_result.files)
3535
self.defects += analysis_result.defects
3636

3737
self.category_mapping = {}
38-
for sast_name in self.sasts:
38+
for sast_name in self.sast_names:
3939
sast = SASTS_ALL[sast_name]["sast"]
4040
for category_name, color in sast.color_mapping.items():
4141
if color.lower() == "red":
@@ -55,7 +55,7 @@ def __repr__(self) -> str:
5555
return f"""{self.__class__.__name__}(
5656
name: \t{self.name}
5757
lang: \t{self.lang}
58-
sasts: \t{self.sasts}
58+
sasts: \t{self.sast_names}
5959
file_count: \t{len(self.files)}
6060
defect_count: \t{len(self.defects)}
6161
)"""
@@ -145,7 +145,7 @@ def stats_by_scores(self) -> dict:
145145
cwes_found_by_all_sasts = 0
146146
for cwe in defects_cwes:
147147
cwes_sasts = {d.sast for d in defects if d.cwe == cwe}
148-
if set(self.sasts) == cwes_sasts:
148+
if set(self.sast_names) == cwes_sasts:
149149
cwes_found_by_all_sasts += 1
150150

151151
defect_locations = {}
@@ -158,7 +158,7 @@ def stats_by_scores(self) -> dict:
158158
defects_same_location = 0
159159
defects_same_location_same_cwe = 0
160160
for _, defects_ in defect_locations.items():
161-
if set(defect.sast for defect in defects_) == set(self.sasts):
161+
if set(defect.sast for defect in defects_) == set(self.sast_names):
162162
defects_same_location += 1
163163
defects_by_cwe = {}
164164
for defect in defects_:
@@ -167,7 +167,9 @@ def stats_by_scores(self) -> dict:
167167
defects_by_cwe[defect.cwe].append(defect)
168168

169169
for _, defects_ in defects_by_cwe.items():
170-
if set(defect.sast for defect in defects_) == set(self.sasts):
170+
if set(defect.sast for defect in defects_) == set(
171+
self.sast_names
172+
):
171173
defects_same_location_same_cwe += 1
172174

173175
stats[defect_file] = {

0 commit comments

Comments
 (0)