diff --git a/doc/UsageDoc/CA_UsageDocument.md b/doc/UsageDoc/CA_UsageDocument.md index b87dd0f8..ade3f548 100644 --- a/doc/UsageDoc/CA_UsageDocument.md +++ b/doc/UsageDoc/CA_UsageDocument.md @@ -237,7 +237,7 @@ Currently LTA support is not provided for SBOM, hence until that is implemented ``` { - "CaVersion": "6.2.0", + "CaVersion": "", "TimeOut": 200, "ProjectType": "", "SW360ProjectName": "", diff --git a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj index 49c58f26..f2be23ab 100644 --- a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj +++ b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj @@ -4,6 +4,7 @@ Exe net8.0 ArtifactoryUploader + 7.0.0 diff --git a/src/ArtifactoryUploader/Program.cs b/src/ArtifactoryUploader/Program.cs index 2c5750fc..7a69617d 100644 --- a/src/ArtifactoryUploader/Program.cs +++ b/src/ArtifactoryUploader/Program.cs @@ -23,6 +23,7 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; +using LCT.Common.Model; namespace ArtifactoryUploader { @@ -44,6 +45,7 @@ static async Task Main(string[] args) string FolderPath = InitiateLogger(appSettings); settingsManager.CheckRequiredArgsToRun(appSettings, "Uploader"); + CatoolInfo caToolVersion = GetCatoolVersionFromProjectfile(); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Artifactory Uploader >>>>>====================", null); Logger.Logger.Log(null, Level.Notice, $"\nStart of Artifactory Uploader execution: {DateTime.Now}", null); @@ -55,6 +57,8 @@ 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" + + $"CaToolVersion\t\t --> {caToolVersion.CatoolVersion}\n\t" + + $"CaToolRunningPath\t --> {caToolVersion.CatoolRunningLocation}\n\t" + $"JFrogUrl:\t\t {appSettings.JFrogApi}\n\t" + $"Release:\t\t {appSettings.Release}\n\t" + $"LogFolderPath:\t\t {Path.GetFullPath(FolderPath)}\n", null); @@ -77,6 +81,15 @@ static async Task Main(string[] args) Logger.Logger.Log(null, Level.Notice, $"End of Artifactory Uploader execution : {DateTime.Now}\n", null); } + private static CatoolInfo GetCatoolVersionFromProjectfile() + { + CatoolInfo catoolInfo = new CatoolInfo(); + var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version; + catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}"; + catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + return catoolInfo; + } + private static string InitiateLogger(CommonAppSettings appSettings) { string FolderPath; diff --git a/src/LCT.APICommunications/LCT.APICommunications.csproj b/src/LCT.APICommunications/LCT.APICommunications.csproj index 675263d8..78f1d279 100644 --- a/src/LCT.APICommunications/LCT.APICommunications.csproj +++ b/src/LCT.APICommunications/LCT.APICommunications.csproj @@ -3,6 +3,7 @@ Library net8.0 + 7.0.0 diff --git a/src/LCT.Common/LCT.Common.csproj b/src/LCT.Common/LCT.Common.csproj index 486a8aa5..fb2cc9d9 100644 --- a/src/LCT.Common/LCT.Common.csproj +++ b/src/LCT.Common/LCT.Common.csproj @@ -3,6 +3,7 @@ Library net8.0 + 7.0.0 diff --git a/src/LCT.Common/Model/CatoolInfo.cs b/src/LCT.Common/Model/CatoolInfo.cs new file mode 100644 index 00000000..80faa6be --- /dev/null +++ b/src/LCT.Common/Model/CatoolInfo.cs @@ -0,0 +1,16 @@ +// -------------------------------------------------------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2024 Siemens AG +// +// SPDX-License-Identifier: MIT +// -------------------------------------------------------------------------------------------------------------------- + + +namespace LCT.Common.Model +{ + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public class CatoolInfo + { + public string CatoolVersion { get; set; } + public string CatoolRunningLocation { get; set; } + } +} \ No newline at end of file diff --git a/src/LCT.Common/appSettings.json b/src/LCT.Common/appSettings.json index d67393b1..f3aa2960 100644 --- a/src/LCT.Common/appSettings.json +++ b/src/LCT.Common/appSettings.json @@ -5,7 +5,7 @@ // -------------------------------------------------------------------------------------------------------------------- { - "CaVersion": "7.0.0", + "CaVersion": "", "TimeOut": 200, "ProjectType": "", "SW360ProjectName": "", diff --git a/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj b/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj index 84aab0c6..82dd43e2 100644 --- a/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj +++ b/src/LCT.CycloneDxProcessor/LCT.CycloneDxProcessor.csproj @@ -2,6 +2,7 @@ netstandard2.0 + 7.0.0 diff --git a/src/LCT.Facade/LCT.Facade.csproj b/src/LCT.Facade/LCT.Facade.csproj index 82d7907d..ece08d21 100644 --- a/src/LCT.Facade/LCT.Facade.csproj +++ b/src/LCT.Facade/LCT.Facade.csproj @@ -2,6 +2,7 @@ net8.0 + 7.0.0 diff --git a/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs b/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs index 3294a806..100169b2 100644 --- a/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs +++ b/src/LCT.PackageIdentifier.UTest/CycloneBomProcessorTests.cs @@ -39,8 +39,9 @@ public void SetMetadataInComparisonBOM_GivenBOMWithEmptyMetadata_FillsInMetadata { CaVersion = "1.2.3" }; + CatoolInfo caToolInformation = new CatoolInfo() { CatoolVersion = "6.0.0", CatoolRunningLocation="" }; //Act - Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases); + Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation); //Assert Assert.That(2, Is.EqualTo(files.Metadata.Tools.Count), "Returns bom with metadata "); @@ -92,9 +93,10 @@ public void SetMetadataInComparisonBOM_GivenBOMWithMetadata_AddsNewMetadataInfoI Version = projectReleases.Version, Type = Component.Classification.Application }; - + + CatoolInfo caToolInformation = new CatoolInfo() { CatoolVersion = "6.0.0", CatoolRunningLocation = "" }; //Act - Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases); + Bom files = CycloneBomProcessor.SetMetadataInComparisonBOM(bom, appSettings, projectReleases, caToolInformation); //Assert Assert.That(tools.Name, Is.EqualTo(files.Metadata.Tools[1].Name), "Returns bom with metadata tools"); diff --git a/src/LCT.PackageIdentifier/BomCreator.cs b/src/LCT.PackageIdentifier/BomCreator.cs index 3d79780f..a2a0666a 100644 --- a/src/LCT.PackageIdentifier/BomCreator.cs +++ b/src/LCT.PackageIdentifier/BomCreator.cs @@ -9,6 +9,7 @@ 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; @@ -16,7 +17,6 @@ using log4net.Core; using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Reflection; @@ -42,7 +42,11 @@ 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, + ProjectReleases projectReleases, + CatoolInfo caToolInformation) { Logger.Debug($"GenerateBom():Start"); Bom listOfComponentsToBom; @@ -56,7 +60,10 @@ public async Task GenerateBom(CommonAppSettings appSettings, IBomHelper bomHelpe //Get project details for metadata properties //sets metadata properties - listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, appSettings, projectReleases); + listOfComponentsToBom = CycloneBomProcessor.SetMetadataInComparisonBOM(listOfComponentsToBom, + appSettings, + projectReleases, + caToolInformation); // Writes Comparison Bom Logger.Logger.Log(null, Level.Notice, $"Writing CycloneDX BOM..", null); diff --git a/src/LCT.PackageIdentifier/CycloneBomProcessor.cs b/src/LCT.PackageIdentifier/CycloneBomProcessor.cs index 980b5ee8..2f601a1a 100644 --- a/src/LCT.PackageIdentifier/CycloneBomProcessor.cs +++ b/src/LCT.PackageIdentifier/CycloneBomProcessor.cs @@ -8,6 +8,7 @@ using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Constants; +using LCT.Common.Model; using log4net; using System.Collections.Generic; using System.Reflection; @@ -19,7 +20,10 @@ 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, + ProjectReleases projectReleases, + CatoolInfo caToolInformation) { Logger.Debug("Starting to add metadata info into the BOM"); List tools = new List(); @@ -28,7 +32,7 @@ public static Bom SetMetadataInComparisonBOM(Bom bom, CommonAppSettings appSetti Tool tool = new Tool { Name = "Clearing Automation Tool", - Version = appSettings.CaVersion, + Version = caToolInformation.CatoolVersion, Vendor = "Siemens AG", ExternalReferences = new List() { new ExternalReference { Url = "https://github.com/siemens/continuous-clearing", Type = ExternalReference.ExternalReferenceType.Website } } diff --git a/src/LCT.PackageIdentifier/Interface/IBomCreator.cs b/src/LCT.PackageIdentifier/Interface/IBomCreator.cs index bc865d30..4b1e02a8 100644 --- a/src/LCT.PackageIdentifier/Interface/IBomCreator.cs +++ b/src/LCT.PackageIdentifier/Interface/IBomCreator.cs @@ -7,6 +7,7 @@ using LCT.APICommunications.Model; using LCT.Common; using LCT.Common.Interface; +using LCT.Common.Model; using LCT.Services.Interface; using System.Threading.Tasks; @@ -21,7 +22,8 @@ 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, + ProjectReleases projectReleases, CatoolInfo caToolInformation); public Task CheckJFrogConnection(); } diff --git a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj index 836cc7e8..377bcbd7 100644 --- a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj +++ b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj @@ -4,6 +4,7 @@ Exe net8.0 PackageIdentifier + 7.0.0 diff --git a/src/LCT.PackageIdentifier/Program.cs b/src/LCT.PackageIdentifier/Program.cs index 742e11a6..34af2638 100644 --- a/src/LCT.PackageIdentifier/Program.cs +++ b/src/LCT.PackageIdentifier/Program.cs @@ -53,6 +53,7 @@ static async Task Main(string[] args) ProjectReleases projectReleases = new ProjectReleases(); string FolderPath = LogFolderInitialisation(appSettings); + CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile(); settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer"); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package Identifier >>>>>====================", null); @@ -78,6 +79,8 @@ static async Task Main(string[] args) } Logger.Logger.Log(null, Level.Notice, $"Input Parameters used in Package Identifier:\n\t" + + $"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" + + $"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" + $"PackageFilePath\t\t --> {appSettings.PackageFilePath}\n\t" + $"BomFolderPath\t\t --> {appSettings.BomFolderPath}\n\t" + $"SBOMTemplateFilePath\t --> {appSettings.CycloneDxSBomTemplatePath}\n\t" + @@ -104,11 +107,21 @@ 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(), projectReleases, + caToolInformation); } Logger.Logger.Log(null, Level.Notice, $"End of Package Identifier execution : {DateTime.Now}\n", null); } + private static CatoolInfo GetCatoolVersionFromProjectfile() + { + CatoolInfo catoolInfo = new CatoolInfo(); + var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version; + catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}"; + catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + return catoolInfo; + } + private static IJFrogService GetJfrogService(CommonAppSettings appSettings) { ArtifactoryCredentials artifactoryUpload = new ArtifactoryCredentials() diff --git a/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj b/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj index 049a9158..76ccd598 100644 --- a/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj +++ b/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj @@ -4,6 +4,7 @@ Exe net8.0 SW360PackageCreator + 7.0.0 LCT.SW360PackageCreator diff --git a/src/LCT.SW360PackageCreator/Program.cs b/src/LCT.SW360PackageCreator/Program.cs index 25419dbb..7210b7ee 100644 --- a/src/LCT.SW360PackageCreator/Program.cs +++ b/src/LCT.SW360PackageCreator/Program.cs @@ -54,6 +54,7 @@ static async Task Main(string[] args) string FolderPath = InitiateLogger(appSettings); settingsManager.CheckRequiredArgsToRun(appSettings, "Creator"); await CreatorValidator.ValidateAppSettings(appSettings, sw360ProjectService, projectReleases); + CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile(); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package creator >>>>>====================", null); Logger.Logger.Log(null, Level.Notice, $"\nStart of Package creator execution : {DateTime.Now}", null); @@ -62,6 +63,8 @@ static async Task Main(string[] args) Logger.Logger.Log(null, Level.Alert, $"Package creator is running in TEST mode \n", null); Logger.Logger.Log(null, Level.Notice, $"Input parameters used in Package Creator:\n\t" + + $"CaToolVersion\t\t --> {caToolInformation.CatoolVersion}\n\t" + + $"CaToolRunningPath\t --> {caToolInformation.CatoolRunningLocation}\n\t" + $"BomFilePath\t\t --> {appSettings.BomFilePath}\n\t" + $"SW360Url\t\t --> {appSettings.SW360URL}\n\t" + $"SW360AuthTokenType\t --> {appSettings.SW360AuthTokenType}\n\t" + @@ -79,6 +82,15 @@ static async Task Main(string[] args) Logger.Logger.Log(null, Level.Notice, $"End of Package Creator execution: {DateTime.Now}\n", null); } + private static CatoolInfo GetCatoolVersionFromProjectfile() + { + CatoolInfo catoolInfo = new CatoolInfo(); + var versionFromProj = Assembly.GetExecutingAssembly().GetName().Version; + catoolInfo.CatoolVersion = $"{versionFromProj.Major}.{versionFromProj.Minor}.{versionFromProj.Build}"; + catoolInfo.CatoolRunningLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + return catoolInfo; + } + private static ISw360ProjectService Getsw360ProjectServiceObject(CommonAppSettings appSettings, out ISW360ApicommunicationFacade sW360ApicommunicationFacade) { ISw360ProjectService sw360ProjectService; diff --git a/src/LCT.Services/LCT.Services.csproj b/src/LCT.Services/LCT.Services.csproj index 55c5e361..4bf8da3e 100644 --- a/src/LCT.Services/LCT.Services.csproj +++ b/src/LCT.Services/LCT.Services.csproj @@ -3,6 +3,7 @@ Library net8.0 + 7.0.0