@@ -26,13 +26,27 @@ namespace LCT.PackageIdentifier
2626 /// </summary>
2727 public class AlpineProcessor(ICycloneDXBomParser cycloneDXBomParser, ISpdxBomParser spdxBomParser) : IParser
2828 {
29+ #region Fields
2930 static readonly ILog Logger = LoggerFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
3031 private readonly ICycloneDXBomParser _cycloneDXBomParser = cycloneDXBomParser;
3132 private readonly ISpdxBomParser _spdxBomParser = spdxBomParser;
3233 private static Bom ListUnsupportedComponentsForBom = new Bom { Components = new List<Component>(), Dependencies = new List<Dependency>() };
34+ #endregion
35+
36+ #region Properties
37+ #endregion
3338
34- #region public method
39+ #region Constructors
40+ // Primary constructor parameters are declared on the class.
41+ #endregion
3542
43+ #region Methods
44+ /// <summary>
45+ /// Parses Alpine package files from the configured input folder and builds a BOM.
46+ /// </summary>
47+ /// <param name="appSettings">Application settings with input and processing options.</param>
48+ /// <param name="unSupportedBomList">Reference BOM that will be populated with unsupported components.</param>
49+ /// <returns>BOM built from discovered Alpine packages.</returns>
3650 public Bom ParsePackageFile(CommonAppSettings appSettings, ref Bom unSupportedBomList)
3751 {
3852 List<string> configFiles;
@@ -77,12 +91,26 @@ public Bom ParsePackageFile(CommonAppSettings appSettings, ref Bom unSupportedBo
7791 return bom;
7892 }
7993
94+ /// <summary>
95+ /// Removes components excluded in settings from the provided BOM.
96+ /// </summary>
97+ /// <param name="appSettings">Application settings.</param>
98+ /// <param name="cycloneDXBOM">BOM to filter.</param>
99+ /// <returns>Filtered BOM.</returns>
80100 public static Bom RemoveExcludedComponents(CommonAppSettings appSettings, Bom cycloneDXBOM)
81101 {
82102 return CommonHelper.RemoveExcludedComponentsFromBom(appSettings, cycloneDXBOM,
83103 noOfExcludedComponents => BomCreator.bomKpiData.ComponentsExcludedSW360 += noOfExcludedComponents);
84104 }
85105
106+ /// <summary>
107+ /// Asynchronously retrieves repository details for the provided components and returns a modified list.
108+ /// </summary>
109+ /// <param name="componentsForBOM">List of components to enrich.</param>
110+ /// <param name="appSettings">Application settings.</param>
111+ /// <param name="jFrogService">JFrog service to query (may be null).</param>
112+ /// <param name="bomhelper">BOM helper utilities.</param>
113+ /// <returns>Asynchronously returns the modified list of components.</returns>
86114 public async Task<List<Component>> GetJfrogRepoDetailsOfAComponent(List<Component> componentsForBOM, CommonAppSettings appSettings,
87115 IJFrogService jFrogService,
88116 IBomHelper bomhelper)
@@ -97,24 +125,42 @@ public async Task<List<Component>> GetJfrogRepoDetailsOfAComponent(List<Componen
97125 return modifiedBOM;
98126 }
99127
128+ /// <summary>
129+ /// Asynchronously identifies internal components using JFrog and BOM helper; returns input unchanged in current implementation.
130+ /// </summary>
131+ /// <param name="componentData">Component identification data to analyze.</param>
132+ /// <param name="appSettings">Application settings.</param>
133+ /// <param name="jFrogService">JFrog service to query.</param>
134+ /// <param name="bomhelper">BOM helper utilities.</param>
135+ /// <returns>Asynchronously returns the (possibly modified) component identification data.</returns>
100136 public async Task<ComponentIdentification> IdentificationOfInternalComponents(ComponentIdentification componentData,
101137 CommonAppSettings appSettings, IJFrogService jFrogService, IBomHelper bomhelper)
102138 {
103139 await Task.Yield();
104140 return componentData;
105141 }
106142
107- #endregion
108-
109- #region private methods
110-
143+ /// <summary>
144+ /// Parses a CycloneDX SBOM file and returns a list of AlpinePackage entries.
145+ /// </summary>
146+ /// <param name="filePath">Path to the CycloneDX/ SPDX file.</param>
147+ /// <param name="dependenciesForBOM">List to collect BOM dependencies.</param>
148+ /// <param name="appSettings">Application settings.</param>
149+ /// <returns>List of parsed AlpinePackage instances.</returns>
111150 public List<AlpinePackage> ParseCycloneDX(string filePath, List<Dependency> dependenciesForBOM, CommonAppSettings appSettings)
112151 {
113152 List<AlpinePackage> alpinePackages = new List<AlpinePackage>();
114153 ExtractDetailsForJson(filePath, ref alpinePackages, dependenciesForBOM, appSettings);
115154 return alpinePackages;
116155 }
117156
157+ /// <summary>
158+ /// Extracts package details from a BOM file and populates provided collections with packages and dependencies.
159+ /// </summary>
160+ /// <param name="filePath">Path to the BOM file.</param>
161+ /// <param name="alpinePackages">Reference list to append discovered Alpine packages.</param>
162+ /// <param name="dependenciesForBOM">List to collect dependencies discovered in the BOM.</param>
163+ /// <param name="appSettings">Application settings.</param>
118164 private void ExtractDetailsForJson(string filePath, ref List<AlpinePackage> alpinePackages, List<Dependency> dependenciesForBOM, CommonAppSettings appSettings)
119165 {
120166 Bom listUnsupportedComponents = new Bom { Components = new List<Component>(), Dependencies = new List<Dependency>() };
@@ -151,6 +197,10 @@ private void ExtractDetailsForJson(string filePath, ref List<AlpinePackage> alpi
151197 ListUnsupportedComponentsForBom.Dependencies.AddRange(listUnsupportedComponents.Dependencies);
152198 }
153199
200+ /// <summary>
201+ /// Removes duplicate components from the provided list and updates KPI data.
202+ /// </summary>
203+ /// <param name="listofComponents">Reference to the component list to deduplicate.</param>
154204 private static void GetDistinctComponentList(ref List<AlpinePackage> listofComponents)
155205 {
156206 int initialCount = listofComponents.Count;
@@ -160,6 +210,12 @@ private static void GetDistinctComponentList(ref List<AlpinePackage> listofCompo
160210 BomCreator.bomKpiData.DuplicateComponents = initialCount - listofComponents.Count;
161211 }
162212
213+ /// <summary>
214+ /// Builds a release external id (purl) for the specified name and version.
215+ /// </summary>
216+ /// <param name="name">Package name.</param>
217+ /// <param name="version">Package version.</param>
218+ /// <returns>Release external id as a PURL string.</returns>
163219 private static string GetReleaseExternalId(string name, string version)
164220 {
165221 version = WebUtility.UrlEncode(version);
@@ -168,6 +224,11 @@ private static string GetReleaseExternalId(string name, string version)
168224 return $"{Dataconstant.PurlCheck()["ALPINE"]}{Dataconstant.ForwardSlash}{name}@{version}?arch=source";
169225 }
170226
227+ /// <summary>
228+ /// Extracts the distro query portion from an Alpine package PURL if present.
229+ /// </summary>
230+ /// <param name="alpinePackage">Alpine package to inspect.</param>
231+ /// <returns>Distro query string including leading token, or empty string if not found.</returns>
171232 private static string GetDistro(AlpinePackage alpinePackage)
172233 {
173234 var distroIndex = alpinePackage.PurlID.LastIndexOf("distro");
@@ -178,6 +239,11 @@ private static string GetDistro(AlpinePackage alpinePackage)
178239 return alpinePackage.PurlID[distroIndex..];
179240 }
180241
242+ /// <summary>
243+ /// Forms a list of CycloneDX Component objects from parsed Alpine packages, adding PURLs and properties.
244+ /// </summary>
245+ /// <param name="listOfComponents">List of parsed Alpine packages.</param>
246+ /// <returns>List of components ready for BOM insertion.</returns>
181247 private static List<Component> FormComponentReleaseExternalID(List<AlpinePackage> listOfComponents)
182248 {
183249 List<Component> listComponentForBOM = new List<Component>();
@@ -198,6 +264,12 @@ private static List<Component> FormComponentReleaseExternalID(List<AlpinePackage
198264 }
199265 return listComponentForBOM;
200266 }
267+
268+ /// <summary>
269+ /// Adds properties to a CycloneDX component based on SPDX information or discovery metadata.
270+ /// </summary>
271+ /// <param name="prop">Parsed Alpine package information.</param>
272+ /// <param name="component">Component to enrich.</param>
201273 private static void AddComponentProperties(AlpinePackage prop, Component component)
202274 {
203275 if (prop.SpdxComponentDetails.SpdxComponent)
@@ -213,6 +285,13 @@ private static void AddComponentProperties(AlpinePackage prop, Component compone
213285 component.Properties.Add(identifierType);
214286 }
215287 }
288+
289+ /// <summary>
290+ /// Sets SPDX related details on an AlpinePackage when the source file is an SPDX file.
291+ /// </summary>
292+ /// <param name="filePath">Source file path.</param>
293+ /// <param name="package">Alpine package to update.</param>
294+ /// <param name="componentInfo">Component information parsed from the BOM.</param>
216295 private static void SetSpdxComponentDetails(string filePath, AlpinePackage package, Component componentInfo)
217296 {
218297 if (filePath.EndsWith(FileConstant.SPDXFileExtension))
@@ -224,5 +303,8 @@ private static void SetSpdxComponentDetails(string filePath, AlpinePackage packa
224303 }
225304
226305 #endregion
306+
307+ #region Events
308+ #endregion
227309 }
228310}
0 commit comments