@@ -169,6 +169,25 @@ def _check_suppressions(self, record: Record, suppressions: Optional[list[dict[s
169
169
return suppression
170
170
return None
171
171
172
+ def _check_cve_suppression (self , record : Record , suppression : dict [str , Any ]) -> bool :
173
+ if 'accountIds' not in suppression :
174
+ return False
175
+ if self .bc_integration .repo_id and self .bc_integration .source_id and self .bc_integration .source_id in \
176
+ suppression ['accountIds' ] \
177
+ and suppression ['cves' ]:
178
+ repo_name = align_path (self .bc_integration .repo_id ).split ('/' )[- 1 ]
179
+ suppression_path = self ._get_cve_suppression_path (suppression )
180
+ repo_file_path = align_path (record .repo_file_path )
181
+ file_abs_path = align_path (record .file_abs_path )
182
+ if file_abs_path == suppression_path [1 :] or \
183
+ file_abs_path == suppression_path or \
184
+ file_abs_path .endswith ("" .join ([repo_name , suppression_path ])) or \
185
+ removeprefix (repo_file_path , '/' ) == removeprefix (suppression_path , '/' ) \
186
+ or record .file_path == suppression_path :
187
+ return any (record .vulnerability_details and record .vulnerability_details ['id' ] == cve ['cve' ]
188
+ for cve in suppression ['cves' ])
189
+ return False
190
+
172
191
def _check_suppression (self , record : Record , suppression : dict [str , Any ]) -> bool :
173
192
"""
174
193
Returns True if and only if the specified suppression applies to the specified record.
@@ -217,21 +236,7 @@ def _check_suppression(self, record: Record, suppression: dict[str, Any]) -> boo
217
236
return False
218
237
219
238
elif type == 'Cves' :
220
- if 'accountIds' not in suppression :
221
- return False
222
- if self .bc_integration .repo_id and self .bc_integration .source_id and self .bc_integration .source_id in suppression ['accountIds' ]\
223
- and suppression ['cves' ]:
224
- repo_name = align_path (self .bc_integration .repo_id ).split ('/' )[- 1 ]
225
- suppression_path = self ._get_cve_suppression_path (suppression )
226
- repo_file_path = align_path (record .repo_file_path )
227
- file_abs_path = align_path (record .file_abs_path )
228
- if file_abs_path == suppression_path [1 :] or \
229
- file_abs_path == suppression_path or \
230
- file_abs_path .endswith ("" .join ([repo_name , suppression_path ])) or \
231
- removeprefix (repo_file_path , '/' ) == removeprefix (suppression_path , '/' ):
232
- return any (record .vulnerability_details and record .vulnerability_details ['id' ] == cve ['cve' ]
233
- for cve in suppression ['cves' ])
234
- return False
239
+ return self ._check_cve_suppression (record , suppression )
235
240
236
241
elif type == 'LicenseType' :
237
242
return any (record .vulnerability_details and record .vulnerability_details ['license' ] == license_type
0 commit comments