From 5a9d7e15a586ced883617269a6bcecb4b147b54a Mon Sep 17 00:00:00 2001
From: Vijayalakshmi027 <58800320+Vijayalakshmi027@users.noreply.github.com>
Date: Tue, 11 Jun 2024 13:30:29 +0530
Subject: [PATCH 1/5] Revert "Updating SBOM with component Hashes"
---
.../Model/DisplayPackagesInfo.cs | 29 +-
.../PackageUploadHelper.cs | 285 ++----------------
src/ArtifactoryUploader/PackageUploader.cs | 24 +-
src/ArtifactoryUploader/Program.cs | 1 +
.../JfrogAqlApiCommunication.cs | 2 +-
.../Model/AQL/AqlResult.cs | 9 -
src/LCT.Common/Constants/FileConstant.cs | 2 -
src/LCT.Common/CycloneDXBomParser.cs | 5 +-
src/LCT.Common/ExceptionHandling.cs | 4 +-
src/LCT.Common/FileOperations.cs | 84 +-----
src/LCT.Common/Interface/IFileOperations.cs | 18 --
src/LCT.Common/Model/MultipleVersionValues.cs | 30 --
.../BomHelperUnitTests.cs | 256 +---------------
.../BomValidatorUnitTests.cs | 13 +-
.../CycloneBomProcessorTests.cs | 44 +--
src/LCT.PackageIdentifier/AlpineProcesser.cs | 5 +-
src/LCT.PackageIdentifier/BomCreator.cs | 6 +-
src/LCT.PackageIdentifier/BomValidator.cs | 5 +-
src/LCT.PackageIdentifier/ConanProcessor.cs | 78 +----
.../CycloneBomProcessor.cs | 32 +-
src/LCT.PackageIdentifier/DebianProcessor.cs | 28 +-
.../Interface/IBomCreator.cs | 3 +-
src/LCT.PackageIdentifier/MavenProcessor.cs | 26 --
src/LCT.PackageIdentifier/NpmProcessor.cs | 82 +----
src/LCT.PackageIdentifier/NugetProcessor.cs | 91 +-----
src/LCT.PackageIdentifier/Program.cs | 172 +----------
src/LCT.PackageIdentifier/PythonProcessor.cs | 28 +-
src/LCT.PackageIdentifier/Scanner.cs | 9 +-
.../CreatorValidatorTest.cs | 13 +-
.../ComponentCreator.cs | 2 +-
.../CreatorValidator.cs | 5 +-
src/LCT.SW360PackageCreator/Program.cs | 5 +-
.../Sw360ProjectServiceTest.cs | 12 +-
src/LCT.Services.UTest/Sw360ServiceTest.cs | 2 +-
.../Interface/ISw360ProjectService.cs | 2 +-
src/LCT.Services/Sw360ProjectService.cs | 4 +-
36 files changed, 121 insertions(+), 1295 deletions(-)
delete mode 100644 src/LCT.Common/Model/MultipleVersionValues.cs
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 bcbaaf88..0be43fea 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;
@@ -153,12 +152,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);
@@ -174,7 +173,9 @@ private static void DisplayErrorForJfrogFoundPackages(List {jfrogFoundPackage.DestRepoName}");
@@ -183,11 +184,6 @@ 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)
- {
- JsonComponents jsonComponents = new JsonComponents();
- jsonComponents.Name = npmpackage.Name;
- jsonComponents.Version = npmpackage.Version;
- npmComponents.Add(jsonComponents);
- }
- myDeserializedClass.Npm = npmComponents;
- fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory");
-
- }
- else
- {
- projectResponse.Npm = new List();
- foreach (var npmpackage in unknownPackages)
- {
- JsonComponents jsonComponents = new JsonComponents();
- jsonComponents.Name = npmpackage.Name;
- jsonComponents.Version = npmpackage.Version;
- projectResponse.Npm.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 GetNotApprovedNugetPackages(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 nugetComponents = new List();
- foreach (var nugetpackage in unknownPackages)
- {
- JsonComponents jsonComponents = new JsonComponents();
- jsonComponents.Name = nugetpackage.Name;
- jsonComponents.Version = nugetpackage.Version;
- nugetComponents.Add(jsonComponents);
- }
- 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))
+ if (unknownPackages.Any())
{
- string json = File.ReadAllText(filename);
- ProjectResponse myDeserializedClass = JsonConvert.DeserializeObject(json);
- List mavenComponents = new List();
- foreach (var mavenPackage in unknownPackages)
+ foreach (var unknownPackage in unknownPackages)
{
- JsonComponents jsonComponents = new JsonComponents();
- jsonComponents.Name = mavenPackage.Name;
- jsonComponents.Version = mavenPackage.Version;
- mavenComponents.Add(jsonComponents);
+ Logger.Warn($"Package {unknownPackage.Name}-{unknownPackage.Version} is not in report approved state,hence artifactory upload will not be done!");
}
- myDeserializedClass.Maven = mavenComponents;
- fileOperations.WriteContentToReportNotApprovedFile(myDeserializedClass, filepath, FileConstant.artifactoryReportNotApproved, "Artifactory");
-
+ Logger.Info("\n");
}
- 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)
{
@@ -485,14 +236,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 2c5750fc..b975d48c 100644
--- a/src/ArtifactoryUploader/Program.cs
+++ b/src/ArtifactoryUploader/Program.cs
@@ -56,6 +56,7 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Info, $"Input Parameters used in Artifactory Uploader:\n\t", null);
Logger.Logger.Log(null, Level.Notice, $"\tBomFilePath:\t\t {appSettings.BomFilePath}\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 e280983d..b89a1e4c 100644
--- a/src/LCT.Common/Constants/FileConstant.cs
+++ b/src/LCT.Common/Constants/FileConstant.cs
@@ -50,7 +50,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 90f57023..bd570cce 100644
--- a/src/LCT.Common/CycloneDXBomParser.cs
+++ b/src/LCT.Common/CycloneDXBomParser.cs
@@ -25,7 +25,7 @@ public Bom ParseCycloneDXBom(string filePath)
{
Bom bom = new Bom();
string json = string.Empty;
- Logger.Logger.Log(null, Level.Notice, $"Consuming cyclonedx file data from " + filePath + "...\n", null);
+ Logger.Logger.Log(null, Level.Notice, $"Consuming cyclonedx file data from "+ filePath + "...\n", null);
try
{
@@ -81,7 +81,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
@@ -94,6 +94,5 @@ public static void CheckValidComponentsForProjectType(List bom, strin
}
}
}
-
}
}
diff --git a/src/LCT.Common/ExceptionHandling.cs b/src/LCT.Common/ExceptionHandling.cs
index 3918532d..a32eb7b8 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/FileOperations.cs b/src/LCT.Common/FileOperations.cs
index 7f876ad1..3ec79012 100644
--- a/src/LCT.Common/FileOperations.cs
+++ b/src/LCT.Common/FileOperations.cs
@@ -8,14 +8,12 @@
using LCT.Common.Interface;
using log4net;
using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security;
-using Newtonsoft.Json.Converters;
namespace LCT.Common
{
@@ -51,9 +49,10 @@ public void ValidateFilePath(string filePath)
public string WriteContentToFile(T dataToWrite, string folderPath, string fileNameWithExtension, string projectName)
{
try
- {
- Logger.Debug($"WriteContentToFile():folderpath-{folderPath},fileNameWithExtension-{fileNameWithExtension}," + $"projectName-{projectName}");
- string jsonString = JsonConvert.SerializeObject(dataToWrite, Formatting.Indented, new StringEnumConverter());
+ {
+ Logger.Debug($"WriteContentToFile():folderpath-{folderPath},fileNameWithExtension-{fileNameWithExtension}," +
+ $"projectName-{projectName}");
+ string jsonString = JsonConvert.SerializeObject(dataToWrite, Formatting.Indented);
string fileName = $"{projectName}_{fileNameWithExtension}";
string filePath = Path.Combine(folderPath, fileName);
@@ -194,80 +193,5 @@ private static void BackupTheGivenFile(string folderPath, string fileName)
Environment.ExitCode = -1;
}
}
- ///
- /// writes the content to the specified file
- ///
- ///
- /// dataToWrite
- /// folderPath
- /// fileNameWithExtension
- /// projectName
- public string WriteContentToReportNotApprovedFile(T dataToWrite, string folderPath, string fileNameWithExtension, string name)
- {
- try
- {
- Logger.Debug($"WriteContentToReportNotApprovedFile():folderpath-{folderPath},fileNameWithExtension-{fileNameWithExtension}," +
- $"Name-{name}");
- string jsonString = JsonConvert.SerializeObject(dataToWrite, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- string fileName = $"{name}_{fileNameWithExtension}";
-
- string filePath = Path.Combine(folderPath, fileName);
- Logger.Debug($"filePath-{filePath}");
- File.WriteAllText(filePath, jsonString);
-
- }
- catch (IOException e)
- {
- Logger.Debug($"WriteContentToReportNotApprovedFile():Error:", e);
- return "failure";
- }
- catch (UnauthorizedAccessException e)
- {
- Logger.Debug($"WriteContentToReportNotApprovedFile():Error:", e);
- return "failure";
- }
- catch (SecurityException e)
- {
- Logger.Debug($"WriteContentToReportNotApprovedFile():Error:", e);
- return "failure";
- }
- Logger.Debug($"WriteContentToReportNotApprovedFile():End");
- return "success";
-
- }
- public string WriteContentToMultipleVersionsFile(T dataToWrite, string folderPath, string fileNameWithExtension, string projectName)
- {
- try
- {
- Logger.Debug($"WriteContentToMultipleVersionsFile():folderpath-{folderPath},fileNameWithExtension-{fileNameWithExtension}," +
- $"projectName-{projectName}");
- string jsonString = JsonConvert.SerializeObject(dataToWrite, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- string fileName = $"{projectName}_{fileNameWithExtension}";
-
- string filePath = Path.Combine(folderPath, fileName);
- Logger.Debug($"filePath-{filePath}");
- BackupTheGivenFile(folderPath, fileName);
- File.WriteAllText(filePath, jsonString);
-
- }
- catch (IOException e)
- {
- Logger.Debug($"WriteContentToMultipleVersionsFile():Error:", e);
- return "failure";
- }
- catch (UnauthorizedAccessException e)
- {
- Logger.Debug($"WriteContentToMultipleVersionsFile():Error:", e);
- return "failure";
- }
- catch (SecurityException e)
- {
- Logger.Debug($"WriteContentToMultipleVersionsFile():Error:", e);
- return "failure";
- }
- Logger.Debug($"WriteContentToMultipleVersionsFile():End");
- return "success";
-
- }
}
}
diff --git a/src/LCT.Common/Interface/IFileOperations.cs b/src/LCT.Common/Interface/IFileOperations.cs
index a4d1c119..03ddd803 100644
--- a/src/LCT.Common/Interface/IFileOperations.cs
+++ b/src/LCT.Common/Interface/IFileOperations.cs
@@ -41,23 +41,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 7647ac39..a5237c7e 100644
--- a/src/LCT.PackageIdentifier.UTest/BomHelperUnitTests.cs
+++ b/src/LCT.PackageIdentifier.UTest/BomHelperUnitTests.cs
@@ -55,11 +55,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);
@@ -76,256 +73,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 52927bcf..e7a5b757 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,
@@ -40,27 +35,23 @@ public void SetMetadataInComparisonBOM_GivenBOMWithEmptyMetadata_FillsInMetadata
CaVersion = "1.2.3"
};
//Act
- Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases);
+ Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings);
//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()
{
@@ -70,8 +61,7 @@ public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoI
};
CommonAppSettings appSettings = new CommonAppSettings()
{
- CaVersion = "1.2.3",
- SW360ProjectName = "Test",
+ CaVersion = "1.2.3"
};
Tool tools = new Tool()
@@ -80,28 +70,12 @@ public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoI
Version = "1.0.17",
Vendor = "Siemens AG"
};
- Tool SiemensSBOM = new Tool
- {
- Name = "Siemens SBOM",
- Version = "2.0.0",
- Vendor = "Siemens AG",
- };
- Component component = new Component
- {
- Name = appSettings.SW360ProjectName,
- Version = projectReleases.Version,
- Type = Component.Classification.Application
- };
-
//Act
- Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases);
+ Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings);
//Assert
- Assert.That(tools.Name, Is.EqualTo(files.Metadata.Tools[1].Name), "Returns bom with metadata tools");
- Assert.That(SiemensSBOM.Name, Is.EqualTo(files.Metadata.Tools[2].Name), "Returns bom with metadata tools");
- Assert.That(component.Name, Is.EqualTo(files.Metadata.Component.Name), "Returns bom with metadata component ");
- Assert.That(component.Version, Is.EqualTo(files.Metadata.Component.Version), "Returns bom with metadata component ");
- Assert.That(component.Type, Is.EqualTo(files.Metadata.Component.Type), "Returns bom with metadata component ");
+ Assert.That(tools.Name, Is.EqualTo(files.Metadata.Tools[1].Name), "Returns bom with metadata ");
+
}
[Test]
public void SetProperties_GivenComponent_SetsPropertiesInBOM()
diff --git a/src/LCT.PackageIdentifier/AlpineProcesser.cs b/src/LCT.PackageIdentifier/AlpineProcesser.cs
index 179e85a4..f9f3da2b 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 83976ca7..db59edd4 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;
@@ -41,7 +40,7 @@ public BomCreator(ICycloneDXBomParser cycloneDXBomParser)
CycloneDXBomParser = cycloneDXBomParser;
}
- public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases)
+ public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations)
{
Logger.Debug($"GenerateBom():Start");
Bom listOfComponentsToBom;
@@ -52,10 +51,9 @@ public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelpe
$"= {listOfComponentsToBom.Components.Count}", null);
bomKpiData.ComponentsInComparisonBOM = listOfComponentsToBom.Components.Count;
- //Get project details for metadata properties
//sets metadata properties
- listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, appSettings,projectReleases);
+ listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, appSettings);
// Writes Comparison Bom
Logger.Logger.Log(null, Level.Notice, $"Writing CycloneDX BOM..", null);
diff --git a/src/LCT.PackageIdentifier/BomValidator.cs b/src/LCT.PackageIdentifier/BomValidator.cs
index a4db211a..29e69ed9 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.IO;
@@ -17,9 +16,9 @@ namespace LCT.PackageIdentifier
///
public static class BomValidator
{
- public static async Task ValidateAppSettings(CommonAppSettings appSettings, ISw360ProjectService bomService, ProjectReleases projectReleases)
+ public static async Task ValidateAppSettings(CommonAppSettings appSettings, ISw360ProjectService bomService)
{
- 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 f57d4f3f..1207dd38 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;
@@ -31,7 +29,7 @@ namespace LCT.PackageIdentifier
///
/// Parses the Conan Packages
///
- public class ConanProcessor : CycloneDXBomParser,IParser
+ public class ConanProcessor : CycloneDXBomParser, IParser
{
#region fields
static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -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;
@@ -126,8 +128,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName);
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoUrl, Value = repoName };
Component componentVal = component;
@@ -138,29 +138,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);
}
@@ -182,50 +160,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 af14d1b2..10eabdd5 100644
--- a/src/LCT.PackageIdentifier/CycloneBomProcessor.cs
+++ b/src/LCT.PackageIdentifier/CycloneBomProcessor.cs
@@ -5,15 +5,11 @@
// --------------------------------------------------------------------------------------------------------------------
using CycloneDX.Models;
-using LCT.APICommunications.Model;
using LCT.Common;
using LCT.Common.Constants;
using log4net;
-using System;
using System.Collections.Generic;
using System.Reflection;
-using System.Security.Policy;
-using static CycloneDX.Models.ExternalReference;
namespace LCT.PackageIdentifier
{
@@ -22,50 +18,28 @@ public static class CycloneBomProcessor
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSettings, ProjectReleases projectReleases)
+ public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSettings)
{
Logger.Debug("Starting to add metadata info into the BOM");
List tools = new List();
- List components = new List();
Tool tool = new Tool
{
Name = "Clearing Automation Tool",
Version = appSettings.CaVersion,
- Vendor = "Siemens AG",
- ExternalReferences = new List() { new ExternalReference { Url = "https://github.com/siemens/continuous-clearing", Type = ExternalReference.ExternalReferenceType.Website } }
-
+ Vendor = "Siemens AG"
};
tools.Add(tool);
- Tool SiemensSBOM = new Tool
- {
- Name = "Siemens SBOM",
- Version = "2.0.0",
- Vendor = "Siemens AG",
- ExternalReferences = new List() { new ExternalReference { Url = "https://sbom.siemens.io/", Type = ExternalReference.ExternalReferenceType.Website } }
- };
- tools.Add(SiemensSBOM);
- Component component = new Component
- {
- Name = appSettings.SW360ProjectName,
- Version = projectReleases.Version,
- Type = Component.Classification.Application
- };
- components.Add(component);
if (bom.Metadata != null)
{
bom.Metadata.Tools.AddRange(tools);
- bom.Metadata.Component.Name = component.Name;
- bom.Metadata.Component.Version = component.Version;
- bom.Metadata.Component.Type = component.Type;
}
else
{
bom.Metadata = new Metadata
{
- Tools = tools,
- Component = component
+ Tools = tools
};
}
return bom;
diff --git a/src/LCT.PackageIdentifier/DebianProcessor.cs b/src/LCT.PackageIdentifier/DebianProcessor.cs
index b23e1a68..b077b442 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
@@ -27,7 +25,7 @@ namespace LCT.PackageIdentifier
///
/// The DebianProcessor class
///
- public class DebianProcessor : IParser
+ public class DebianProcessor : IParser
{
static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly ICycloneDXBomParser _cycloneDXBomParser;
@@ -104,8 +102,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName);
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoUrl, Value = repoName };
Component componentVal = component;
@@ -116,29 +112,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 bc865d30..014cd55a 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.Services.Interface;
@@ -21,7 +20,7 @@ public interface IBomCreator
public IBomHelper BomHelper { get; set; }
- public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations, ProjectReleases projectReleases);
+ public Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelper, IFileOperations fileOperations);
public Task CheckJFrogConnection();
}
diff --git a/src/LCT.PackageIdentifier/MavenProcessor.cs b/src/LCT.PackageIdentifier/MavenProcessor.cs
index 74296075..248a7a62 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;
@@ -176,10 +175,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName);
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoUrl, Value = repoName };
Component componentVal = component;
if (componentVal.Properties?.Count == null || componentVal.Properties?.Count <= 0)
@@ -189,29 +185,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 135e921b..2479a7aa 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,17 +62,19 @@ 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;
Logger.Debug($"ParsePackageFile():End");
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();
@@ -132,51 +133,6 @@ public List ParsePackageLockJson(string filepath, CommonAppSettings a
return lstComponentForBOM;
}
- 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.Npm = new List();
- foreach (var npmpackage in componentsWithMultipleVersions)
- {
- npmpackage.Description = !string.IsNullOrEmpty(appSettings.CycloneDxSBomTemplatePath) ? appSettings.CycloneDxSBomTemplatePath : npmpackage.Description;
-
- MultipleVersionValues jsonComponents = new MultipleVersionValues();
- jsonComponents.ComponentName = npmpackage.Name;
- jsonComponents.ComponentVersion = npmpackage.Version;
- jsonComponents.PackageFoundIn = npmpackage.Description;
- multipleVersions.Npm.Add(jsonComponents);
- }
- fileOperations.WriteContentToMultipleVersionsFile(multipleVersions, appSettings.BomFolderPath, FileConstant.multipleversionsFileName, appSettings.SW360ProjectName);
- Logger.Warn($"\nTotal Multiple versions detected {multipleVersions.Npm.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 npmComponents = new List();
- foreach (var npmpackage in componentsWithMultipleVersions)
- {
- npmpackage.Description = !string.IsNullOrEmpty(appSettings.CycloneDxSBomTemplatePath) ? appSettings.CycloneDxSBomTemplatePath : npmpackage.Description;
-
- MultipleVersionValues jsonComponents = new MultipleVersionValues();
- jsonComponents.ComponentName = npmpackage.Name;
- jsonComponents.ComponentVersion = npmpackage.Version;
- jsonComponents.PackageFoundIn = npmpackage.Description;
-
- npmComponents.Add(jsonComponents);
- }
- myDeserializedClass.Npm = npmComponents;
-
- fileOperations.WriteContentToMultipleVersionsFile(myDeserializedClass, appSettings.BomFolderPath, FileConstant.multipleversionsFileName, appSettings.SW360ProjectName);
- Logger.Warn($"\nTotal Multiple versions detected {npmComponents.Count} and details can be found at {appSettings.BomFolderPath}\\{appSettings.SW360ProjectName}_{FileConstant.multipleversionsFileName}\n");
- }
- }
-
-
private static void GetPackagesForBom(string filepath, ref List bundledComponents, ref List lstComponentForBOM, ref int noOfDevDependent, IEnumerable depencyComponentList)
{
BomCreator.bomKpiData.ComponentsinPackageLockJsonFile += depencyComponentList.Count();
@@ -356,9 +312,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName);
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoUrl, Value = repoName };
Component componentVal = component;
@@ -369,29 +323,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/NugetProcessor.cs b/src/LCT.PackageIdentifier/NugetProcessor.cs
index 18e54738..878697d0 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,12 +43,13 @@ 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();
CheckForMultipleVersions(appSettings, componentsWithMultipleVersions);
+
Logger.Debug($"ParsePackageFile():End");
return bom;
}
@@ -222,10 +220,7 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName);
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoUrl, Value = repoName };
Component componentVal = component;
@@ -236,28 +231,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;
@@ -415,7 +389,7 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref 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.Nuget = new List();
- foreach (var nugetPackage in componentsWithMultipleVersions)
- {
- nugetPackage.Description = !string.IsNullOrEmpty(appSettings.CycloneDxSBomTemplatePath) ? appSettings.CycloneDxSBomTemplatePath : nugetPackage.Description;
-
- MultipleVersionValues jsonComponents = new MultipleVersionValues();
- jsonComponents.ComponentName = nugetPackage.Name;
- jsonComponents.ComponentVersion = nugetPackage.Version;
- jsonComponents.PackageFoundIn = nugetPackage.Description;
- multipleVersions.Nuget.Add(jsonComponents);
- }
- fileOperations.WriteContentToMultipleVersionsFile(multipleVersions, appSettings.BomFolderPath, FileConstant.multipleversionsFileName, appSettings.SW360ProjectName);
- Logger.Warn($"\nTotal Multiple versions detected {multipleVersions.Nuget.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 nugetComponents = new List();
- foreach (var nugetPackage in componentsWithMultipleVersions)
- {
- nugetPackage.Description = !string.IsNullOrEmpty(appSettings.CycloneDxSBomTemplatePath) ? appSettings.CycloneDxSBomTemplatePath : nugetPackage.Description;
-
- MultipleVersionValues jsonComponents = new MultipleVersionValues();
- jsonComponents.ComponentName = nugetPackage.Name;
- jsonComponents.ComponentVersion = nugetPackage.Version;
- jsonComponents.PackageFoundIn = nugetPackage.Description;
-
- nugetComponents.Add(jsonComponents);
- }
- myDeserializedClass.Nuget = nugetComponents;
-
- fileOperations.WriteContentToMultipleVersionsFile(myDeserializedClass, appSettings.BomFolderPath, FileConstant.multipleversionsFileName, appSettings.SW360ProjectName);
- Logger.Warn($"\nTotal Multiple versions detected {nugetComponents.Count} and details can be found at {appSettings.BomFolderPath}\\{appSettings.SW360ProjectName}_{FileConstant.multipleversionsFileName}\n");
- }
+
+ bom = RemoveExcludedComponents(appSettings, bom);
}
private static void ConvertToCycloneDXModel(List listComponentForBOM, List listofComponents, List dependencies)
@@ -570,7 +500,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.");
}
}
@@ -580,7 +510,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 7775ca79..c74c6f73 100644
--- a/src/LCT.PackageIdentifier/Program.cs
+++ b/src/LCT.PackageIdentifier/Program.cs
@@ -24,7 +24,6 @@
using LCT.APICommunications.Interfaces;
using LCT.APICommunications;
using LCT.APICommunications.Model;
-using System.Linq;
namespace LCT.PackageIdentifier
{
@@ -48,7 +47,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();
+
string FolderPath = LogFolderInitialisation(appSettings);
settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer");
@@ -65,15 +64,7 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Alert, $"Package Identifier is running in TEST mode \n", null);
// Validate application settings
- await ValidateAppsettingsFile(appSettings,projectReleases);
- string listOfInlude = DisplayInclude(appSettings);
- string listOfExclude = DisplayExclude(appSettings);
- string listOfExcludeComponents = DisplayExcludeComponents(appSettings);
- string listOfInternalRepoList = string.Empty;
- if (appSettings.InternalRepoList != null)
- {
- listOfInternalRepoList = string.Join(",", appSettings.InternalRepoList?.ToList());
- }
+ await ValidateAppsettingsFile(appSettings);
Logger.Logger.Log(null, Level.Notice, $"Input Parameters used in Package Identifier:\n\t" +
$"PackageFilePath\t\t --> {appSettings.PackageFilePath}\n\t" +
@@ -84,12 +75,7 @@ static async Task Main(string[] args)
$"SW360ProjectName\t --> {appSettings.SW360ProjectName}\n\t" +
$"SW360ProjectID\t\t --> {appSettings.SW360ProjectID}\n\t" +
$"ProjectType\t\t --> {appSettings.ProjectType}\n\t" +
- $"LogFolderPath\t\t --> {Path.GetFullPath(FolderPath)}\n\t" +
- $"InternalRepoList\t --> {listOfInternalRepoList}\n\t" +
- $"Include\t\t\t --> {listOfInlude}\n\t" +
- $"Exclude\t\t\t --> {listOfExclude}\n\t" +
- $"ExcludeComponents\t --> {listOfExcludeComponents}\n", null);
-
+ $"LogFolderPath\t\t --> {Path.GetFullPath(FolderPath)}", null);
if (appSettings.IsTestMode)
Logger.Logger.Log(null, Level.Notice, $"\tMode\t\t\t --> {appSettings.Mode}\n", null);
@@ -102,7 +88,7 @@ static async Task Main(string[] args)
//Validating JFrog Settings
if (await bomCreator.CheckJFrogConnection())
{
- await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations(),projectReleases);
+ await bomCreator.GenerateBom(appSettings, new BomHelper(), new FileOperations());
}
Logger.Logger.Log(null, Level.Notice, $"End of Package Identifier execution : {DateTime.Now}\n", null);
}
@@ -121,7 +107,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()
{
@@ -132,153 +118,7 @@ private static async Task ValidateAppsettingsFile(CommonAppSettings appSettings,
Timeout = appSettings.TimeOut
};
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":
- if (appSettings.Python.Include != null)
- {
- totalString = string.Join(",", appSettings.Python.Include?.ToList());
- }
- return totalString;
- case "CONAN":
- if (appSettings.Conan.Include != null)
- {
- totalString = string.Join(",", appSettings.Conan.Include?.ToList());
- }
- return totalString;
- default:
- Logger.Error($"Invalid ProjectType - {appSettings.ProjectType}");
- break;
- }
- return totalString;
- }
- private static string DisplayExclude(CommonAppSettings appSettings)
- {
-
- string totalString = string.Empty;
- switch (appSettings.ProjectType.ToUpperInvariant())
- {
- case "NPM":
- if (appSettings.Npm.Exclude != null)
- {
- totalString = string.Join(",", appSettings.Npm.Exclude?.ToList());
- }
- return totalString;
- case "NUGET":
- if (appSettings.Nuget.Exclude != null)
- {
- totalString = string.Join(",", appSettings.Nuget.Exclude?.ToList());
- }
- return totalString;
- case "MAVEN":
- if (appSettings.Maven.Exclude != null)
- {
- totalString = string.Join(",", appSettings.Maven.Exclude?.ToList());
- }
- return totalString;
- case "DEBIAN":
- if (appSettings.Debian.Exclude != null)
- {
- totalString = string.Join(",", appSettings.Debian.Exclude?.ToList());
- }
- return totalString;
- case "PYTHON":
- if (appSettings.Python.Exclude != null)
- {
- totalString = string.Join(",", appSettings.Python.Exclude?.ToList());
- }
- return totalString;
- case "CONAN":
- if (appSettings.Conan.Exclude != null)
- {
- totalString = string.Join(",", appSettings.Conan.Exclude?.ToList());
- }
- return totalString;
- default:
- Logger.Error($"Invalid ProjectType - {appSettings.ProjectType}");
- break;
- }
- return totalString;
- }
-
- private static string DisplayExcludeComponents(CommonAppSettings appSettings)
- {
-
- string totalString = string.Empty;
- switch (appSettings.ProjectType.ToUpperInvariant())
- {
- case "NPM":
- if (appSettings.Npm.ExcludedComponents != null)
- {
- totalString = string.Join(",", appSettings.Npm.ExcludedComponents?.ToList());
- }
- return totalString;
- case "NUGET":
- if (appSettings.Nuget.ExcludedComponents != null)
- {
- totalString = string.Join(",", appSettings.Nuget.ExcludedComponents?.ToList());
- }
- return totalString;
- case "MAVEN":
- if (appSettings.Maven.ExcludedComponents != null)
- {
- totalString = string.Join(",", appSettings.Maven.ExcludedComponents?.ToList());
- }
- return totalString;
- case "DEBIAN":
- if (appSettings.Debian.ExcludedComponents != null)
- {
- totalString = string.Join(",", appSettings.Debian.ExcludedComponents?.ToList());
- }
-
- return totalString;
- case "PYTHON":
- if (appSettings.Python.ExcludedComponents != null)
- {
- totalString = string.Join(",", appSettings.Python.ExcludedComponents?.ToList());
- }
- return totalString;
- case "CONAN":
- if (appSettings.Conan.ExcludedComponents != null)
- {
- totalString = string.Join(",", appSettings.Conan.ExcludedComponents?.ToList());
- }
- return totalString;
- default:
- Logger.Error($"Invalid ProjectType - {appSettings.ProjectType}");
- break;
- }
- return totalString;
+ await BomValidator.ValidateAppSettings(appSettings, sw360ProjectService);
}
private static string LogFolderInitialisation(CommonAppSettings appSettings)
diff --git a/src/LCT.PackageIdentifier/PythonProcessor.cs b/src/LCT.PackageIdentifier/PythonProcessor.cs
index 5b5e6b96..f1058ce2 100644
--- a/src/LCT.PackageIdentifier/PythonProcessor.cs
+++ b/src/LCT.PackageIdentifier/PythonProcessor.cs
@@ -24,8 +24,8 @@
using Component = CycloneDX.Models.Component;
namespace LCT.PackageIdentifier
-{
- public class PythonProcessor : IParser
+{
+ public class PythonProcessor : IParser
{
private const string NotFoundInRepo = "Not Found in JFrogRepo";
@@ -353,8 +353,6 @@ public async Task> GetJfrogRepoDetailsOfAComponent(List x.Name == jfrogpackageName);
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoUrl, Value = repoName };
Component componentVal = component;
@@ -365,29 +363,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 effc2502..30a4c5b5 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.");
Environment.Exit(-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 28b5d791..b24f3332 100644
--- a/src/LCT.SW360PackageCreator/ComponentCreator.cs
+++ b/src/LCT.SW360PackageCreator/ComponentCreator.cs
@@ -505,7 +505,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 707b2391..007fe567 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;
namespace LCT.SW360PackageCreator
@@ -18,9 +17,9 @@ namespace LCT.SW360PackageCreator
///
public static class CreatorValidator
{
- public static async Task ValidateAppSettings(CommonAppSettings appSettings, ISw360ProjectService sw360ProjectService, ProjectReleases projectReleases)
+ public static async Task ValidateAppSettings(CommonAppSettings appSettings, ISw360ProjectService sw360ProjectService)
{
- 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 25419dbb..82102429 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,11 +48,10 @@ 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();
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);
@@ -64,6 +62,7 @@ static async Task Main(string[] args)
Logger.Logger.Log(null, Level.Notice, $"Input parameters used in Package Creator:\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 fda2c5dd..0dd5b48d 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;
}
}
From a9f1795db68ea29e4a12817ed3bd509a58f177fc Mon Sep 17 00:00:00 2001
From: karthika
Date: Thu, 27 Jun 2024 12:28:23 +0530
Subject: [PATCH 2/5] Bugfix: Components are not present in the BOM
---
src/LCT.PackageIdentifier/MavenProcessor.cs | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/LCT.PackageIdentifier/MavenProcessor.cs b/src/LCT.PackageIdentifier/MavenProcessor.cs
index 248a7a62..efcb9071 100644
--- a/src/LCT.PackageIdentifier/MavenProcessor.cs
+++ b/src/LCT.PackageIdentifier/MavenProcessor.cs
@@ -48,7 +48,16 @@ public Bom ParsePackageFile(CommonAppSettings appSettings)
if (!filepath.EndsWith(FileConstant.SBOMTemplateFileExtension))
{
Bom bomList = ParseCycloneDXBom(filepath);
- CheckValidComponentsForProjectType(bomList.Components, appSettings.ProjectType);
+
+ if (bomList?.Components != null)
+ {
+ CheckValidComponentsForProjectType(bomList.Components, appSettings.ProjectType);
+ }
+ else
+ {
+ Logger.Error("No components found in the BOM file : " + filepath);
+ continue;
+ }
if (componentsForBOM.Count == 0)
{
@@ -86,7 +95,7 @@ public Bom ParsePackageFile(CommonAppSettings appSettings)
componentsForBOM = ListOfComponents.Distinct(new ComponentEqualityComparer()).ToList();
BomCreator.bomKpiData.DuplicateComponents = totalComponentsIdentified - componentsForBOM.Count;
-
+
if (appSettings.Maven.ExcludedComponents != null)
{
From aadd24c531239fca7aaea3845f252539407116f3 Mon Sep 17 00:00:00 2001
From: karthika