@@ -26,14 +26,29 @@ namespace LCT.PackageIdentifier
2626 /// </summary>
2727 public class AlpineProcessor ( ICycloneDXBomParser cycloneDXBomParser , ISpdxBomParser spdxBomParser ) : IParser
2828 {
29+ #region Fields
2930 private const string ProjectTypeAlpine = "ALPINE" ;
3031 static readonly ILog Logger = LoggerFactory . GetLogger ( MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
3132 private readonly ICycloneDXBomParser _cycloneDXBomParser = cycloneDXBomParser ;
3233 private readonly ISpdxBomParser _spdxBomParser = spdxBomParser ;
3334 private static Bom ListUnsupportedComponentsForBom = new Bom { Components = new List < Component > ( ) , Dependencies = new List < Dependency > ( ) } ;
35+ #endregion
36+
3437 private readonly IEnvironmentHelper _environmentHelper = new EnvironmentHelper ( ) ;
35- #region public method
38+ #region Properties
39+ #endregion
3640
41+ #region Constructors
42+ // Primary constructor parameters are declared on the class.
43+ #endregion
44+
45+ #region Methods
46+ /// <summary>
47+ /// Parses Alpine package files from the configured input folder and builds a BOM.
48+ /// </summary>
49+ /// <param name="appSettings">Application settings with input and processing options.</param>
50+ /// <param name="unSupportedBomList">Reference BOM that will be populated with unsupported components.</param>
51+ /// <returns>BOM built from discovered Alpine packages.</returns>
3752 public Bom ParsePackageFile ( CommonAppSettings appSettings , ref Bom unSupportedBomList )
3853 {
3954 List < string > configFiles ;
@@ -78,12 +93,26 @@ public Bom ParsePackageFile(CommonAppSettings appSettings, ref Bom unSupportedBo
7893 return bom ;
7994 }
8095
96+ /// <summary>
97+ /// Removes components excluded in settings from the provided BOM.
98+ /// </summary>
99+ /// <param name="appSettings">Application settings.</param>
100+ /// <param name="cycloneDXBOM">BOM to filter.</param>
101+ /// <returns>Filtered BOM.</returns>
81102 public static Bom RemoveExcludedComponents ( CommonAppSettings appSettings , Bom cycloneDXBOM )
82103 {
83104 return CommonHelper . RemoveExcludedComponentsFromBom ( appSettings , cycloneDXBOM ,
84105 noOfExcludedComponents => BomCreator . bomKpiData . ComponentsExcludedSW360 += noOfExcludedComponents ) ;
85106 }
86107
108+ /// <summary>
109+ /// Asynchronously retrieves repository details for the provided components and returns a modified list.
110+ /// </summary>
111+ /// <param name="componentsForBOM">List of components to enrich.</param>
112+ /// <param name="appSettings">Application settings.</param>
113+ /// <param name="jFrogService">JFrog service to query (may be null).</param>
114+ /// <param name="bomhelper">BOM helper utilities.</param>
115+ /// <returns>Asynchronously returns the modified list of components.</returns>
87116 public async Task < List < Component > > GetJfrogRepoDetailsOfAComponent ( List < Component > componentsForBOM , CommonAppSettings appSettings ,
88117 IJFrogService jFrogService ,
89118 IBomHelper bomhelper )
@@ -98,24 +127,42 @@ public async Task<List<Component>> GetJfrogRepoDetailsOfAComponent(List<Componen
98127 return modifiedBOM ;
99128 }
100129
130+ /// <summary>
131+ /// Asynchronously identifies internal components using JFrog and BOM helper; returns input unchanged in current implementation.
132+ /// </summary>
133+ /// <param name="componentData">Component identification data to analyze.</param>
134+ /// <param name="appSettings">Application settings.</param>
135+ /// <param name="jFrogService">JFrog service to query.</param>
136+ /// <param name="bomhelper">BOM helper utilities.</param>
137+ /// <returns>Asynchronously returns the (possibly modified) component identification data.</returns>
101138 public async Task < ComponentIdentification > IdentificationOfInternalComponents ( ComponentIdentification componentData ,
102139 CommonAppSettings appSettings , IJFrogService jFrogService , IBomHelper bomhelper )
103140 {
104141 await Task . Yield ( ) ;
105142 return componentData ;
106143 }
107144
108- #endregion
109-
110- #region private methods
111-
145+ /// <summary>
146+ /// Parses a CycloneDX SBOM file and returns a list of AlpinePackage entries.
147+ /// </summary>
148+ /// <param name="filePath">Path to the CycloneDX/ SPDX file.</param>
149+ /// <param name="dependenciesForBOM">List to collect BOM dependencies.</param>
150+ /// <param name="appSettings">Application settings.</param>
151+ /// <returns>List of parsed AlpinePackage instances.</returns>
112152 public List < AlpinePackage > ParseCycloneDX ( string filePath , List < Dependency > dependenciesForBOM , CommonAppSettings appSettings )
113153 {
114154 List < AlpinePackage > alpinePackages = new List < AlpinePackage > ( ) ;
115155 ExtractDetailsForJson ( filePath , ref alpinePackages , dependenciesForBOM , appSettings ) ;
116156 return alpinePackages ;
117157 }
118158
159+ /// <summary>
160+ /// Extracts package details from a BOM file and populates provided collections with packages and dependencies.
161+ /// </summary>
162+ /// <param name="filePath">Path to the BOM file.</param>
163+ /// <param name="alpinePackages">Reference list to append discovered Alpine packages.</param>
164+ /// <param name="dependenciesForBOM">List to collect dependencies discovered in the BOM.</param>
165+ /// <param name="appSettings">Application settings.</param>
119166 private void ExtractDetailsForJson ( string filePath , ref List < AlpinePackage > alpinePackages , List < Dependency > dependenciesForBOM , CommonAppSettings appSettings )
120167 {
121168 Bom listUnsupportedComponents = new Bom { Components = new List < Component > ( ) , Dependencies = new List < Dependency > ( ) } ;
@@ -151,6 +198,11 @@ private void ExtractDetailsForJson(string filePath, ref List<AlpinePackage> alpi
151198 ListUnsupportedComponentsForBom . Components . AddRange ( listUnsupportedComponents . Components ) ;
152199 ListUnsupportedComponentsForBom . Dependencies . AddRange ( listUnsupportedComponents . Dependencies ) ;
153200 }
201+
202+ /// <summary>
203+ /// Removes duplicate components from the provided list and updates KPI data.
204+ /// </summary>
205+ /// <param name="listofComponents">Reference to the component list to deduplicate.</param>
154206 private static string GetReleaseExternalId ( string name , string version )
155207 {
156208 return BomHelper . GetReleaseExternalId ( name , version , Dataconstant . PurlCheck ( ) [ ProjectTypeAlpine ] ) ;
@@ -174,6 +226,11 @@ private static string GetDistro(AlpinePackage alpinePackage)
174226 return alpinePackage . PurlID [ distroIndex ..] ;
175227 }
176228
229+ /// <summary>
230+ /// Forms a list of CycloneDX Component objects from parsed Alpine packages, adding PURLs and properties.
231+ /// </summary>
232+ /// <param name="listOfComponents">List of parsed Alpine packages.</param>
233+ /// <returns>List of components ready for BOM insertion.</returns>
177234 private static List < Component > FormComponentReleaseExternalID ( List < AlpinePackage > listOfComponents )
178235 {
179236 List < Component > listComponentForBOM = new List < Component > ( ) ;
@@ -194,6 +251,12 @@ private static List<Component> FormComponentReleaseExternalID(List<AlpinePackage
194251 }
195252 return listComponentForBOM ;
196253 }
254+
255+ /// <summary>
256+ /// Adds properties to a CycloneDX component based on SPDX information or discovery metadata.
257+ /// </summary>
258+ /// <param name="prop">Parsed Alpine package information.</param>
259+ /// <param name="component">Component to enrich.</param>
197260 private static void AddComponentProperties ( AlpinePackage prop , Component component )
198261 {
199262 if ( prop . SpdxComponentDetails . SpdxComponent )
@@ -209,6 +272,13 @@ private static void AddComponentProperties(AlpinePackage prop, Component compone
209272 component . Properties . Add ( identifierType ) ;
210273 }
211274 }
275+
276+ /// <summary>
277+ /// Sets SPDX related details on an AlpinePackage when the source file is an SPDX file.
278+ /// </summary>
279+ /// <param name="filePath">Source file path.</param>
280+ /// <param name="package">Alpine package to update.</param>
281+ /// <param name="componentInfo">Component information parsed from the BOM.</param>
212282 private static void SetSpdxComponentDetails ( string filePath , AlpinePackage package , Component componentInfo )
213283 {
214284 if ( filePath . EndsWith ( FileConstant . SPDXFileExtension ) )
@@ -220,5 +290,8 @@ private static void SetSpdxComponentDetails(string filePath, AlpinePackage packa
220290 }
221291
222292 #endregion
293+
294+ #region Events
295+ #endregion
223296 }
224297}
0 commit comments