@@ -172,7 +172,7 @@ def _is_valid_sbom_file(self):
172172
173173 def _get_bom (self ):
174174 """
175- Get the Billing of Materials from the settings file
175+ Get the Bill of Materials from the settings file
176176 Returns:
177177 dict: If using scanoss.json
178178 list: If using SBOM.json
@@ -196,6 +196,17 @@ def get_bom_include(self) -> List[BomEntry]:
196196 return self ._get_bom ()
197197 return self ._get_bom ().get ('include' , [])
198198
199+
200+ def get_bom_exclude (self ) -> List [BomEntry ]:
201+ """
202+ Get the list of components to exclude from the scan
203+ Returns:
204+ list: List of components to exclude from the scan
205+ """
206+ if self .settings_file_type == 'legacy' :
207+ return self ._get_bom ()
208+ return self ._get_bom ().get ('exclude' , [])
209+
199210 def get_bom_remove (self ) -> List [BomEntry ]:
200211 """
201212 Get the list of components to remove from the scan
@@ -225,8 +236,8 @@ def get_sbom(self):
225236 if not self .data :
226237 return None
227238 return {
228- 'scan_type' : self .scan_type ,
229239 'assets' : json .dumps (self ._get_sbom_assets ()),
240+ 'scan_type' : self .scan_type ,
230241 }
231242
232243 def _get_sbom_assets (self ):
@@ -235,7 +246,18 @@ def _get_sbom_assets(self):
235246 Returns:
236247 List: List of SBOM assets
237248 """
238- if self .scan_type == 'identify' :
249+
250+ if self .settings_file_type == 'new' :
251+ if len (self .get_bom_include ()):
252+ self .scan_type = 'identify'
253+ include_bom_entries = self ._remove_duplicates (self .normalize_bom_entries (self .get_bom_include ()))
254+ return {"components" : include_bom_entries }
255+ elif len (self .get_bom_exclude ()):
256+ self .scan_type = 'blacklist'
257+ exclude_bom_entries = self ._remove_duplicates (self .normalize_bom_entries (self .get_bom_exclude ()))
258+ return {"components" : exclude_bom_entries }
259+
260+ if self .settings_file_type == 'legacy' and self .scan_type == 'identify' : # sbom-identify.json
239261 include_bom_entries = self ._remove_duplicates (self .normalize_bom_entries (self .get_bom_include ()))
240262 replace_bom_entries = self ._remove_duplicates (self .normalize_bom_entries (self .get_bom_replace ()))
241263 self .print_debug (
@@ -244,6 +266,14 @@ def _get_sbom_assets(self):
244266 f'From Replace list: { [entry ["purl" ] for entry in replace_bom_entries ]} \n '
245267 )
246268 return include_bom_entries + replace_bom_entries
269+
270+ if self .settings_file_type == 'legacy' and self .scan_type == 'blacklist' : # sbom-identify.json
271+ exclude_bom_entries = self ._remove_duplicates (self .normalize_bom_entries (self .get_bom_exclude ()))
272+ self .print_debug (
273+ f"Scan type set to 'blacklist'. Adding { len (exclude_bom_entries )} components as context to the scan. \n " # noqa: E501
274+ f'From Exclude list: { [entry ["purl" ] for entry in exclude_bom_entries ]} \n ' )
275+ return exclude_bom_entries
276+
247277 return self .normalize_bom_entries (self .get_bom_remove ())
248278
249279 @staticmethod
0 commit comments