From 41be36c887c7daccd85c40ac9ec09f744948662d Mon Sep 17 00:00:00 2001 From: Chalapala RaghavendraReddy Date: Sat, 11 Jan 2025 02:59:14 +0530 Subject: [PATCH] Updated package identifier with requested changes UT and IT --- src/LCT.Common/CommonAppSettings.cs | 30 +-------- src/LCT.Common/CommonHelper.cs | 16 ++++- src/LCT.Common/Constants/Dataconstant.cs | 2 +- src/LCT.Common/SettingsManager.cs | 33 ++++++++-- src/LCT.Common/appSettings.json | 3 +- .../AlpineParserTests.cs | 6 +- .../DebianParserTests.cs | 4 +- .../MavenParserTests.cs | 4 +- .../NPMParserTests.cs | 4 +- .../PythonParserTests.cs | 4 +- .../SBomTemplateTests.cs | 2 +- src/LCT.PackageIdentifier/AlpineProcesser.cs | 26 ++++---- src/LCT.PackageIdentifier/BomCreator.cs | 22 +++++-- src/LCT.PackageIdentifier/ConanProcessor.cs | 29 ++++----- src/LCT.PackageIdentifier/DebianProcessor.cs | 21 +++--- src/LCT.PackageIdentifier/MavenProcessor.cs | 24 +++---- src/LCT.PackageIdentifier/NpmProcessor.cs | 25 ++++---- src/LCT.PackageIdentifier/NugetProcessor.cs | 27 ++++---- src/LCT.PackageIdentifier/Program.cs | 3 +- src/LCT.PackageIdentifier/PythonProcessor.cs | 21 +++--- .../Conan/PackageIdentifierInitialConan.cs | 3 +- .../Debian/PackageIdentifierInitialDebian.cs | 3 +- .../Maven/PackageIdentifierInitialMaven.cs | 3 +- .../NPM/PackageIdentifierInitial.cs | 3 +- .../Nuget/PackageIdentifierInitialNuget.cs | 3 +- .../Python/PackageIdentifierInitialPython.cs | 3 +- src/TestUtilities/TestConstant.cs | 64 ++++++++++--------- src/TestUtilities/TestParamConan.cs | 2 +- 28 files changed, 205 insertions(+), 185 deletions(-) diff --git a/src/LCT.Common/CommonAppSettings.cs b/src/LCT.Common/CommonAppSettings.cs index 8fad5daf..bbb388c1 100644 --- a/src/LCT.Common/CommonAppSettings.cs +++ b/src/LCT.Common/CommonAppSettings.cs @@ -61,6 +61,7 @@ public string ProjectType m_ProjectType = value; } } + public bool MultipleProjectType { get; set; } = false; public SW360 SW360 { get; set; } public Directory Directory { get; set; } public Jfrog Jfrog { get; set; } @@ -212,8 +213,7 @@ public class Directory private readonly IFolderAction folderAction; private readonly IFileOperations _fileOperations; private string m_InputFolder; - private string m_OutputFolder; - private string m_BomFilePath; + private string m_OutputFolder; public Directory(IFolderAction folderAction, IFileOperations fileOperations) { @@ -236,30 +236,7 @@ public string InputFolder } } } - - public string BomFilePath - { - get - { - return m_BomFilePath; - } - set - { - if (AppDomain.CurrentDomain.FriendlyName.Contains("PackageIdentifier")) - { - if (!string.IsNullOrEmpty(value)) - { - m_BomFilePath = value; - _fileOperations.ValidateFilePath(m_BomFilePath); - } - } - else - { - m_BomFilePath = value; - _fileOperations.ValidateFilePath(m_BomFilePath); - } - } - } + public string OutputFolder { get @@ -280,7 +257,6 @@ public string OutputFolder } } - public string CycloneDxSBomTemplatePath { get; set; } } } diff --git a/src/LCT.Common/CommonHelper.cs b/src/LCT.Common/CommonHelper.cs index cd528f17..c2534772 100644 --- a/src/LCT.Common/CommonHelper.cs +++ b/src/LCT.Common/CommonHelper.cs @@ -40,7 +40,21 @@ public static bool IsAzureDevOpsDebugEnabled() public static List RemoveExcludedComponents(List ComponentList, List ExcludedComponents, ref int noOfExcludedComponents) { List ExcludedList = new List(); - foreach (string excludedComponent in ExcludedComponents) + List ExcludedComponentsFromPurl = ExcludedComponents?.Where(ec => ec.StartsWith("pkg:")).ToList(); + List otherExcludedComponents = ExcludedComponents?.Where(ec => !ec.StartsWith("pkg:")).ToList(); + + foreach (string excludedComponent in ExcludedComponentsFromPurl) + { + foreach (var component in ComponentList) + { + if (component.Purl != null && component.Purl.Equals(excludedComponent, StringComparison.OrdinalIgnoreCase)) + { + noOfExcludedComponents++; + ExcludedList.Add(component); + } + } + } + foreach (string excludedComponent in otherExcludedComponents) { string[] excludedcomponent = excludedComponent.ToLower().Split(':'); foreach (var component in ComponentList) diff --git a/src/LCT.Common/Constants/Dataconstant.cs b/src/LCT.Common/Constants/Dataconstant.cs index ace66df6..01700b3b 100644 --- a/src/LCT.Common/Constants/Dataconstant.cs +++ b/src/LCT.Common/Constants/Dataconstant.cs @@ -21,7 +21,7 @@ public static class Dataconstant {"NUGET", "pkg:nuget"}, {"DEBIAN", "pkg:deb/debian"}, {"MAVEN", "pkg:maven"}, - {"PYTHON", "pkg:pypi"}, + {"POETRY", "pkg:pypi"}, {"CONAN", "pkg:conan"}, {"ALPINE", "pkg:apk/alpine"}, }; diff --git a/src/LCT.Common/SettingsManager.cs b/src/LCT.Common/SettingsManager.cs index 55778aad..363c7d8c 100644 --- a/src/LCT.Common/SettingsManager.cs +++ b/src/LCT.Common/SettingsManager.cs @@ -131,10 +131,13 @@ public void CheckRequiredArgsToRun(CommonAppSettings appSettings, string current "Directory.OutputFolder", "ProjectType" }; - // Check if ProjectType contains a value and add InternalRepos key accordingly + //Check if ProjectType contains a value and add InternalRepos key accordingly if (!string.IsNullOrWhiteSpace(appSettings.ProjectType)) { - identifierReqParameters.Add($"{appSettings.ProjectType}.Artifactory.InternalRepos"); + if (!appSettings.ProjectType.Equals("ALPINE", StringComparison.InvariantCultureIgnoreCase)) + { + identifierReqParameters.Add($"{appSettings.ProjectType}.Artifactory.InternalRepos"); + } } CheckForMissingParameter(appSettings, properties, identifierReqParameters); } @@ -180,15 +183,31 @@ private static void CheckForMissingParameter(CommonAppSettings appSettings, Prop break; } - property = currentObject.GetType().GetProperty(part); + property = currentObject.GetType().GetProperty(part, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); currentObject = property?.GetValue(currentObject); } - string value = currentObject?.ToString(); - - if (string.IsNullOrWhiteSpace(value)) + if (currentObject is Array array) + { + if (array.Length == 0 || string.IsNullOrWhiteSpace(array.GetValue(0)?.ToString())) + { + missingParameters.Append(key + "\n"); + } + } + else if (currentObject is IList list) { - missingParameters.Append(key + "\n"); + if (list.Count == 0 || string.IsNullOrWhiteSpace(list[0]?.ToString())) + { + missingParameters.Append(key + "\n"); + } + } + else + { + string value = currentObject?.ToString(); + if (string.IsNullOrWhiteSpace(value)) + { + missingParameters.Append(key + "\n"); + } } } diff --git a/src/LCT.Common/appSettings.json b/src/LCT.Common/appSettings.json index ac62c898..be1580b6 100644 --- a/src/LCT.Common/appSettings.json +++ b/src/LCT.Common/appSettings.json @@ -7,6 +7,7 @@ { "TimeOut": 400, "ProjectType": "", + "MultipleProjectType": false, "SW360": { "URL": "", "ProjectName": "", @@ -24,7 +25,7 @@ "Directory": { "InputFolder": "/PathToInputDirectory", //Input File path. For Docker run set as /mnt/Input "OutputFolder": "/PathToOutputDirectory", //Output Bom Folder path. For Docker run set as /mnt/Output - "BomFilePath": "//_Bom.cdx.json", //For multiple project type + "BomFilePath": "", //For multiple project type "CycloneDxSBomTemplatePath": ""//CycloneDxBomFilePath: For Providing Customer maintained SBOM as input.Can be used along with Packagefilepath or individually }, "Jfrog": { diff --git a/src/LCT.PackageIdentifier.UTest/AlpineParserTests.cs b/src/LCT.PackageIdentifier.UTest/AlpineParserTests.cs index 338cdc73..89fb3309 100644 --- a/src/LCT.PackageIdentifier.UTest/AlpineParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/AlpineParserTests.cs @@ -175,8 +175,7 @@ public void ParsePackageConfig_GivenAInputFilePathAlongWithSBOMTemplate_ReturnTo SW360 = new SW360() { IgnoreDevDependency = true }, Directory = new LCT.Common.Directory(folderAction, fileOperations) { - InputFolder = OutFolder + @"\PackageIdentifierUTTestFiles", - CycloneDxSBomTemplatePath = packagefilepath + "\\SBOMTemplates\\SBOM_AlpineCATemplate.cdx.json" + InputFolder = OutFolder + @"\PackageIdentifierUTTestFiles", } }; @@ -206,8 +205,7 @@ public void ParsePackageConfig_GivenAInputFilePathAlongWithSBOMTemplate_ReturnUp SW360 = new SW360() { IgnoreDevDependency = true }, Directory = new LCT.Common.Directory(folderAction, fileOperations) { - InputFolder = packagefilepath, - CycloneDxSBomTemplatePath = packagefilepath + "\\SBOMTemplates\\SBOMTemplate_Alpine.cdx.json" + InputFolder = packagefilepath } }; diff --git a/src/LCT.PackageIdentifier.UTest/DebianParserTests.cs b/src/LCT.PackageIdentifier.UTest/DebianParserTests.cs index 77ba5dd1..539e108e 100644 --- a/src/LCT.PackageIdentifier.UTest/DebianParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/DebianParserTests.cs @@ -259,7 +259,7 @@ public void ParsePackageConfig_GivenAInputFilePathAlongWithSBOMTemplate_ReturnTo Directory = new LCT.Common.Directory(folderAction, fileOperations) { InputFolder = packagefilepath, - CycloneDxSBomTemplatePath= packagefilepath + "\\SBOMTemplates\\SBOM_DebianCATemplate.cdx.json" + } }; @@ -290,7 +290,7 @@ public void ParsePackageConfig_GivenAInputFilePathAlongWithSBOMTemplate_ReturnUp Directory = new LCT.Common.Directory(folderAction, fileOperations) { InputFolder = packagefilepath, - CycloneDxSBomTemplatePath = packagefilepath + "\\SBOMTemplates\\SBOMTemplate_Debian.cdx.json" + } }; diff --git a/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs b/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs index 074218e1..4df4459a 100644 --- a/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/MavenParserTests.cs @@ -488,7 +488,7 @@ public void ParsePackageFile_GivenAInputFilePathAlongWithSBOMTemplate_ReturnTota Directory = new LCT.Common.Directory(folderAction, fileOperations) { InputFolder = filepath, - CycloneDxSBomTemplatePath= filepath + "\\SBOMTemplates\\SBOM_MavenCATemplate.cdx.json" + } }; @@ -523,7 +523,7 @@ public void ParsePackageFile_GivenAInputFilePathAlongWithSBOMTemplate_ReturnUpda Directory = new LCT.Common.Directory(folderAction, fileOperations) { InputFolder = filepath, - CycloneDxSBomTemplatePath = filepath + "\\SBOMTemplates\\SBOMTemplate_Maven.cdx.json" + } }; diff --git a/src/LCT.PackageIdentifier.UTest/NPMParserTests.cs b/src/LCT.PackageIdentifier.UTest/NPMParserTests.cs index 7e5b1009..82c4b2a6 100644 --- a/src/LCT.PackageIdentifier.UTest/NPMParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/NPMParserTests.cs @@ -181,7 +181,7 @@ public void ParseCycloneDXFile_GivenAInputFilePathAlongWithSBOMTemplate_ReturnTo { InputFolder = packagefilepath, OutputFolder = outFolder, - CycloneDxSBomTemplatePath = packagefilepath + "\\SBOMTemplates\\SBOM_NpmCATemplate.cdx.json" + } }; @@ -214,7 +214,7 @@ public void ParseCycloneDXFile_GivenAInputFilePathAlongWithSBOMTemplate_ReturnUp { InputFolder = packagefilepath, OutputFolder = outFolder, - CycloneDxSBomTemplatePath = packagefilepath + "\\SBOMTemplates\\SBOMTemplate_Npm.cdx.json" + } }; diff --git a/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs b/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs index 2113c22e..123d5a1f 100644 --- a/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs +++ b/src/LCT.PackageIdentifier.UTest/PythonParserTests.cs @@ -174,7 +174,7 @@ public void ParseCycloneDXFile_GivenAInputFilePathAlongWithSBOMTemplate_ReturnTo Directory = new LCT.Common.Directory(folderAction, fileOperations) { InputFolder = OutFolder + @"\PackageIdentifierUTTestFiles", - CycloneDxSBomTemplatePath = packagefilepath + "\\SBOMTemplates\\SBOM_PythonCATemplate.cdx.json" + } }; @@ -204,7 +204,7 @@ public void ParseCycloneDXFile_GivenAInputFilePathAlongWithSBOMTemplate_ReturnUp Directory = new LCT.Common.Directory(folderAction, fileOperations) { InputFolder = packagefilepath, - CycloneDxSBomTemplatePath = packagefilepath + "\\SBOMTemplates\\SBOMTemplate_Python.cdx.json" + } }; diff --git a/src/LCT.PackageIdentifier.UTest/SBomTemplateTests.cs b/src/LCT.PackageIdentifier.UTest/SBomTemplateTests.cs index 4a71de7a..07c308b3 100644 --- a/src/LCT.PackageIdentifier.UTest/SBomTemplateTests.cs +++ b/src/LCT.PackageIdentifier.UTest/SBomTemplateTests.cs @@ -139,7 +139,7 @@ public void AddComponentDetails_InputTemplateDetails_ReturnsTemplateWithDetailsu SbomTemplate.AddComponentDetails(componentsForBOM, templateDetails); //Assert - Assert.That(BomCreator.bomKpiData.ComponentsUpdatedFromSBOMTemplateFile, Is.EqualTo(3)); + Assert.That(BomCreator.bomKpiData.ComponentsUpdatedFromSBOMTemplateFile, Is.EqualTo(1)); } } } diff --git a/src/LCT.PackageIdentifier/AlpineProcesser.cs b/src/LCT.PackageIdentifier/AlpineProcesser.cs index 8e31a4df..c3afaec3 100644 --- a/src/LCT.PackageIdentifier/AlpineProcesser.cs +++ b/src/LCT.PackageIdentifier/AlpineProcesser.cs @@ -46,8 +46,19 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) foreach (string filepath in configFiles) { - Logger.Debug($"ParsePackageFile():FileName: " + filepath); - listofComponents.AddRange(ParseCycloneDX(filepath, dependenciesForBOM)); + if (filepath.EndsWith(FileConstant.SBOMTemplateFileExtension)) + { + Bom templateDetails; + templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(filepath)); + CycloneDXBomParser.CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); + //Adding Template Component Details & MetaData + SbomTemplate.AddComponentDetails(bom.Components, templateDetails); + } + else + { + Logger.Debug($"ParsePackageFile():FileName: " + filepath); + listofComponents.AddRange(ParseCycloneDX(filepath, dependenciesForBOM)); + } } int initialCount = listofComponents.Count; @@ -56,16 +67,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) BomCreator.bomKpiData.DuplicateComponents = initialCount - listComponentForBOM.Count; bom.Components = listComponentForBOM; - bom.Dependencies = dependenciesForBOM; - - if (File.Exists(appSettings.Directory.CycloneDxSBomTemplatePath) && appSettings.Directory.CycloneDxSBomTemplatePath.EndsWith(FileConstant.SBOMTemplateFileExtension)) - { - Bom templateDetails; - templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(appSettings.Directory.CycloneDxSBomTemplatePath)); - CycloneDXBomParser.CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); - //Adding Template Component Details & MetaData - SbomTemplate.AddComponentDetails(bom.Components, templateDetails); - } + bom.Dependencies = dependenciesForBOM; bom = RemoveExcludedComponents(appSettings, bom); bom.Dependencies = bom.Dependencies?.GroupBy(x => new { x.Ref }).Select(y => y.First()).ToList(); diff --git a/src/LCT.PackageIdentifier/BomCreator.cs b/src/LCT.PackageIdentifier/BomCreator.cs index 62d828a0..381fc8bf 100644 --- a/src/LCT.PackageIdentifier/BomCreator.cs +++ b/src/LCT.PackageIdentifier/BomCreator.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Net; using System.Net.Http; using System.Reflection; @@ -101,17 +102,24 @@ private static void WriteContentToCycloneDxBOM(CommonAppSettings appSettings, Bo { IFileOperations fileOperations = new FileOperations(); string bomFileName = $"{appSettings.SW360.ProjectName}_Bom.cdx.json"; - if (string.IsNullOrEmpty(appSettings.Directory.BomFilePath)) + + string outputFolderPath = appSettings.Directory.OutputFolder; + string[] files = System.IO.Directory.GetFiles(outputFolderPath); + + bool fileExists = files.Length > 0 && files.Any(file => Path.GetFileName(file).Equals(bomFileName, StringComparison.OrdinalIgnoreCase)); + + if (fileExists && appSettings.MultipleProjectType) { + string existingFilePath = files.FirstOrDefault(file => Path.GetFileName(file).Equals(bomFileName, StringComparison.OrdinalIgnoreCase)); + listOfComponentsToBom = fileOperations.CombineComponentsFromExistingBOM(listOfComponentsToBom, existingFilePath); + bomKpiData.ComponentsInComparisonBOM = listOfComponentsToBom.Components.Count; string formattedString = CommonHelper.AddSpecificValuesToBOMFormat(listOfComponentsToBom); - fileOperations.WriteContentToOutputBomFile(formattedString, appSettings.Directory.OutputFolder, FileConstant.BomFileName, appSettings.SW360.ProjectName); + fileOperations.WriteContentToOutputBomFile(formattedString, outputFolderPath, FileConstant.BomFileName, appSettings.SW360.ProjectName); } - else if(Path.GetFileName(appSettings.Directory.BomFilePath).Equals(bomFileName, StringComparison.OrdinalIgnoreCase)) + else { - listOfComponentsToBom = fileOperations.CombineComponentsFromExistingBOM(listOfComponentsToBom, appSettings.Directory.BomFilePath); - bomKpiData.ComponentsInComparisonBOM = listOfComponentsToBom.Components.Count; string formattedString = CommonHelper.AddSpecificValuesToBOMFormat(listOfComponentsToBom); - fileOperations.WriteContentToOutputBomFile(formattedString, appSettings.Directory.OutputFolder, FileConstant.BomFileName, appSettings.SW360.ProjectName); + fileOperations.WriteContentToOutputBomFile(formattedString, outputFolderPath, FileConstant.BomFileName, appSettings.SW360.ProjectName); } } @@ -137,7 +145,7 @@ private async Task CallPackageParser(CommonAppSettings appSettings) case "ALPINE": parser = new AlpineProcessor(CycloneDXBomParser); return await ComponentIdentification(appSettings, parser); - case "PYTHON": + case "POETRY": parser = new PythonProcessor(CycloneDXBomParser); return await ComponentIdentification(appSettings, parser); case "CONAN": diff --git a/src/LCT.PackageIdentifier/ConanProcessor.cs b/src/LCT.PackageIdentifier/ConanProcessor.cs index 6b54ed2f..5abd894e 100644 --- a/src/LCT.PackageIdentifier/ConanProcessor.cs +++ b/src/LCT.PackageIdentifier/ConanProcessor.cs @@ -121,6 +121,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List()) .Concat(appSettings.Conan?.Artifactory.DevRepos ?? Array.Empty()) .Concat(appSettings.Conan?.Artifactory.RemoteRepos ?? Array.Empty()) + .Concat(appSettings.Conan?.Artifactory.ThirdPartyRepos?.Select(repo => repo.Name) ?? Array.Empty()) .ToArray(); List aqlResultList = await bomhelper.GetListOfComponentsFromRepo(repoList, jFrogService); Property projectType = new() { Name = Dataconstant.Cdx_ProjectType, Value = appSettings.ProjectType }; @@ -220,13 +221,11 @@ private static void CreateFileForMultipleVersions(List componentsWith MultipleVersions multipleVersions = new MultipleVersions(); IFileOperations fileOperations = new FileOperations(); string filename = $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_{FileConstant.multipleversionsFileName}"; - if (string.IsNullOrEmpty(appSettings.Directory.BomFilePath) || (!File.Exists(filename))) + if (string.IsNullOrEmpty(appSettings.Directory.OutputFolder) || (!File.Exists(filename))) { multipleVersions.Conan = new List(); foreach (var conanPackage in componentsWithMultipleVersions) { - conanPackage.Description = !string.IsNullOrEmpty(appSettings.Directory.CycloneDxSBomTemplatePath) ? appSettings.Directory.CycloneDxSBomTemplatePath : conanPackage.Description; - MultipleVersionValues jsonComponents = new MultipleVersionValues(); jsonComponents.ComponentName = conanPackage.Name; jsonComponents.ComponentVersion = conanPackage.Version; @@ -243,8 +242,6 @@ private static void CreateFileForMultipleVersions(List componentsWith List conanComponents = new List(); foreach (var conanPackage in componentsWithMultipleVersions) { - conanPackage.Description = !string.IsNullOrEmpty(appSettings.Directory.CycloneDxSBomTemplatePath) ? appSettings.Directory.CycloneDxSBomTemplatePath : conanPackage.Description; - MultipleVersionValues jsonComponents = new MultipleVersionValues(); jsonComponents.ComponentName = conanPackage.Name; jsonComponents.ComponentVersion = conanPackage.Version; @@ -282,7 +279,15 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref Bom bom) CheckValidComponentsForProjectType(bom.Components, appSettings.ProjectType); GetDetailsforManuallyAddedComp(bom.Components); componentsForBOM.AddRange(bom.Components); - } + }else if (filepath.EndsWith(FileConstant.SBOMTemplateFileExtension)) + { + Bom templateDetails; + templateDetails = ExtractSBOMDetailsFromTemplate( + _cycloneDXBomParser.ParseCycloneDXBom(filepath)); + CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); + SbomTemplate.AddComponentDetails(bom.Components, templateDetails); + + } } int initialCount = componentsForBOM.Count; @@ -299,17 +304,7 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref Bom bom) { bom.Dependencies = dependencies; } - - if (File.Exists(appSettings.Directory.CycloneDxSBomTemplatePath) - && appSettings.Directory.CycloneDxSBomTemplatePath.EndsWith(FileConstant.SBOMTemplateFileExtension)) - { - //Adding Template Component Details - Bom templateDetails; - templateDetails = ExtractSBOMDetailsFromTemplate( - _cycloneDXBomParser.ParseCycloneDXBom(appSettings.Directory.CycloneDxSBomTemplatePath)); - CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); - SbomTemplate.AddComponentDetails(bom.Components, templateDetails); - } + bom = RemoveExcludedComponents(appSettings, bom); bom.Dependencies = bom.Dependencies?.GroupBy(x => new { x.Ref }).Select(y => y.First()).ToList(); diff --git a/src/LCT.PackageIdentifier/DebianProcessor.cs b/src/LCT.PackageIdentifier/DebianProcessor.cs index 079a7a80..bb51281b 100644 --- a/src/LCT.PackageIdentifier/DebianProcessor.cs +++ b/src/LCT.PackageIdentifier/DebianProcessor.cs @@ -51,11 +51,20 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) foreach (string filepath in configFiles) { - if (!filepath.EndsWith(FileConstant.SBOMTemplateFileExtension)) + if (filepath.EndsWith(FileConstant.SBOMTemplateFileExtension)) + { + Bom templateDetails; + templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(filepath)); + CycloneDXBomParser.CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); + //Adding Template Component Details & MetaData + SbomTemplate.AddComponentDetails(bom.Components, templateDetails); + } + else { Logger.Debug($"ParsePackageFile():FileName: " + filepath); var list = ParseCycloneDX(filepath, ref bom); listofComponents.AddRange(list); + } } @@ -65,14 +74,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) BomCreator.bomKpiData.DuplicateComponents = initialCount - listComponentForBOM.Count; bom.Components = listComponentForBOM; - if (File.Exists(appSettings.Directory.CycloneDxSBomTemplatePath) && appSettings.Directory.CycloneDxSBomTemplatePath.EndsWith(FileConstant.SBOMTemplateFileExtension)) - { - Bom templateDetails; - templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(appSettings.Directory.CycloneDxSBomTemplatePath)); - CycloneDXBomParser.CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); - //Adding Template Component Details & MetaData - SbomTemplate.AddComponentDetails(bom.Components, templateDetails); - } + bom = RemoveExcludedComponents(appSettings, bom); bom.Dependencies = bom.Dependencies?.GroupBy(x => new { x.Ref }).Select(y => y.First()).ToList(); @@ -131,6 +133,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List()) .Concat(appSettings.Debian?.Artifactory.DevRepos ?? Array.Empty()) .Concat(appSettings.Debian?.Artifactory.RemoteRepos ?? Array.Empty()) + .Concat(appSettings.Debian?.Artifactory.ThirdPartyRepos?.Select(repo => repo.Name) ?? Array.Empty()) .ToArray(); List aqlResultList = await bomhelper.GetListOfComponentsFromRepo(repoList, jFrogService); Property projectType = new() { Name = Dataconstant.Cdx_ProjectType, Value = appSettings.ProjectType }; diff --git a/src/LCT.PackageIdentifier/MavenProcessor.cs b/src/LCT.PackageIdentifier/MavenProcessor.cs index e2ec94f0..a07d4c2e 100644 --- a/src/LCT.PackageIdentifier/MavenProcessor.cs +++ b/src/LCT.PackageIdentifier/MavenProcessor.cs @@ -33,7 +33,7 @@ public MavenProcessor(ICycloneDXBomParser cycloneDXBomParser) } public Bom ParsePackageFile(CommonAppSettings appSettings) - { + { List componentsForBOM = new(); List componentsToBOM = new(); List ListOfComponents = new(); @@ -46,7 +46,14 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) foreach (string filepath in configFiles) { - if (!filepath.EndsWith(FileConstant.SBOMTemplateFileExtension)) + if (filepath.EndsWith(FileConstant.SBOMTemplateFileExtension)) + { + Bom templateDetails; + templateDetails = ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(filepath)); + CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); + SbomTemplate.AddComponentDetails(componentsForBOM, templateDetails); + } + else { Bom bomList = ParseCycloneDXBom(filepath); if (bomList?.Components != null) @@ -74,15 +81,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) } } } - - if (File.Exists(appSettings.Directory.CycloneDxSBomTemplatePath) && appSettings.Directory.CycloneDxSBomTemplatePath.EndsWith(FileConstant.SBOMTemplateFileExtension)) - { - //Adding Template Component Details - Bom templateDetails; - templateDetails = ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(appSettings.Directory.CycloneDxSBomTemplatePath)); - CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); - SbomTemplate.AddComponentDetails(componentsForBOM, templateDetails); - } + //checking Dev dependency DevDependencyIdentificationLogic(componentsForBOM, componentsToBOM, ref ListOfComponents); @@ -95,7 +94,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) componentsForBOM = ListOfComponents.Distinct(new ComponentEqualityComparer()).ToList(); BomCreator.bomKpiData.DuplicateComponents = totalComponentsIdentified - componentsForBOM.Count; - + if (appSettings.SW360.ExcludeComponents != null) { @@ -210,6 +209,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List()) .Concat(appSettings.Maven?.Artifactory.DevRepos ?? Array.Empty()) .Concat(appSettings.Maven?.Artifactory.RemoteRepos ?? Array.Empty()) + .Concat(appSettings.Maven?.Artifactory.ThirdPartyRepos?.Select(repo => repo.Name) ?? Array.Empty()) .ToArray(); List aqlResultList = await bomhelper.GetListOfComponentsFromRepo(repoList, jFrogService); Property projectType = new() { Name = Dataconstant.Cdx_ProjectType, Value = appSettings.ProjectType }; diff --git a/src/LCT.PackageIdentifier/NpmProcessor.cs b/src/LCT.PackageIdentifier/NpmProcessor.cs index f3f3e15d..0f524c3e 100644 --- a/src/LCT.PackageIdentifier/NpmProcessor.cs +++ b/src/LCT.PackageIdentifier/NpmProcessor.cs @@ -153,12 +153,11 @@ private static void CreateFileForMultipleVersions(List componentsWith MultipleVersions multipleVersions = new MultipleVersions(); IFileOperations fileOperations = new FileOperations(); string filename = $"{appSettings.Directory.OutputFolder}\\{appSettings.SW360.ProjectName}_{FileConstant.multipleversionsFileName}"; - if (string.IsNullOrEmpty(appSettings.Directory.BomFilePath) || (!File.Exists(filename))) + if (string.IsNullOrEmpty(appSettings.Directory.OutputFolder) || (!File.Exists(filename))) { multipleVersions.Npm = new List(); foreach (var npmpackage in componentsWithMultipleVersions) { - npmpackage.Description = !string.IsNullOrEmpty(appSettings.Directory.CycloneDxSBomTemplatePath) ? appSettings.Directory.CycloneDxSBomTemplatePath : npmpackage.Description; MultipleVersionValues jsonComponents = new MultipleVersionValues(); jsonComponents.ComponentName = npmpackage.Name; @@ -176,7 +175,6 @@ private static void CreateFileForMultipleVersions(List componentsWith List npmComponents = new List(); foreach (var npmpackage in componentsWithMultipleVersions) { - npmpackage.Description = !string.IsNullOrEmpty(appSettings.Directory.CycloneDxSBomTemplatePath) ? appSettings.Directory.CycloneDxSBomTemplatePath : npmpackage.Description; MultipleVersionValues jsonComponents = new MultipleVersionValues(); jsonComponents.ComponentName = npmpackage.Name; @@ -398,6 +396,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List()) .Concat(appSettings.Npm?.Artifactory.DevRepos ?? Array.Empty()) .Concat(appSettings.Npm?.Artifactory.RemoteRepos ?? Array.Empty()) + .Concat(appSettings.Npm?.Artifactory.ThirdPartyRepos?.Select(repo => repo.Name) ?? Array.Empty()) .ToArray(); List aqlResultList = await bomhelper.GetListOfComponentsFromRepo(repoList, jFrogService); Property projectType = new() { Name = Dataconstant.Cdx_ProjectType, Value = appSettings.ProjectType }; @@ -508,8 +507,16 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref List> GetJfrogRepoDetailsOfAComponent(List()) .Concat(appSettings.Nuget?.Artifactory.DevRepos ?? Array.Empty()) .Concat(appSettings.Nuget?.Artifactory.RemoteRepos ?? Array.Empty()) + .Concat(appSettings.Nuget?.Artifactory.ThirdPartyRepos?.Select(repo => repo.Name) ?? Array.Empty()) .ToArray(); List aqlResultList = await bomhelper.GetListOfComponentsFromRepo(repoList, jFrogService); Property projectType = new() { Name = Dataconstant.Cdx_ProjectType, Value = appSettings.ProjectType }; @@ -451,6 +452,16 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, if (filepath.EndsWith(FileConstant.CycloneDXFileExtension)) { if (!filepath.EndsWith(FileConstant.SBOMTemplateFileExtension)) + { + Bom templateDetails; + templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate( + _cycloneDXBomParser.ParseCycloneDXBom(filepath)); + CycloneDXBomParser.CheckValidComponentsForProjectType( + templateDetails.Components, appSettings.ProjectType); + SbomTemplate.AddComponentDetails(bom.Components, templateDetails); + + } + else { Logger.Debug($"ParsingInputFileForBOM():Found as CycloneDXFile"); bom = _cycloneDXBomParser.ParseCycloneDXBom(filepath); @@ -497,17 +508,7 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, listComponentForBOM.Count(s => s.Properties[0].Value == "true"); bom.Components = listComponentForBOM; - if (File.Exists(appSettings.Directory.CycloneDxSBomTemplatePath) - && appSettings.Directory.CycloneDxSBomTemplatePath.EndsWith(FileConstant.SBOMTemplateFileExtension)) - { - //Adding Template Component Details - Bom templateDetails; - templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate( - _cycloneDXBomParser.ParseCycloneDXBom(appSettings.Directory.CycloneDxSBomTemplatePath)); - CycloneDXBomParser.CheckValidComponentsForProjectType( - templateDetails.Components, appSettings.ProjectType); - SbomTemplate.AddComponentDetails(bom.Components, templateDetails); - } + bom = RemoveExcludedComponents(appSettings, bom); @@ -550,8 +551,6 @@ private static void CreateFileForMultipleVersions(List componentsWith multipleVersions.Nuget = new List(); foreach (var nugetPackage in componentsWithMultipleVersions) { - nugetPackage.Description = !string.IsNullOrEmpty(appSettings.Directory.CycloneDxSBomTemplatePath) ? appSettings.Directory.CycloneDxSBomTemplatePath : nugetPackage.Description; - MultipleVersionValues jsonComponents = new MultipleVersionValues(); jsonComponents.ComponentName = nugetPackage.Name; jsonComponents.ComponentVersion = nugetPackage.Version; @@ -568,8 +567,6 @@ private static void CreateFileForMultipleVersions(List componentsWith List nugetComponents = new List(); foreach (var nugetPackage in componentsWithMultipleVersions) { - nugetPackage.Description = !string.IsNullOrEmpty(appSettings.Directory.CycloneDxSBomTemplatePath) ? appSettings.Directory.CycloneDxSBomTemplatePath : nugetPackage.Description; - MultipleVersionValues jsonComponents = new MultipleVersionValues(); jsonComponents.ComponentName = nugetPackage.Name; jsonComponents.ComponentVersion = nugetPackage.Version; diff --git a/src/LCT.PackageIdentifier/Program.cs b/src/LCT.PackageIdentifier/Program.cs index ef842f03..5cee4653 100644 --- a/src/LCT.PackageIdentifier/Program.cs +++ b/src/LCT.PackageIdentifier/Program.cs @@ -83,8 +83,7 @@ static async Task Main(string[] args) $"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" + $"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" + $"PackageFilePath\t\t --> {appSettings.Directory.InputFolder}\n\t" + - $"BomFolderPath\t\t --> {appSettings.Directory.OutputFolder}\n\t" + - $"SBOMTemplateFilePath\t --> {appSettings.Directory.CycloneDxSBomTemplatePath}\n\t" + + $"BomFolderPath\t\t --> {appSettings.Directory.OutputFolder}\n\t" + $"SW360Url\t\t --> {appSettings.SW360.URL}\n\t" + $"SW360AuthTokenType\t --> {appSettings.SW360.AuthTokenType}\n\t" + $"SW360ProjectName\t --> {appSettings.SW360.ProjectName}\n\t" + diff --git a/src/LCT.PackageIdentifier/PythonProcessor.cs b/src/LCT.PackageIdentifier/PythonProcessor.cs index 87f0eda8..a11d0864 100644 --- a/src/LCT.PackageIdentifier/PythonProcessor.cs +++ b/src/LCT.PackageIdentifier/PythonProcessor.cs @@ -44,7 +44,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) Bom bom = new Bom(); List listComponentForBOM; List dependencies = new List(); - + Bom templateDetails = new Bom(); foreach (string config in configFiles) { if (config.ToLower().EndsWith("poetry.lock")) @@ -54,16 +54,12 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) else if (config.EndsWith(FileConstant.CycloneDXFileExtension) && !config.EndsWith(FileConstant.SBOMTemplateFileExtension)) { listofComponents.AddRange(ExtractDetailsFromJson(config, appSettings, ref dependencies)); + }else if (config.EndsWith(FileConstant.SBOMTemplateFileExtension)) + { + templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(config)); + CycloneDXBomParser.CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); } - } - - Bom templateDetails = new Bom(); - if (File.Exists(appSettings.Directory.CycloneDxSBomTemplatePath) - && appSettings.Directory.CycloneDxSBomTemplatePath.EndsWith(FileConstant.SBOMTemplateFileExtension)) - { - templateDetails = CycloneDXBomParser.ExtractSBOMDetailsFromTemplate(_cycloneDXBomParser.ParseCycloneDXBom(appSettings.Directory.CycloneDxSBomTemplatePath)); - CycloneDXBomParser.CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType); - } + } int initialCount = listofComponents.Count; GetDistinctComponentList(ref listofComponents); @@ -203,7 +199,7 @@ private List ExtractDetailsFromJson(string filePath, CommonAppSet PurlID = componentsInfo.Purl, }; - if (!string.IsNullOrEmpty(componentsInfo.Name) && !string.IsNullOrEmpty(componentsInfo.Version) && !string.IsNullOrEmpty(componentsInfo.Purl) && componentsInfo.Purl.Contains(Dataconstant.PurlCheck()["PYTHON"])) + if (!string.IsNullOrEmpty(componentsInfo.Name) && !string.IsNullOrEmpty(componentsInfo.Version) && !string.IsNullOrEmpty(componentsInfo.Purl) && componentsInfo.Purl.Contains(Dataconstant.PurlCheck()["POETRY"])) { BomCreator.bomKpiData.DebianComponents++; PythonPackages.Add(package); @@ -238,7 +234,7 @@ private static string GetReleaseExternalId(string name, string version) version = WebUtility.UrlEncode(version); version = version.Replace("%3A", ":"); - return $"{Dataconstant.PurlCheck()["PYTHON"]}{Dataconstant.ForwardSlash}{name}@{version}"; + return $"{Dataconstant.PurlCheck()["POETRY"]}{Dataconstant.ForwardSlash}{name}@{version}"; } private static List FormComponentReleaseExternalID(List listOfComponents) @@ -400,6 +396,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List()) .Concat(appSettings.Poetry?.Artifactory.DevRepos ?? Array.Empty()) .Concat(appSettings.Poetry?.Artifactory.RemoteRepos ?? Array.Empty()) + .Concat(appSettings.Poetry?.Artifactory.ThirdPartyRepos?.Select(repo => repo.Name) ?? Array.Empty()) .ToArray(); List aqlResultList = await bomhelper.GetListOfComponentsFromRepo(repoList, jFrogService); Property projectType = new() { Name = Dataconstant.Cdx_ProjectType, Value = appSettings.ProjectType }; diff --git a/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs b/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs index 9b95d40d..56cafb21 100644 --- a/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs +++ b/src/SW360IntegrationTest/Conan/PackageIdentifierInitialConan.cs @@ -42,7 +42,8 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, - TestConstant.ProjectType,"CONAN", + TestConstant.JfrogConanInternalRepo,"Conan.test", + TestConstant.ProjectType,"Conan", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs b/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs index 12a23580..8e592c7d 100644 --- a/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs +++ b/src/SW360IntegrationTest/Debian/PackageIdentifierInitialDebian.cs @@ -52,7 +52,8 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, - TestConstant.ProjectType,"DEBIAN", + TestConstant.JfrogDebianInternalRepo,"Debian.test", + TestConstant.ProjectType,"Debian", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs b/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs index dd23bc01..b64d712c 100644 --- a/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs +++ b/src/SW360IntegrationTest/Maven/PackageIdentifierInitialMaven.cs @@ -50,7 +50,8 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, - TestConstant.ProjectType,"MAVEN", + TestConstant.JfrogMavenInternalRepo,"Maven.test", + TestConstant.ProjectType,"Maven", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs b/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs index d632d6d6..f18820b1 100644 --- a/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs +++ b/src/SW360IntegrationTest/NPM/PackageIdentifierInitial.cs @@ -50,7 +50,8 @@ public void TestBOMCreatorexe() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, - TestConstant.ProjectType, "NPM", + TestConstant.JfrogNpmInternalRepo,"Npm.test", + TestConstant.ProjectType, "Npm", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs b/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs index 32af3cc7..bdec145d 100644 --- a/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs +++ b/src/SW360IntegrationTest/Nuget/PackageIdentifierInitialNuget.cs @@ -50,7 +50,8 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, - TestConstant.ProjectType,"NUGET", + TestConstant.JfrogNugetInternalRepo,"Nuget.test", + TestConstant.ProjectType,"Nuget", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs b/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs index 17b9d6e1..8aa5c467 100644 --- a/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs +++ b/src/SW360IntegrationTest/Python/PackageIdentifierInitialPython.cs @@ -50,7 +50,8 @@ public void RunBOMCreatorexe_ProvidedPackageJsonFilePath_ReturnsSuccess() TestConstant.SW360ProjectName, testParameters.SW360ProjectName, TestConstant.JFrogApiURL, testParameters.JfrogApi, TestConstant.ArtifactoryKey, testParameters.ArtifactoryUploadApiKey, - TestConstant.ProjectType,"PYTHON", + TestConstant.JfrogPoetryInternalRepo,"Pypi.test", + TestConstant.ProjectType,"Poetry", TestConstant.Mode,""}), "Test to run Package Identifier EXE execution"); } diff --git a/src/TestUtilities/TestConstant.cs b/src/TestUtilities/TestConstant.cs index 7f1a49da..6ed6986f 100644 --- a/src/TestUtilities/TestConstant.cs +++ b/src/TestUtilities/TestConstant.cs @@ -26,46 +26,52 @@ public static class TestConstant public const string componentNameUrl = "?name="; - public const string PackageFilePath = "--packageFilePath"; - public const string BomFolderPath = "--bomFolderPath"; - public const string Sw360Token = "--sw360Token"; - public const string BomFilePath = "--bomFilePath"; - public const string SW360URL = "--sW360URL"; - public const string FossologyURL = "--fossologyURL"; - public const string SW360AuthTokenType = "--sW360AuthTokenType"; - public const string SW360ProjectName = "--sW360ProjectName"; - public const string SW360ProjectID = "--sW360ProjectID"; - public const string ProjectType = "--projectType"; - public const string RemoveDevDependency = "--removeDevDependency"; + public const string PackageFilePath = "--Directory:InputFolder"; + public const string BomFolderPath = "--Directory:OutputFolder"; + public const string Sw360Token = "--SW360:Token"; + public const string BomFilePath = "--Directory:BomFilePath"; + public const string SW360URL = "--SW360:URL"; + public const string FossologyURL = "--Fossology:URL"; + public const string SW360AuthTokenType = "--SW360:AuthTokenType"; + public const string SW360ProjectName = "--SW360:ProjectName"; + public const string SW360ProjectID = "--SW360:ProjectID"; + public const string ProjectType = "--ProjectType"; + public const string RemoveDevDependency = "--SW360:IgnoreDevDependency"; public const string Mode = "--Mode"; public const string JFrog_API_Header = "X-JFrog-Art-Api"; public const string Email = "Email"; public const string ArtifactoryUser = "--artifactoryuploaduser"; - public const string ArtifactoryKey = "--artifactoryuploadapikey"; + public const string ArtifactoryKey = "--Jfrog:Token"; - public const string JfrogNpmThirdPartyDestRepoName = "--npm:JfrogThirdPartyDestRepoName "; - public const string JfrogNpmInternalDestRepoName = "--npm:JfrogInternalDestRepoName "; - public const string JfrogNpmDevDestRepoName = "--npm:JfrogDevDestRepoName "; + public const string JfrogNpmThirdPartyDestRepoName = "--Npm:Artifactory:ThirdPartyRepos:0:Name"; + public const string JfrogNpmInternalRepo = "--Npm:Artifactory:InternalRepos:0"; + public const string JfrogNpmInternalDestRepoName = "--Npm:ReleaseRepo "; + public const string JfrogNpmDevDestRepoName = "--Npm:DevDepRepo "; - public const string JfrogMavenThirdPartyDestRepoName = "--maven:JfrogThirdPartyDestRepoName "; - public const string JfrogMavenInternalDestRepoName = "--maven:JfrogInternalDestRepoName "; - public const string JfrogMavenDevDestRepoName = "--maven:JfrogDevDestRepoName "; + public const string JfrogMavenThirdPartyDestRepoName = "--Maven:Artifactory:ThirdPartyRepos:0:Name"; + public const string JfrogMavenInternalRepo = "--Maven:Artifactory:InternalRepos:0"; + public const string JfrogMavenInternalDestRepoName = "--Maven:ReleaseRepo "; + public const string JfrogMavenDevDestRepoName = "--Maven:DevDepRepo "; - public const string JfrogNugetThirdPartyDestRepoName = "--nuget:JfrogThirdPartyDestRepoName "; - public const string JfrogNugetInternalDestRepoName = "--nuget:JfrogInternalDestRepoName "; - public const string JfrogNugetDevDestRepoName = "--nuget:JfrogDevDestRepoName "; + public const string JfrogNugetThirdPartyDestRepoName = "--Nuget:Artifactory:ThirdPartyRepos:0:Name"; + public const string JfrogNugetInternalRepo = "--Nuget:Artifactory:InternalRepos:0"; + public const string JfrogNugetInternalDestRepoName = "--Nuget:ReleaseRepo "; + public const string JfrogNugetDevDestRepoName = "--Nuget:DevDepRepo "; - public const string JfrogPythonThirdPartyDestRepoName = "--python:JfrogThirdPartyDestRepoName "; - public const string JfrogPythonInternalDestRepoName = "--python:JfrogInternalDestRepoName "; - public const string JfrogPythonDevDestRepoName = "--python:JfrogDevDestRepoName "; + public const string JfrogPythonThirdPartyDestRepoName = "--Poetry:Artifactory:ThirdPartyRepos:0:Name"; + public const string JfrogPoetryInternalRepo = "--Poetry:Artifactory:InternalRepos:0"; + public const string JfrogPythonInternalDestRepoName = "--Poetry:ReleaseRepo "; + public const string JfrogPythonDevDestRepoName = "--Poetry:DevDepRepo "; - public const string JfrogConanThirdPartyDestRepoName = "--conan:JfrogThirdPartyDestRepoName "; - public const string JfrogConanInternalDestRepoName = "--conan:JfrogInternalDestRepoName "; - public const string JfrogConanDevDestRepoName = "--conan:JfrogDevDestRepoName "; + public const string JfrogConanThirdPartyDestRepoName = "--Conan:Artifactory:ThirdPartyRepos:0:Name"; + public const string JfrogConanInternalRepo = "--Conan:Artifactory:InternalRepos:0"; + public const string JfrogConanInternalDestRepoName = "--Conan:ReleaseRepo "; + public const string JfrogConanDevDestRepoName = "--Conan:DevDepRepo "; + public const string JfrogDebianInternalRepo = "--Debian:Artifactory:InternalRepos:0"; public const string NuspecMode = "--NuspecMode"; - public const string JFrogApiURL = "--JFrogApi"; - public const string CycloneDxSBomTemplatePath = "--cycloneDxSBomTemplatePath"; + public const string JFrogApiURL = "--JFrog:URL"; + public const string CycloneDxSBomTemplatePath = "--Directory:CycloneDxSBomTemplatePath"; public const string Release = "--release"; } } diff --git a/src/TestUtilities/TestParamConan.cs b/src/TestUtilities/TestParamConan.cs index 7bd4ed14..a81662b4 100644 --- a/src/TestUtilities/TestParamConan.cs +++ b/src/TestUtilities/TestParamConan.cs @@ -37,7 +37,7 @@ public TestParamConan() FossUrl = s_Config["FossologyURL"]; SW360ProjectName = s_Config["SW360ProjectName"]; SW360ProjectID = s_Config["SW360ProjectID"]; - ProjectType = "NUGET"; + ProjectType = "Conan"; RemoveDevDependency = s_Config["RemoveDevDependency"]; ArtifactoryUploadUser = s_Config["ArtifactoryUploadUser"]; ArtifactoryUploadApiKey = s_Config["ArtifactoryUploadApiKey"];