diff --git a/src/ArtifactoryUploader/Model/DisplayPackagesInfo.cs b/src/ArtifactoryUploader/Model/DisplayPackagesInfo.cs index 912e76f8..532813ea 100644 --- a/src/ArtifactoryUploader/Model/DisplayPackagesInfo.cs +++ b/src/ArtifactoryUploader/Model/DisplayPackagesInfo.cs @@ -4,16 +4,13 @@ // SPDX-License-Identifier: MIT // -------------------------------------------------------------------------------------------------------------------- using LCT.APICommunications.Model; -using Newtonsoft.Json; using System.Collections.Generic; namespace LCT.ArtifactoryUploader.Model { /// - /// The Model class for DisplayPackagesInfo + /// The Model class for UnkmownPackagesAll /// - - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public class DisplayPackagesInfo { public List UnknownPackagesNpm { get; set; } @@ -42,28 +39,4 @@ public class DisplayPackagesInfo public List SuccessfullPackagesMaven { get; set; } } - public class ProjectResponse - { - [JsonProperty("npm")] - public List Npm { get; set; } - [JsonProperty("nuget")] - public List Nuget { get; set; } - [JsonProperty("conan")] - public List Conan { get; set; } - [JsonProperty("python")] - public List Python { get; set; } - [JsonProperty("debian")] - public List Debian { get; set; } - [JsonProperty("maven")] - public List Maven { get; set; } - - } - - public class JsonComponents - { - [JsonProperty("name")] - public string Name { get; set; } - [JsonProperty("version")] - public string Version { get; set; } - } } diff --git a/src/ArtifactoryUploader/PackageUploadHelper.cs b/src/ArtifactoryUploader/PackageUploadHelper.cs index dc698927..eb540fc8 100644 --- a/src/ArtifactoryUploader/PackageUploadHelper.cs +++ b/src/ArtifactoryUploader/PackageUploadHelper.cs @@ -12,7 +12,6 @@ using LCT.ArtifactoryUploader.Model; using LCT.Common; using LCT.Common.Constants; -using LCT.Common.Interface; using LCT.Services; using LCT.Services.Interface; using log4net; @@ -155,12 +154,12 @@ public static DisplayPackagesInfo GetComponentsToBePackages() } - private static void DisplaySortedForeachComponents(List unknownPackages, List JfrogNotFoundPackages, List SucessfullPackages, List JfrogFoundPackages, string name, string filename) + private static void DisplaySortedForeachComponents(List unknownPackages, List JfrogNotFoundPackages, List SucessfullPackages, List JfrogFoundPackages, string name) { if (unknownPackages.Any() || JfrogNotFoundPackages.Any() || SucessfullPackages.Any() || JfrogFoundPackages.Any()) { - Logger.Info("\n" + name + ":\n"); - DisplayErrorForUnknownPackages(unknownPackages, name, filename); + Logger.Info("\n" + name + "\n"); + DisplayErrorForUnknownPackages(unknownPackages); DisplayErrorForJfrogFoundPackages(JfrogFoundPackages); DisplayErrorForJfrogPackages(JfrogNotFoundPackages); DisplayErrorForSucessfullPackages(SucessfullPackages); @@ -176,6 +175,8 @@ private static void DisplayErrorForJfrogFoundPackages(List J } } - - private static void DisplayErrorForUnknownPackages(List unknownPackages, string name, string filepath) + private static void DisplayErrorForUnknownPackages(List unknownPackages) { - ProjectResponse projectResponse = new ProjectResponse(); - IFileOperations fileOperations = new FileOperations(); - var filename = Path.Combine(filepath, $"Artifactory_{FileConstant.artifactoryReportNotApproved}"); + if (unknownPackages.Any()) { - if (name.Equals("Npm")) - { - GetNotApprovedNpmPackages(unknownPackages, projectResponse, fileOperations, filepath, filename); - } - else if (name.Equals("Nuget")) - { - GetNotApprovedNugetPackages(unknownPackages, projectResponse, fileOperations, filepath, filename); - } - else if (name.Equals("Conan")) - { - GetNotApprovedConanPackages(unknownPackages, projectResponse, fileOperations, filepath, filename); - } - else if (name.Equals("Debian")) - { - GetNotApprovedDebianPackages(unknownPackages, projectResponse, fileOperations, filepath, filename); - } - else if (name.Equals("Maven")) - { - GetNotApprovedMavenPackages(unknownPackages, projectResponse, fileOperations, filepath, filename); - } - else if (name.Equals("Python")) - { - GetNotApprovedPythonPackages(unknownPackages, projectResponse, fileOperations, filepath, filename); - } - } - } - private static void GetNotApprovedNpmPackages(List unknownPackages, ProjectResponse projectResponse, IFileOperations fileOperations, string filepath, string filename) - { - if (File.Exists(filename)) - { - string json = File.ReadAllText(filename); - ProjectResponse myDeserializedClass = JsonConvert.DeserializeObject(json); - List npmComponents = new List(); - foreach (var npmpackage in unknownPackages) + foreach (var unknownPackage in unknownPackages) { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = npmpackage.Name; - jsonComponents.Version = npmpackage.Version; - npmComponents.Add(jsonComponents); + Logger.Warn($"Package {unknownPackage.Name}-{unknownPackage.Version} is not in report approved state,hence artifactory upload will not be done!"); } myDeserializedClass.Npm = npmComponents; fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); @@ -297,179 +254,6 @@ private static void GetNotApprovedNugetPackages(List un myDeserializedClass.Nuget = nugetComponents; fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); } - else - { - projectResponse.Nuget = new List(); - foreach (var nugetpackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = nugetpackage.Name; - jsonComponents.Version = nugetpackage.Version; - projectResponse.Nuget.Add(jsonComponents); - } - fileOperations.WriteContentToReportNotApprovedFile(projectResponse, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - } - Logger.Warn($"Artifactory upload will not be done due to Report not in Approved state and package details can be found at {filename}\n"); - } - private static void GetNotApprovedConanPackages(List unknownPackages, ProjectResponse projectResponse, IFileOperations fileOperations, string filepath, string filename) - { - if (File.Exists(filename)) - { - string json = File.ReadAllText(filename); - - ProjectResponse myDeserializedClass = JsonConvert.DeserializeObject(json); - List conanComponents = new List(); - foreach (var conanpackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = conanpackage.Name; - jsonComponents.Version = conanpackage.Version; - conanComponents.Add(jsonComponents); - } - myDeserializedClass.Conan = conanComponents; - fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - - - } - else - { - projectResponse.Conan = new List(); - foreach (var conanpackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = conanpackage.Name; - jsonComponents.Version = conanpackage.Version; - projectResponse.Conan.Add(jsonComponents); - } - fileOperations.WriteContentToReportNotApprovedFile(projectResponse, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - } - Logger.Warn($"Artifactory upload will not be done due to Report not in Approved state and package details can be found at {filename}\n"); - - } - private static void GetNotApprovedPythonPackages(List unknownPackages, ProjectResponse projectResponse, IFileOperations fileOperations, string filepath, string filename) - { - if (File.Exists(filename)) - { - string json = File.ReadAllText(filename); - - ProjectResponse myDeserializedClass = JsonConvert.DeserializeObject(json); - List pythonComponents = new List(); - foreach (var pythonPackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = pythonPackage.Name; - jsonComponents.Version = pythonPackage.Version; - pythonComponents.Add(jsonComponents); - } - myDeserializedClass.Python = pythonComponents; - fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - - - } - else - { - projectResponse.Python = new List(); - foreach (var pythonPackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = pythonPackage.Name; - jsonComponents.Version = pythonPackage.Version; - projectResponse.Python.Add(jsonComponents); - } - fileOperations.WriteContentToReportNotApprovedFile(projectResponse, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - } - Logger.Warn($"Artifactory upload will not be done due to Report not in Approved state and package details can be found at {filename}\n"); - } - private static void GetNotApprovedDebianPackages(List unknownPackages, ProjectResponse projectResponse, IFileOperations fileOperations, string filepath, string filename) - { - if (File.Exists(filename)) - { - string json = File.ReadAllText(filename); - - ProjectResponse myDeserializedClass = JsonConvert.DeserializeObject(json); - List debianComponents = new List(); - foreach (var debianPackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = debianPackage.Name; - jsonComponents.Version = debianPackage.Version; - debianComponents.Add(jsonComponents); - } - myDeserializedClass.Debian = debianComponents; - fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - - - } - else - { - projectResponse.Debian = new List(); - foreach (var debianPackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = debianPackage.Name; - jsonComponents.Version = debianPackage.Version; - projectResponse.Debian.Add(jsonComponents); - } - fileOperations.WriteContentToReportNotApprovedFile(projectResponse, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - } - Logger.Warn($"Artifactory upload will not be done due to Report not in Approved state and package details can be found at {filename}\n"); - } - private static void GetNotApprovedMavenPackages(List unknownPackages, ProjectResponse projectResponse, IFileOperations fileOperations, string filepath, string filename) - { - if (File.Exists(filename)) - { - string json = File.ReadAllText(filename); - - ProjectResponse myDeserializedClass = JsonConvert.DeserializeObject(json); - List mavenComponents = new List(); - foreach (var mavenPackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = mavenPackage.Name; - jsonComponents.Version = mavenPackage.Version; - mavenComponents.Add(jsonComponents); - } - myDeserializedClass.Maven = mavenComponents; - fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - - - } - else - { - projectResponse.Maven = new List(); - foreach (var mavenPackage in unknownPackages) - { - JsonComponents jsonComponents = new JsonComponents(); - jsonComponents.Name = mavenPackage.Name; - jsonComponents.Version = mavenPackage.Version; - projectResponse.Maven.Add(jsonComponents); - } - fileOperations.WriteContentToReportNotApprovedFile(projectResponse, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory"); - } - Logger.Warn($"Artifactory upload will not be done due to Report not in Approved state and package details can be found at {filename}\n"); - } - public static string GettPathForArtifactoryUpload() - { - string localPathforartifactory = string.Empty; - try - { - String Todaysdate = DateTime.Now.ToString("dd-MM-yyyy_ss"); - localPathforartifactory = $"{Directory.GetParent(Directory.GetCurrentDirectory())}\\ClearingTool\\ArtifactoryFiles\\{Todaysdate}\\"; - if (!Directory.Exists(localPathforartifactory)) - { - localPathforartifactory = Directory.CreateDirectory(localPathforartifactory).ToString(); - } - } - catch (IOException ex) - { - Logger.Error($"GettPathForArtifactoryUpload() ", ex); - } - catch (UnauthorizedAccessException ex) - { - Logger.Error($"GettPathForArtifactoryUpload() ", ex); - } - - return localPathforartifactory; } private static void DisplayErrorForSucessfullPackages(List SucessfullPackages) { @@ -487,14 +271,12 @@ private static void DisplayErrorForSucessfullPackages(List m_ComponentsInBOM, CommonA private static void PackageSettings(Config project) { - string includeList = string.Empty; - string excludeList = string.Empty; - if (project.Include != null) - { - includeList = string.Join(",", project.Include?.ToList()); - } - if (project.Exclude != null) - { - excludeList = string.Join(",", project.Exclude?.ToList()); - } - Logger.Logger.Log(null, Level.Notice, $"\tDEVDEP_REPO_NAME:\t{project.JfrogDevDestRepoName}\n\t" + - $"THIRD_PARTY_REPO_NAME:\t{project.JfrogThirdPartyDestRepoName}\n\t" + - $"INTERNAL_REPO_NAME:\t{project.JfrogInternalDestRepoName}\n\t" + - $"Config:\n\t" + - $"Exclude:\t\t{excludeList}\n\t" + - $"Include: \t\t{includeList}\n", null); + Logger.Logger.Log(null, Level.Notice, $"\tDEVDEP_REPO_NAME:\t`{project.JfrogDevDestRepoName}`\n\t" + + $"THIRD_PARTY_REPO_NAME:\t`{project.JfrogThirdPartyDestRepoName}`\n\t" + + $"INTERNAL_REPO_NAME:\t`{project.JfrogInternalDestRepoName}`\n\t" + + $"Config:\n\t" + + $"Include: \t", null); + project.Include?.ToList().ForEach(x => Logger.Logger.Log(null, Level.Notice, $"\t\t\t\t`{x}`\t", null)); + Logger.Logger.Log(null, Level.Notice, $"\tExclude:", null); + project.Exclude?.ToList().ForEach(x => Logger.Logger.Log(null, Level.Notice, $"\t\t\t\t`{x}`\n\t", null)); } } } diff --git a/src/ArtifactoryUploader/Program.cs b/src/ArtifactoryUploader/Program.cs index 604b076e..74303ac0 100644 --- a/src/ArtifactoryUploader/Program.cs +++ b/src/ArtifactoryUploader/Program.cs @@ -65,6 +65,7 @@ static async Task Main(string[] args) $"CaToolVersion\t\t {caToolInformation.CatoolVersion}\n\t" + $"CaToolRunningPath\t {caToolInformation.CatoolRunningLocation}\n\t" + $"JFrogUrl:\t\t {appSettings.JFrogApi}\n\t" + + $"Artifactory User:\t {appSettings.ArtifactoryUploadUser}\n\t" + $"Release:\t\t {appSettings.Release}\n\t" + $"LogFolderPath:\t\t {Path.GetFullPath(FolderPath)}\n", null); diff --git a/src/LCT.APICommunications/JfrogAqlApiCommunication.cs b/src/LCT.APICommunications/JfrogAqlApiCommunication.cs index f8585ce6..adda574b 100644 --- a/src/LCT.APICommunications/JfrogAqlApiCommunication.cs +++ b/src/LCT.APICommunications/JfrogAqlApiCommunication.cs @@ -58,7 +58,7 @@ public async Task GetInternalComponentDataByRepo(string rep StringBuilder query = new(); query.Append("items.find({\"repo\":\""); query.Append($"{repoName}"); - query.Append("\"}).include(\"repo\", \"path\", \"name\", \"actual_sha1\",\"actual_md5\",\"sha256\")"); + query.Append("\"}).include(\"repo\", \"path\", \"name\")"); string aqlQueryToBody = query.ToString(); string uri = $"{DomainName}{ApiConstant.JfrogArtifactoryApiSearchAql}"; diff --git a/src/LCT.APICommunications/Model/AQL/AqlResult.cs b/src/LCT.APICommunications/Model/AQL/AqlResult.cs index 1a281969..278cd553 100644 --- a/src/LCT.APICommunications/Model/AQL/AqlResult.cs +++ b/src/LCT.APICommunications/Model/AQL/AqlResult.cs @@ -22,14 +22,5 @@ public class AqlResult [JsonProperty("name")] public string Name { get; set; } - - [JsonProperty("actual_md5")] - public string MD5 { get; set; } - - [JsonProperty("actual_sha1")] - public string SHA1 { get; set; } - - [JsonProperty("sha256")] - public string SHA256 { get; set; } } } diff --git a/src/LCT.Common/Constants/FileConstant.cs b/src/LCT.Common/Constants/FileConstant.cs index c3d80954..f3054f2c 100644 --- a/src/LCT.Common/Constants/FileConstant.cs +++ b/src/LCT.Common/Constants/FileConstant.cs @@ -51,7 +51,5 @@ public static class FileConstant public const string CycloneDXFileExtension = ".cdx.json"; public const string SBOMTemplateFileExtension = "CATemplate.cdx.json"; public const string NugetAssetFile = "project.assets.json"; - public const string multipleversionsFileName = "Multipleversions.json"; - public const string artifactoryReportNotApproved = "ReportNotApproved.json"; } } diff --git a/src/LCT.Common/CycloneDXBomParser.cs b/src/LCT.Common/CycloneDXBomParser.cs index 7aeec351..db610f6b 100644 --- a/src/LCT.Common/CycloneDXBomParser.cs +++ b/src/LCT.Common/CycloneDXBomParser.cs @@ -79,7 +79,7 @@ public static void CheckValidComponentsForProjectType(List bom, strin foreach (var component in bom.ToList()) { if (!string.IsNullOrEmpty(component.Name) && !string.IsNullOrEmpty(component.Version) - && !string.IsNullOrEmpty(component.Purl) && + && !string.IsNullOrEmpty(component.Purl) && component.Purl.Contains(Dataconstant.PurlCheck()[projectType.ToUpper()])) { //Taking Valid Components for perticular projects @@ -92,6 +92,5 @@ public static void CheckValidComponentsForProjectType(List bom, strin } } } - } } diff --git a/src/LCT.Common/ExceptionHandling.cs b/src/LCT.Common/ExceptionHandling.cs index cb5b3f00..f8c9b92e 100644 --- a/src/LCT.Common/ExceptionHandling.cs +++ b/src/LCT.Common/ExceptionHandling.cs @@ -35,11 +35,11 @@ public static void FossologyException(HttpRequestException ex) { if (500 <= Convert.ToInt32(ex.StatusCode) && Convert.ToInt32(ex.StatusCode) <= 599) { - Logger.Logger.Log(null, Level.Error, $"\tThe exception may arise because fossology is currently unresponsive:{ex.Message} Please try again later", null); + Logger.Logger.Log(null, Level.Error, $"The exception may arise because fossology is currently unresponsive:{ex.Message} Please try again later", null); } else { - Logger.Logger.Log(null, Level.Error, $"\tThe exception may be caused by an incorrect or missing token for fossology :{ex.Message} Please ensure that a valid token is provided and try again", null); + Logger.Logger.Log(null, Level.Error, $"The exception may be caused by an incorrect or missing token for fossology :{ex.Message} Please ensure that a valid token is provided and try again", null); } } diff --git a/src/LCT.Common/Interface/IFileOperations.cs b/src/LCT.Common/Interface/IFileOperations.cs index 39d00540..25516bc8 100644 --- a/src/LCT.Common/Interface/IFileOperations.cs +++ b/src/LCT.Common/Interface/IFileOperations.cs @@ -49,23 +49,5 @@ public interface IFileOperations /// comparisonBOM data /// filePath public string WriteContentToCycloneDXFile(T dataToWrite, string filePath, string fileNameWithExtension); - - /// - /// Writes the given content to the file - /// - /// Any type - /// Data to write - /// Folder path to save the file - /// File Name with Extension - public string WriteContentToReportNotApprovedFile(T dataToWrite, string folderPath, string fileNameWithExtension, string name); - - /// - /// Writes the given content to the file - /// - /// Any type - /// Data to write - /// Folder path to save the file - /// File Name with Extension - public string WriteContentToMultipleVersionsFile(T dataToWrite, string folderPath, string fileNameWithExtension, string projectName); } } diff --git a/src/LCT.Common/Model/MultipleVersionValues.cs b/src/LCT.Common/Model/MultipleVersionValues.cs deleted file mode 100644 index 437e0d1e..00000000 --- a/src/LCT.Common/Model/MultipleVersionValues.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// SPDX-FileCopyrightText: 2024 Siemens AG -// -// SPDX-License-Identifier: MIT -// -------------------------------------------------------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace LCT.Common.Model -{ - /// - /// MultipleVersionValues model - /// - [ExcludeFromCodeCoverage] - public class MultipleVersionValues - { - public string ComponentName { get; set; } - public string ComponentVersion { get; set; } - public string PackageFoundIn { get; set; } - - } - - public class MultipleVersions - { - public List Npm { get; set; } - public List Nuget { get; set; } - public List Conan { get; set; } - } -} diff --git a/src/LCT.PackageIdentifier.UTest/BomHelperUnitTests.cs b/src/LCT.PackageIdentifier.UTest/BomHelperUnitTests.cs index 31c62d48..b77e55d0 100644 --- a/src/LCT.PackageIdentifier.UTest/BomHelperUnitTests.cs +++ b/src/LCT.PackageIdentifier.UTest/BomHelperUnitTests.cs @@ -192,11 +192,8 @@ public async Task GetRepoDetails_GivenProjectTypeAsDebian_ReturnsListOFComponent new() { Path="test/test", - Name="Test-1.debian", - Repo="remote", - MD5="7654345676543", - SHA256="65434567", - SHA1="765434567654" + Name="compoenent", + Repo="remote" } }; mockIProcessor.Setup(x => x.GetJfrogArtifactoryRepoInfo(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(lstComponentForBOM); @@ -213,256 +210,7 @@ public async Task GetRepoDetails_GivenProjectTypeAsDebian_ReturnsListOFComponent //Assert Assert.AreEqual(expected.Count, lstComponentForBOM.Count); } - [TestCase] - public async Task GetRepoDetails_GivenProjectTypeAsNpm_ReturnsListOFComponents() - { - - //Arrange - var lstComponentForBOM = new List() - { - new Component() - { - Name="Test", - Version="1", - } - }; - - CommonAppSettings appSettings = new CommonAppSettings() - { - ArtifactoryUploadApiKey = "testvalue", - ProjectType = "NPM", - Debian = new Config() - { - JfrogDebianRepoList = new string[] { "here" } - }, - JFrogApi = "https://jfrogapi" - }; - List aqlResultList = new() - { - new() - { - Path="test/test", - Name="Test-1.tgz", - Repo="remote", - MD5="7654345676543", - SHA256="65434567", - SHA1="765434567654" - } - }; - mockIProcessor.Setup(x => x.GetJfrogArtifactoryRepoInfo(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(lstComponentForBOM); - Mock cycloneDXBomParser = new Mock(); - - IParser parser = new DebianProcessor(cycloneDXBomParser.Object); - Mock jFrogService = new Mock(); - Mock bomHelper = new Mock(); - bomHelper.Setup(x => x.GetListOfComponentsFromRepo(It.IsAny(), It.IsAny())).ReturnsAsync(aqlResultList); - - //Act - var expected = await parser.GetJfrogRepoDetailsOfAComponent(lstComponentForBOM, appSettings, jFrogService.Object, bomHelper.Object); - - //Assert - Assert.AreEqual(expected.Count, lstComponentForBOM.Count); - } - [TestCase] - public async Task GetRepoDetails_GivenProjectTypeAsNuget_ReturnsListOFComponents() - { - - //Arrange - var lstComponentForBOM = new List() - { - new Component() - { - Name="Test", - Version="1", - } - }; - - CommonAppSettings appSettings = new CommonAppSettings() - { - ArtifactoryUploadApiKey = "testvalue", - ProjectType = "NUGET", - Debian = new Config() - { - JfrogDebianRepoList = new string[] { "here" } - }, - JFrogApi = "https://jfrogapi" - }; - List aqlResultList = new() - { - new() - { - Path="test/test", - Name="Test.1.nupkg", - Repo="remote", - MD5="7654345676543", - SHA256="65434567", - SHA1="765434567654" - } - }; - mockIProcessor.Setup(x => x.GetJfrogArtifactoryRepoInfo(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(lstComponentForBOM); - Mock cycloneDXBomParser = new Mock(); - - IParser parser = new DebianProcessor(cycloneDXBomParser.Object); - Mock jFrogService = new Mock(); - Mock bomHelper = new Mock(); - bomHelper.Setup(x => x.GetListOfComponentsFromRepo(It.IsAny(), It.IsAny())).ReturnsAsync(aqlResultList); - - //Act - var expected = await parser.GetJfrogRepoDetailsOfAComponent(lstComponentForBOM, appSettings, jFrogService.Object, bomHelper.Object); - - //Assert - Assert.AreEqual(expected.Count, lstComponentForBOM.Count); - } - [TestCase] - public async Task GetRepoDetails_GivenProjectTypeAsPython_ReturnsListOFComponents() - { - - //Arrange - var lstComponentForBOM = new List() - { - new Component() - { - Name="Test", - Version="1", - } - }; - - CommonAppSettings appSettings = new CommonAppSettings() - { - ArtifactoryUploadApiKey = "testvalue", - ProjectType = "PYTHON", - Debian = new Config() - { - JfrogDebianRepoList = new string[] { "here" } - }, - JFrogApi = "https://jfrogapi" - }; - List aqlResultList = new() - { - new() - { - Path="test/test", - Name="Test-1.whl", - Repo="remote", - MD5="7654345676543", - SHA256="65434567", - SHA1="765434567654" - } - }; - mockIProcessor.Setup(x => x.GetJfrogArtifactoryRepoInfo(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(lstComponentForBOM); - Mock cycloneDXBomParser = new Mock(); - - IParser parser = new DebianProcessor(cycloneDXBomParser.Object); - Mock jFrogService = new Mock(); - Mock bomHelper = new Mock(); - bomHelper.Setup(x => x.GetListOfComponentsFromRepo(It.IsAny(), It.IsAny())).ReturnsAsync(aqlResultList); - - //Act - var expected = await parser.GetJfrogRepoDetailsOfAComponent(lstComponentForBOM, appSettings, jFrogService.Object, bomHelper.Object); - - //Assert - Assert.AreEqual(expected.Count, lstComponentForBOM.Count); - } - [TestCase] - public async Task GetRepoDetails_GivenProjectTypeAsConan_ReturnsListOFComponents() - { - - //Arrange - var lstComponentForBOM = new List() - { - new Component() - { - Name="Test", - Version="1", - } - }; - CommonAppSettings appSettings = new CommonAppSettings() - { - ArtifactoryUploadApiKey = "testvalue", - ProjectType = "Conan", - Debian = new Config() - { - JfrogDebianRepoList = new string[] { "here" } - }, - JFrogApi = "https://jfrogapi" - }; - List aqlResultList = new() - { - new() - { - Path="test/test", - Name="Test-1", - Repo="remote", - MD5="7654345676543", - SHA256="65434567", - SHA1="765434567654" - } - }; - mockIProcessor.Setup(x => x.GetJfrogArtifactoryRepoInfo(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(lstComponentForBOM); - Mock cycloneDXBomParser = new Mock(); - - IParser parser = new DebianProcessor(cycloneDXBomParser.Object); - Mock jFrogService = new Mock(); - Mock bomHelper = new Mock(); - bomHelper.Setup(x => x.GetListOfComponentsFromRepo(It.IsAny(), It.IsAny())).ReturnsAsync(aqlResultList); - - //Act - var expected = await parser.GetJfrogRepoDetailsOfAComponent(lstComponentForBOM, appSettings, jFrogService.Object, bomHelper.Object); - - //Assert - Assert.AreEqual(expected.Count, lstComponentForBOM.Count); - } - [TestCase] - public async Task GetRepoDetails_GivenProjectTypeAsMaven_ReturnsListOFComponents() - { - - //Arrange - var lstComponentForBOM = new List() - { - new Component() - { - Name="Test", - Version="1", - } - }; - - CommonAppSettings appSettings = new CommonAppSettings() - { - ArtifactoryUploadApiKey = "testvalue", - ProjectType = "MAVEN", - Debian = new Config() - { - JfrogDebianRepoList = new string[] { "here" } - }, - JFrogApi = "https://jfrogapi" - }; - List aqlResultList = new() - { - new() - { - Path="test/test", - Name="Test-1-sources.jar", - Repo="remote", - MD5="7654345676543", - SHA256="65434567", - SHA1="765434567654" - } - }; - mockIProcessor.Setup(x => x.GetJfrogArtifactoryRepoInfo(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync(lstComponentForBOM); - Mock cycloneDXBomParser = new Mock(); - - IParser parser = new DebianProcessor(cycloneDXBomParser.Object); - Mock jFrogService = new Mock(); - Mock bomHelper = new Mock(); - bomHelper.Setup(x => x.GetListOfComponentsFromRepo(It.IsAny(), It.IsAny())).ReturnsAsync(aqlResultList); - - //Act - var expected = await parser.GetJfrogRepoDetailsOfAComponent(lstComponentForBOM, appSettings, jFrogService.Object, bomHelper.Object); - - //Assert - Assert.AreEqual(expected.Count, lstComponentForBOM.Count); - } [TestCase] public void Test_WriteBomKpiDataToConsole() diff --git a/src/LCT.PackageIdentifier.UTest/BomValidatorUnitTests.cs b/src/LCT.PackageIdentifier.UTest/BomValidatorUnitTests.cs index 5ac8cf34..da6c7d0b 100644 --- a/src/LCT.PackageIdentifier.UTest/BomValidatorUnitTests.cs +++ b/src/LCT.PackageIdentifier.UTest/BomValidatorUnitTests.cs @@ -13,7 +13,6 @@ using System.IO; using System.Threading.Tasks; using LCT.Common; -using LCT.APICommunications.Model; namespace PackageIdentifier.UTest { @@ -29,12 +28,11 @@ public async Task ValidateAppSettings_ProvidedProjectID_ReturnsProjectName() { //Arrange string projectName = "Test"; - ProjectReleases projectReleases = new ProjectReleases(); var CommonAppSettings = new CommonAppSettings(mockIFolderAction.Object) { SW360ProjectName = "Test" }; - mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny(), projectReleases)) + mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny())) .ReturnsAsync(projectName); mockIFileOperations.Setup(x => x.ValidateFilePath(It.IsAny())) @@ -47,10 +45,10 @@ public async Task ValidateAppSettings_ProvidedProjectID_ReturnsProjectName() CommonAppSettings.PackageFilePath = ""; //Act - await BomValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object, projectReleases); + await BomValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object); //Assert - mockISw360ProjectService.Verify(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny(), projectReleases), Times.AtLeastOnce); + mockISw360ProjectService.Verify(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny()), Times.AtLeastOnce); } [TestCase] @@ -58,12 +56,11 @@ public Task ValidateAppSettings_ProvidedProjectID_ReturnsInvalidDataException() { //Arrange string projectName = null; - ProjectReleases projectReleases = new ProjectReleases(); var CommonAppSettings = new CommonAppSettings(mockIFolderAction.Object) { SW360ProjectName = "Test" }; - mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny(),projectReleases)) + mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny())) .ReturnsAsync(projectName); mockIFileOperations.Setup(x => x.ValidateFilePath(It.IsAny())) @@ -75,7 +72,7 @@ public Task ValidateAppSettings_ProvidedProjectID_ReturnsInvalidDataException() .Verifiable(); //Act && Assert - Assert.ThrowsAsync(async () => await BomValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object, projectReleases)); + Assert.ThrowsAsync(async () => await BomValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object)); return Task.CompletedTask; } } diff --git a/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs b/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs index 5c6455ab..c39f803b 100644 --- a/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs +++ b/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs @@ -5,16 +5,12 @@ // -------------------------------------------------------------------------------------------------------------------- using CycloneDX.Models; -using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Constants; -using LCT.Common.Model; using LCT.PackageIdentifier; -using NuGet.ContentModel; using NUnit.Framework; using System.Collections.Generic; using System.IO; -using System.Security.Cryptography; namespace PackageIdentifier.UTest { @@ -25,7 +21,6 @@ public class CycloneBomProcessorTests public void SetMetadataInComparisonBOM_GivenBOMWithEmptyMetadata_FillsInMetadataInfoInBOM() { //Arrange - ProjectReleases projectReleases = new ProjectReleases(); Bom bom = new Bom() { Metadata = null, @@ -44,24 +39,20 @@ public void SetMetadataInComparisonBOM_GivenBOMWithEmptyMetadata_FillsInMetadata Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation); //Assert - Assert.That(2, Is.EqualTo(files.Metadata.Tools.Count), "Returns bom with metadata "); + Assert.That(1, Is.EqualTo(files.Metadata.Tools.Count), "Returns bom with metadata "); } [Test] public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoInBOM() { //Arrange - ProjectReleases projectReleases = new ProjectReleases(); - projectReleases.Version= "1.0"; - Bom bom = new Bom() { Metadata = new Metadata() { - Tools = new List() { - new Tool() { - Name = "Existing Data", Version = "1.0.", Vendor = "AG" } }, - Component = new Component() + Tools = new List(){ + new Tool(){ + Name = "Existing Data",Version = "1.0.",Vendor = "AG"} } }, Components = new List() { @@ -71,8 +62,7 @@ public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoI }; CommonAppSettings appSettings = new CommonAppSettings() { - CaVersion = "1.2.3", - SW360ProjectName = "Test", + CaVersion = "1.2.3" }; Tool tools = new Tool() diff --git a/src/LCT.PackageIdentifier/AlpineProcesser.cs b/src/LCT.PackageIdentifier/AlpineProcesser.cs index f284432f..55b38913 100644 --- a/src/LCT.PackageIdentifier/AlpineProcesser.cs +++ b/src/LCT.PackageIdentifier/AlpineProcesser.cs @@ -23,10 +23,11 @@ namespace LCT.PackageIdentifier /// /// The AlpineProcessor class /// - public class AlpineProcessor : IParser + public class AlpineProcessor : IParser { static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly ICycloneDXBomParser _cycloneDXBomParser; + public AlpineProcessor(ICycloneDXBomParser cycloneDXBomParser) { _cycloneDXBomParser = cycloneDXBomParser; @@ -57,7 +58,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) bom.Components = listComponentForBOM; bom.Dependencies = dependenciesForBOM; - + if (File.Exists(appSettings.CycloneDxSBomTemplatePath) && appSettings.CycloneDxSBomTemplatePath.EndsWith(FileConstant.SBOMTemplateFileExtension)) { Bom templateDetails; diff --git a/src/LCT.PackageIdentifier/BomCreator.cs b/src/LCT.PackageIdentifier/BomCreator.cs index a2a0666a..cd39c86a 100644 --- a/src/LCT.PackageIdentifier/BomCreator.cs +++ b/src/LCT.PackageIdentifier/BomCreator.cs @@ -5,7 +5,6 @@ // -------------------------------------------------------------------------------------------------------------------- using CycloneDX.Models; -using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Constants; using LCT.Common.Interface; @@ -57,7 +56,6 @@ public async Task GenerateBom(CommonAppSettings appSettings, $"= {listOfComponentsToBom.Components.Count}", null); bomKpiData.ComponentsInComparisonBOM = listOfComponentsToBom.Components.Count; - //Get project details for metadata properties //sets metadata properties listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, diff --git a/src/LCT.PackageIdentifier/BomValidator.cs b/src/LCT.PackageIdentifier/BomValidator.cs index b48cc7aa..6299711c 100644 --- a/src/LCT.PackageIdentifier/BomValidator.cs +++ b/src/LCT.PackageIdentifier/BomValidator.cs @@ -4,7 +4,6 @@ // SPDX-License-Identifier: MIT // -------------------------------------------------------------------------------------------------------------------- -using LCT.APICommunications.Model; using LCT.Common; using LCT.Services.Interface; using System; @@ -23,7 +22,7 @@ public static class BomValidator static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static async Task ValidateAppSettings(CommonAppSettings appSettings, ISw360ProjectService bomService, ProjectReleases projectReleases) { - string sw360ProjectName = await bomService.GetProjectNameByProjectIDFromSW360(appSettings.SW360ProjectID, appSettings.SW360ProjectName,projectReleases); + string sw360ProjectName = await bomService.GetProjectNameByProjectIDFromSW360(appSettings.SW360ProjectID, appSettings.SW360ProjectName); if (string.IsNullOrEmpty(sw360ProjectName)) { diff --git a/src/LCT.PackageIdentifier/ConanProcessor.cs b/src/LCT.PackageIdentifier/ConanProcessor.cs index 9bade284..6d4cd46f 100644 --- a/src/LCT.PackageIdentifier/ConanProcessor.cs +++ b/src/LCT.PackageIdentifier/ConanProcessor.cs @@ -9,8 +9,6 @@ using LCT.APICommunications.Model.AQL; using LCT.Common; using LCT.Common.Constants; -using LCT.Common.Interface; -using LCT.Common.Model; using LCT.PackageIdentifier.Interface; using LCT.PackageIdentifier.Model; using LCT.Services.Interface; @@ -62,7 +60,11 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) if (componentsWithMultipleVersions.Count != 0) { - CreateFileForMultipleVersions(componentsWithMultipleVersions, appSettings); + Logger.Warn($"Multiple versions detected :\n"); + foreach (var item in componentsWithMultipleVersions) + { + Logger.Warn($"Component Name : {item.Name}\nComponent Version : {item.Version}\nPackage Found in : {item.Description}\n"); + } } bom.Components = componentsForBOM; @@ -147,24 +149,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List() { - new() - { - Alg = Hash.HashAlgorithm.MD5, - Content = hashes.MD5 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_1, - Content = hashes.SHA1 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_256, - Content = hashes.SHA256 - } - }; - - } modifiedBOM.Add(componentVal); } @@ -186,50 +170,6 @@ public static bool IsDevDependency(ConanPackage component, List buildNod #endregion #region private methods - - private static void CreateFileForMultipleVersions(List componentsWithMultipleVersions, CommonAppSettings appSettings) - { - MultipleVersions multipleVersions = new MultipleVersions(); - IFileOperations fileOperations = new FileOperations(); - string filename = $"{appSettings.BomFolderPath}\\{appSettings.SW360ProjectName}_{FileConstant.multipleversionsFileName}"; - if (string.IsNullOrEmpty(appSettings.IdentifierBomFilePath) || (!File.Exists(filename))) - { - multipleVersions.Conan = new List(); - foreach (var conanPackage in componentsWithMultipleVersions) - { - conanPackage.Description = !string.IsNullOrEmpty(appSettings.CycloneDxSBomTemplatePath) ? appSettings.CycloneDxSBomTemplatePath : conanPackage.Description; - - MultipleVersionValues jsonComponents = new MultipleVersionValues(); - jsonComponents.ComponentName = conanPackage.Name; - jsonComponents.ComponentVersion = conanPackage.Version; - jsonComponents.PackageFoundIn = conanPackage.Description; - multipleVersions.Conan.Add(jsonComponents); - } - fileOperations.WriteContentToMultipleVersionsFile(multipleVersions, appSettings.BomFolderPath, FileConstant.multipleversionsFileName, appSettings.SW360ProjectName); - Logger.Warn($"\nTotal Multiple versions detected {multipleVersions.Conan.Count} and details can be found at {appSettings.BomFolderPath}\\{appSettings.SW360ProjectName}_{FileConstant.multipleversionsFileName}\n"); - } - else - { - string json = File.ReadAllText(filename); - MultipleVersions myDeserializedClass = JsonConvert.DeserializeObject(json); - List conanComponents = new List(); - foreach (var conanPackage in componentsWithMultipleVersions) - { - conanPackage.Description = !string.IsNullOrEmpty(appSettings.CycloneDxSBomTemplatePath) ? appSettings.CycloneDxSBomTemplatePath : conanPackage.Description; - - MultipleVersionValues jsonComponents = new MultipleVersionValues(); - jsonComponents.ComponentName = conanPackage.Name; - jsonComponents.ComponentVersion = conanPackage.Version; - jsonComponents.PackageFoundIn = conanPackage.Description; - - conanComponents.Add(jsonComponents); - } - myDeserializedClass.Conan = conanComponents; - - fileOperations.WriteContentToMultipleVersionsFile(myDeserializedClass, appSettings.BomFolderPath, FileConstant.multipleversionsFileName, appSettings.SW360ProjectName); - Logger.Warn($"\nTotal Multiple versions detected {conanComponents.Count} and details can be found at {appSettings.BomFolderPath}\\{appSettings.SW360ProjectName}_{FileConstant.multipleversionsFileName}\n"); - } - } private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref Bom bom) { List configFiles; diff --git a/src/LCT.PackageIdentifier/CycloneBomProcessor.cs b/src/LCT.PackageIdentifier/CycloneBomProcessor.cs index 16651214..1480bb53 100644 --- a/src/LCT.PackageIdentifier/CycloneBomProcessor.cs +++ b/src/LCT.PackageIdentifier/CycloneBomProcessor.cs @@ -5,7 +5,6 @@ // -------------------------------------------------------------------------------------------------------------------- using CycloneDX.Models; -using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Constants; using LCT.Common.Model; diff --git a/src/LCT.PackageIdentifier/DebianProcessor.cs b/src/LCT.PackageIdentifier/DebianProcessor.cs index 8a04641b..24c35aec 100644 --- a/src/LCT.PackageIdentifier/DebianProcessor.cs +++ b/src/LCT.PackageIdentifier/DebianProcessor.cs @@ -5,7 +5,6 @@ // -------------------------------------------------------------------------------------------------------------------- using CycloneDX.Models; -using LCT.APICommunications; using LCT.APICommunications.Model.AQL; using LCT.Common; using LCT.Common.Constants; @@ -19,7 +18,6 @@ using System.Linq; using System.Net; using System.Reflection; -using System.Security.Cryptography; using System.Threading.Tasks; namespace LCT.PackageIdentifier @@ -136,8 +134,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName); Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoName, Value = repoName }; Property jfrogFileNameProperty = new() { Name = Dataconstant.Cdx_Siemensfilename, Value = jfrogRepoPackageName }; Property jfrogRepoPathProperty = new() { Name = Dataconstant.Cdx_JfrogRepoPath, Value = jfrogRepoPath }; @@ -152,29 +148,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List() - { - new() - { - Alg = Hash.HashAlgorithm.MD5, - Content = hashes.MD5 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_1, - Content = hashes.SHA1 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_256, - Content = hashes.SHA256 - } - }; - - } modifiedBOM.Add(componentVal); } diff --git a/src/LCT.PackageIdentifier/Interface/IBomCreator.cs b/src/LCT.PackageIdentifier/Interface/IBomCreator.cs index 4b1e02a8..f6901163 100644 --- a/src/LCT.PackageIdentifier/Interface/IBomCreator.cs +++ b/src/LCT.PackageIdentifier/Interface/IBomCreator.cs @@ -4,7 +4,6 @@ // SPDX-License-Identifier: MIT // -------------------------------------------------------------------------------------------------------------------- -using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Interface; using LCT.Common.Model; diff --git a/src/LCT.PackageIdentifier/MavenProcessor.cs b/src/LCT.PackageIdentifier/MavenProcessor.cs index 3f840b93..4e883e65 100644 --- a/src/LCT.PackageIdentifier/MavenProcessor.cs +++ b/src/LCT.PackageIdentifier/MavenProcessor.cs @@ -4,7 +4,6 @@ // -------------------------------------------------------------------------------------------------------------------- using CycloneDX.Models; -using LCT.APICommunications; using LCT.APICommunications.Model.AQL; using LCT.Common; using LCT.Common.Constants; @@ -59,6 +58,16 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) continue; } + if (bomList?.Components != null) + { + CheckValidComponentsForProjectType(bomList.Components, appSettings.ProjectType); + } + else + { + Logger.Warn("No components found in the BOM file : " + filepath); + continue; + } + if (componentsForBOM.Count == 0) { componentsForBOM.AddRange(bomList.Components); @@ -213,8 +222,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName); string jfrogRepoPath = string.Empty; string jfrogcomponentName = $"{component.Name}-{component.Version}.jar"; @@ -233,29 +240,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List() - { - new() - { - Alg = Hash.HashAlgorithm.MD5, - Content = hashes.MD5 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_1, - Content = hashes.SHA1 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_256, - Content = hashes.SHA256 - } - }; - - } modifiedBOM.Add(componentVal); } diff --git a/src/LCT.PackageIdentifier/NpmProcessor.cs b/src/LCT.PackageIdentifier/NpmProcessor.cs index 4d9ef296..6a0966c9 100644 --- a/src/LCT.PackageIdentifier/NpmProcessor.cs +++ b/src/LCT.PackageIdentifier/NpmProcessor.cs @@ -9,8 +9,6 @@ using LCT.APICommunications.Model.AQL; using LCT.Common; using LCT.Common.Constants; -using LCT.Common.Interface; -using LCT.Common.Model; using LCT.PackageIdentifier.Interface; using LCT.PackageIdentifier.Model; using LCT.Services.Interface; @@ -41,6 +39,7 @@ public class NpmProcessor : CycloneDXBomParser, IParser private const string Version = "version"; private const string NotFoundInRepo = "Not Found in JFrogRepo"; private const string Requires = "requires"; + public NpmProcessor(ICycloneDXBomParser cycloneDXBomParser) { _cycloneDXBomParser = cycloneDXBomParser; @@ -63,9 +62,12 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) if (componentsWithMultipleVersions.Count != 0) { - CreateFileForMultipleVersions(componentsWithMultipleVersions, appSettings); + Logger.Warn($"Multiple versions detected :\n"); + foreach (var item in componentsWithMultipleVersions) + { + Logger.Warn($"Component Name : {item.Name}\nComponent Version : {item.Version}\nPackage Found in : {item.Description}\n"); + } } - bom.Components = componentsForBOM; bom.Dependencies = dependencies; bom.Dependencies = bom.Dependencies?.GroupBy(x => new { x.Ref }).Select(y => y.First()).ToList(); @@ -73,8 +75,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) return bom; } - - public List ParsePackageLockJson(string filepath, CommonAppSettings appSettings) + public static List ParsePackageLockJson(string filepath, CommonAppSettings appSettings) { List bundledComponents = new List(); List lstComponentForBOM = new List(); @@ -402,8 +403,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName); string jfrogRepoPath = string.Empty; AqlResult finalRepoData = GetJfrogArtifactoryRepoDetials(aqlResultList, component, bomhelper, out jfrogRepoPath); @@ -426,24 +425,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List() { - new() - { - Alg = Hash.HashAlgorithm.MD5, - Content = hashes.MD5 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_1, - Content = hashes.SHA1 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_256, - Content = hashes.SHA256 - } - }; - - } modifiedBOM.Add(componentVal); } diff --git a/src/LCT.PackageIdentifier/NugetProcessor.cs b/src/LCT.PackageIdentifier/NugetProcessor.cs index 20686163..1637f150 100644 --- a/src/LCT.PackageIdentifier/NugetProcessor.cs +++ b/src/LCT.PackageIdentifier/NugetProcessor.cs @@ -9,14 +9,11 @@ using LCT.APICommunications.Model.AQL; using LCT.Common; using LCT.Common.Constants; -using LCT.Common.Interface; -using LCT.Common.Model; using LCT.PackageIdentifier.Interface; using LCT.PackageIdentifier.Model; using LCT.PackageIdentifier.Model.NugetModel; using LCT.Services.Interface; using log4net; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; @@ -30,7 +27,7 @@ namespace LCT.PackageIdentifier { - public class NugetProcessor : CycloneDXBomParser, IParser + public class NugetProcessor : IParser { static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private const string NotFoundInRepo = "Not Found in JFrogRepo"; @@ -46,7 +43,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings) { Logger.Debug($"ParsePackageFile():Start"); List listComponentForBOM = new List(); - Bom bom = new Bom(); + Bom bom = new Bom(); ParsingInputFileForBOM(appSettings, ref listComponentForBOM, ref bom); var componentsWithMultipleVersions = bom.Components.GroupBy(s => s.Name).Where(g => g.Count() > 1).SelectMany(g => g).ToList(); @@ -247,23 +244,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List() { - new() - { - Alg = Hash.HashAlgorithm.MD5, - Content = hashes.MD5 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_1, - Content = hashes.SHA1 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_256, - Content = hashes.SHA256 - } - }; - } modifiedBOM.Add(componentVal); } return modifiedBOM; @@ -452,7 +432,7 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, } BomCreator.bomKpiData.ComponentsinPackageLockJsonFile = listComponentForBOM.Count; - totalComponentsIdentified = listComponentForBOM.Count; + totalComponentsIdentified = listComponentForBOM.Count; listComponentForBOM = KeepUniqueNonDevComponents(listComponentForBOM); listComponentForBOM = listComponentForBOM.Distinct( new ComponentEqualityComparer()).ToList(); @@ -478,8 +458,8 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, templateDetails.Components, appSettings.ProjectType); SbomTemplate.AddComponentDetails(bom.Components, templateDetails); } - - bom = RemoveExcludedComponents(appSettings, bom); + + bom = RemoveExcludedComponents(appSettings, bom); if (bom != null) { @@ -649,7 +629,7 @@ private static void ParseInputFiles(CommonAppSettings appSettings, string filepa } else { - Logger.Warn($"Input file NOT_FOUND :{filepath}"); + Logger.Warn("No Proper input files found for Nuget package types."); } } @@ -659,7 +639,12 @@ private static void CheckForMultipleVersions(CommonAppSettings appSettings, List if (componentsWithMultipleVersions.Count != 0) { - CreateFileForMultipleVersions(componentsWithMultipleVersions, appSettings); + Logger.Warn($"Multiple versions detected :\n"); + foreach (var item in componentsWithMultipleVersions) + { + item.Description = !string.IsNullOrEmpty(appSettings.CycloneDxSBomTemplatePath) ? appSettings.CycloneDxSBomTemplatePath : item.Description; + Logger.Warn($"Component Name : {item.Name}\nComponent Version : {item.Version}\nPackage Found in : {item.Description}\n"); + } } } diff --git a/src/LCT.PackageIdentifier/Program.cs b/src/LCT.PackageIdentifier/Program.cs index f980c3c7..d81bc49e 100644 --- a/src/LCT.PackageIdentifier/Program.cs +++ b/src/LCT.PackageIdentifier/Program.cs @@ -52,7 +52,7 @@ static async Task Main(string[] args) m_Verbose = true; ISettingsManager settingsManager = new SettingsManager(); CommonAppSettings appSettings = settingsManager.ReadConfiguration(args, FileConstant.appSettingFileName); - ProjectReleases projectReleases = new ProjectReleases(); + // do not change the order of getting ca tool information CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile(); Log4Net.CatoolCurrentDirectory = Directory.GetParent(caToolInformation.CatoolRunningLocation).FullName; @@ -99,7 +99,6 @@ static async Task Main(string[] args) $"Exclude\t\t\t --> {listOfExclude}\n\t" + $"ExcludeComponents\t --> {listOfExcludeComponents}\n", null); - if (appSettings.IsTestMode) Logger.Logger.Log(null, Level.Notice, $"\tMode\t\t\t --> {appSettings.Mode}\n", null); @@ -144,7 +143,7 @@ private static IJFrogService GetJfrogService(CommonAppSettings appSettings) return jFrogService; } - private static async Task ValidateAppsettingsFile(CommonAppSettings appSettings, ProjectReleases projectReleases) + private static async Task ValidateAppsettingsFile(CommonAppSettings appSettings) { SW360ConnectionSettings sw360ConnectionSettings = new SW360ConnectionSettings() { @@ -157,34 +156,6 @@ private static async Task ValidateAppsettingsFile(CommonAppSettings appSettings, ISw360ProjectService sw360ProjectService = new Sw360ProjectService(new SW360ApicommunicationFacade(sw360ConnectionSettings)); await BomValidator.ValidateAppSettings(appSettings, sw360ProjectService, projectReleases); } - private static string DisplayInclude(CommonAppSettings appSettings) - { - string totalString = string.Empty; - switch (appSettings.ProjectType.ToUpperInvariant()) - { - case "NPM": - if (appSettings.Npm.Include != null) - { - totalString = string.Join(",", appSettings.Npm.Include?.ToList()); - } - return totalString; - case "NUGET": - if (appSettings.Nuget.Include != null) - { - totalString = string.Join(",", appSettings.Nuget.Include?.ToList()); - } - return totalString; - case "MAVEN": - if (appSettings.Maven.Include != null) - { - totalString = string.Join(",", appSettings.Maven.Include?.ToList()); - } - return totalString; - case "DEBIAN": - if (appSettings.Debian.Include != null) - { - totalString = string.Join(",", appSettings.Debian.Include?.ToList()); - } return totalString; case "PYTHON": diff --git a/src/LCT.PackageIdentifier/PythonProcessor.cs b/src/LCT.PackageIdentifier/PythonProcessor.cs index 851c4160..b69d4106 100644 --- a/src/LCT.PackageIdentifier/PythonProcessor.cs +++ b/src/LCT.PackageIdentifier/PythonProcessor.cs @@ -421,29 +421,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List() - { - new() - { - Alg = Hash.HashAlgorithm.MD5, - Content = hashes.MD5 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_1, - Content = hashes.SHA1 - }, - new() - { - Alg = Hash.HashAlgorithm.SHA_256, - Content = hashes.SHA256 - } - }; - - } modifiedBOM.Add(componentVal); } return modifiedBOM; diff --git a/src/LCT.PackageIdentifier/Scanner.cs b/src/LCT.PackageIdentifier/Scanner.cs index 44dfca12..d3f20372 100644 --- a/src/LCT.PackageIdentifier/Scanner.cs +++ b/src/LCT.PackageIdentifier/Scanner.cs @@ -49,7 +49,7 @@ public static List FileScanner(string rootPath, Config config) $" - {rootPath}"); } - Logger.Logger.Log(null, Level.Notice, $"Directory Location: Packages are read from the below locations:", null); + Logger.Logger.Log(null, Level.Notice, $"\n \n Directory Location: Packages are read from the below locations: \n", null); foreach (string includePattern in config.Include) { foundConfigFiles = Directory.GetFiles(rootPath, includePattern, SearchOption.AllDirectories); @@ -65,11 +65,11 @@ public static List FileScanner(string rootPath, Config config) if (allFoundConfigFiles.Count == 0) { - Logger.Error(" Provided package file path do not contain valid input files."); + Logger.Error("Provided package file path do not contain valid input files."); CommonHelper.CallEnvironmentExit(-1); } - + Logger.Logger.Log(null, Level.Notice, $"\n----------------------------------------------------", null); return allFoundConfigFiles; } @@ -78,7 +78,8 @@ private static void CheckingForExcludedFiles(Config config, IFileOperations file { if (!IsExcluded(configFile, config.Exclude)) { - Logger.Logger.Log(null, Level.Info, $" Input file FOUND :{configFile}", null); + string currentDirectory = Path.GetDirectoryName(configFile); + Logger.Logger.Log(null, Level.Info, $" {currentDirectory} \n", null); allFoundConfigFiles.Add(configFile); fileOperations.ValidateFilePath(configFile); diff --git a/src/LCT.SW360PackageCreator.UTest/CreatorValidatorTest.cs b/src/LCT.SW360PackageCreator.UTest/CreatorValidatorTest.cs index d4910e8a..e00e73a1 100644 --- a/src/LCT.SW360PackageCreator.UTest/CreatorValidatorTest.cs +++ b/src/LCT.SW360PackageCreator.UTest/CreatorValidatorTest.cs @@ -12,7 +12,6 @@ using System.IO; using LCT.Common; using System.Threading.Tasks; -using LCT.APICommunications.Model; namespace SW360ComponentCreator.UTest { @@ -30,17 +29,16 @@ public async Task ValidateAppSettings_TestPositive() { //Arrange string projectName = "Test"; - ProjectReleases projectReleases=new ProjectReleases(); var CommonAppSettings = new CommonAppSettings(); CommonAppSettings.SW360ProjectName = "Test"; - mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny(), projectReleases)) + mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny())) .ReturnsAsync(projectName); //Act - await CreatorValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object,projectReleases); + await CreatorValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object); //Assert - mockISw360ProjectService.Verify(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny(), projectReleases), Times.AtLeastOnce); + mockISw360ProjectService.Verify(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny()), Times.AtLeastOnce); } [TestCase] @@ -48,15 +46,14 @@ public void ValidateAppSettings_TestNegative() { //Arrange string projectName = null; - ProjectReleases projectReleases = new ProjectReleases(); var CommonAppSettings = new CommonAppSettings(); - mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny(),projectReleases)) + mockISw360ProjectService.Setup(x => x.GetProjectNameByProjectIDFromSW360(It.IsAny(), It.IsAny())) .ReturnsAsync(projectName); //Act //Assert - Assert.ThrowsAsync(() => CreatorValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object, projectReleases)); + Assert.ThrowsAsync(() => CreatorValidator.ValidateAppSettings(CommonAppSettings, mockISw360ProjectService.Object)); } diff --git a/src/LCT.SW360PackageCreator/ComponentCreator.cs b/src/LCT.SW360PackageCreator/ComponentCreator.cs index 091c450a..2e079805 100644 --- a/src/LCT.SW360PackageCreator/ComponentCreator.cs +++ b/src/LCT.SW360PackageCreator/ComponentCreator.cs @@ -508,7 +508,7 @@ private async Task ComponentAndReleaseAvailable(ComparisonBomData item, { if (item.ComponentStatus == Dataconstant.Available && item.ReleaseStatus == Dataconstant.Available) { - Logger.Logger.Log(null, Level.Notice, $"Release exists in SW360 : Name - {item.Name} , version - {item.Version}", null); + Logger.Logger.Log(null, Level.Notice, $"Release exists : Name - {item.Name} , version - {item.Version}", null); string releaseLink = item.ReleaseLink ?? string.Empty; string releaseId = CommonHelper.GetSubstringOfLastOccurance(releaseLink, "/"); if (!string.IsNullOrWhiteSpace(releaseId)) diff --git a/src/LCT.SW360PackageCreator/CreatorValidator.cs b/src/LCT.SW360PackageCreator/CreatorValidator.cs index b2a68028..35795419 100644 --- a/src/LCT.SW360PackageCreator/CreatorValidator.cs +++ b/src/LCT.SW360PackageCreator/CreatorValidator.cs @@ -8,7 +8,6 @@ using System.IO; using System.Threading.Tasks; using LCT.Common; -using LCT.APICommunications.Model; using log4net; using System.Reflection; @@ -23,7 +22,7 @@ public static class CreatorValidator static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static async Task ValidateAppSettings(CommonAppSettings appSettings, ISw360ProjectService sw360ProjectService, ProjectReleases projectReleases) { - string sw360ProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360(appSettings.SW360ProjectID, appSettings.SW360ProjectName,projectReleases); + string sw360ProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360(appSettings.SW360ProjectID, appSettings.SW360ProjectName); if (string.IsNullOrEmpty(sw360ProjectName)) { diff --git a/src/LCT.SW360PackageCreator/Program.cs b/src/LCT.SW360PackageCreator/Program.cs index 9df180b9..340f2f41 100644 --- a/src/LCT.SW360PackageCreator/Program.cs +++ b/src/LCT.SW360PackageCreator/Program.cs @@ -4,7 +4,6 @@ // SPDX-License-Identifier: MIT // -------------------------------------------------------------------------------------------------------------------- -using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Constants; using LCT.Common.Interface; @@ -49,7 +48,6 @@ static async Task Main(string[] args) CommonAppSettings appSettings = settingsManager.ReadConfiguration(args, FileConstant.appSettingFileName); ISW360ApicommunicationFacade sW360ApicommunicationFacade; ISw360ProjectService sw360ProjectService= Getsw360ProjectServiceObject(appSettings, out sW360ApicommunicationFacade); - ProjectReleases projectReleases = new ProjectReleases(); // do not change the order of getting ca tool information CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile(); Log4Net.CatoolCurrentDirectory = Directory.GetParent(caToolInformation.CatoolRunningLocation).FullName; @@ -57,7 +55,7 @@ static async Task Main(string[] args) string FolderPath = InitiateLogger(appSettings); settingsManager.CheckRequiredArgsToRun(appSettings, "Creator"); - await CreatorValidator.ValidateAppSettings(appSettings, sw360ProjectService, projectReleases); + await CreatorValidator.ValidateAppSettings(appSettings, sw360ProjectService); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package creator >>>>>====================", null); Logger.Logger.Log(null, Level.Notice, $"\nStart of Package creator execution : {DateTime.Now}", null); @@ -70,6 +68,7 @@ static async Task Main(string[] args) $"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" + $"BomFilePath\t\t --> {appSettings.BomFilePath}\n\t" + $"SW360Url\t\t --> {appSettings.SW360URL}\n\t" + + $"FossologyUrl\t\t --> {appSettings.Fossologyurl}\n\t" + $"SW360AuthTokenType\t --> {appSettings.SW360AuthTokenType}\n\t" + $"SW360ProjectName\t --> {appSettings.SW360ProjectName}\n\t" + $"SW360ProjectID\t\t --> {appSettings.SW360ProjectID}\n\t" + diff --git a/src/LCT.Services.UTest/Sw360ProjectServiceTest.cs b/src/LCT.Services.UTest/Sw360ProjectServiceTest.cs index d81d4df6..11dbe3e3 100644 --- a/src/LCT.Services.UTest/Sw360ProjectServiceTest.cs +++ b/src/LCT.Services.UTest/Sw360ProjectServiceTest.cs @@ -32,13 +32,12 @@ public void Setup() public async Task GetProjectNameByProjectIDFromSW360_InvalidSW360Credentials_HttpRequestException_ReturnsProjectNameAsEmpty() { // Arrange - ProjectReleases projectReleases=new ProjectReleases(); Mock sw360ApicommunicationFacadeMck = new Mock(); sw360ApicommunicationFacadeMck.Setup(x => x.GetProjectById(It.IsAny())).Throws(); ISw360ProjectService sw360ProjectService = new Sw360ProjectService(sw360ApicommunicationFacadeMck.Object); // Act - var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("shdjdkhsdfdkfhdhifsodo", "TestProject",projectReleases); + var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("shdjdkhsdfdkfhdhifsodo", "TestProject"); // Assert Assert.That(actualProjectName, Is.EqualTo(string.Empty), "GetProjectNameByProjectIDFromSW360 does not return empty on exception"); @@ -47,14 +46,13 @@ public async Task GetProjectNameByProjectIDFromSW360_InvalidSW360Credentials_Htt [Test] public async Task GetProjectNameByProjectIDFromSW360_InvalidSW360Credentials_AggregateException_ReturnsProjectNameAsEmpty() { - // Arrange - ProjectReleases projectReleases = new ProjectReleases(); + // Arrange Mock sw360ApicommunicationFacadeMck = new Mock(); sw360ApicommunicationFacadeMck.Setup(x => x.GetProjectById(It.IsAny())).Throws(); ISw360ProjectService sw360ProjectService = new Sw360ProjectService(sw360ApicommunicationFacadeMck.Object); // Act - var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("shdjdkhsdfdkfhdhifsodo", "TestProject", projectReleases); + var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("shdjdkhsdfdkfhdhifsodo", "TestProject"); // Assert Assert.That(actualProjectName, Is.EqualTo(string.Empty), "GetProjectNameByProjectIDFromSW360 does not return empty on exception"); @@ -72,7 +70,7 @@ public async Task GetProjectNameByProjectIDFromSW360_ValidProjectIdAndName_Retur ISw360ProjectService sw360ProjectService = new Sw360ProjectService(sw360ApicommunicationFacadeMck.Object); // Act - var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("shdjdkhsdfdkfhdhifsodo", "TestProject",projectsMapper); + var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("shdjdkhsdfdkfhdhifsodo", "TestProject"); // Assert Assert.That(actualProjectName, Is.EqualTo(string.Empty), "Project Id not exist"); @@ -95,7 +93,7 @@ public async Task GetProjectNameByProjectIDFromSW360_ValidProjectNameAndId_Retur ISw360ProjectService sw360ProjectService = new Sw360ProjectService(sw360ApicommunicationFacadeMck.Object); // Act - var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("2c0a03b6d4edaf1b2ccdf64d0d0004f7", "TestProject",projectsMapper); + var actualProjectName = await sw360ProjectService.GetProjectNameByProjectIDFromSW360("2c0a03b6d4edaf1b2ccdf64d0d0004f7", "TestProject"); // Assert Assert.That(actualProjectName, Is.EqualTo(expectedName), "Project Id not exist"); diff --git a/src/LCT.Services.UTest/Sw360ServiceTest.cs b/src/LCT.Services.UTest/Sw360ServiceTest.cs index 39e34c1a..6ede5fc2 100644 --- a/src/LCT.Services.UTest/Sw360ServiceTest.cs +++ b/src/LCT.Services.UTest/Sw360ServiceTest.cs @@ -42,7 +42,7 @@ public async Task GetProjectNameByProjectIDFromSW360_ProvidedProjectIdReturnsPro // Act ISw360ProjectService sw360Service = new Sw360ProjectService(swApiCommunicationFacade.Object); - string sw360ProjectName = await sw360Service.GetProjectNameByProjectIDFromSW360("4aa1165e2d23da3d383692eb9c000a43", "Test", projectsMapper); + string sw360ProjectName = await sw360Service.GetProjectNameByProjectIDFromSW360("4aa1165e2d23da3d383692eb9c000a43", "Test"); // Assert Assert.AreEqual("Test", sw360ProjectName); diff --git a/src/LCT.Services/Interface/ISw360ProjectService.cs b/src/LCT.Services/Interface/ISw360ProjectService.cs index 3a3c24fe..b5eac164 100644 --- a/src/LCT.Services/Interface/ISw360ProjectService.cs +++ b/src/LCT.Services/Interface/ISw360ProjectService.cs @@ -21,7 +21,7 @@ public interface ISw360ProjectService /// projectId /// projectName /// string - Task GetProjectNameByProjectIDFromSW360(string projectId, string projectName, ProjectReleases projectReleases); + Task GetProjectNameByProjectIDFromSW360(string projectId, string projectName); Task> GetAlreadyLinkedReleasesByProjectId(string projectId); } diff --git a/src/LCT.Services/Sw360ProjectService.cs b/src/LCT.Services/Sw360ProjectService.cs index 7289d89c..be9aa167 100644 --- a/src/LCT.Services/Sw360ProjectService.cs +++ b/src/LCT.Services/Sw360ProjectService.cs @@ -39,7 +39,7 @@ public Sw360ProjectService(ISW360ApicommunicationFacade sw360ApiCommunicationFac /// projectId /// projectName /// string - public async Task GetProjectNameByProjectIDFromSW360(string projectId, string projectName, ProjectReleases projectReleases) + public async Task GetProjectNameByProjectIDFromSW360(string projectId, string projectName) { string sw360ProjectName = string.Empty; @@ -56,8 +56,6 @@ public async Task GetProjectNameByProjectIDFromSW360(string projectId, s { var projectInfo = JsonConvert.DeserializeObject(result); sw360ProjectName = projectInfo?.Name; - projectReleases.Name=projectInfo?.Name; - projectReleases.Version=projectInfo?.Version; projectReleases.state = projectInfo?.state; projectReleases.clearingState = projectInfo?.clearingState; }