From 494cb35493ad56332cb30070d9ec9e1b794c6c2e Mon Sep 17 00:00:00 2001 From: Chalapala RaghavendraReddy Date: Fri, 12 Jul 2024 13:05:33 +0530 Subject: [PATCH 1/2] Version Added in project file --- .../LCT.ArtifactoryUploader.csproj | 1 + src/ArtifactoryUploader/Program.cs | 13 ++++++++++++ .../LCT.APICommunications.csproj | 1 + src/LCT.Common/LCT.Common.csproj | 1 + src/LCT.Common/Model/CatoolInfo.cs | 16 +++++++++++++++ .../LCT.CycloneDxProcessor.csproj | 1 + src/LCT.Facade/LCT.Facade.csproj | 1 + src/LCT.PackageIdentifier/BomCreator.cs | 5 +++-- .../CycloneBomProcessor.cs | 5 +++-- .../Interface/IBomCreator.cs | 3 ++- .../LCT.PackageIdentifier.csproj | 3 ++- src/LCT.PackageIdentifier/Program.cs | 20 ++++++++++++++----- .../LCT.SW360PackageCreator.csproj | 1 + src/LCT.SW360PackageCreator/Program.cs | 12 +++++++++++ src/LCT.Services/LCT.Services.csproj | 1 + 15 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 src/LCT.Common/Model/CatoolInfo.cs diff --git a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj index 4067f290..041c5b20 100644 --- a/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj +++ b/src/ArtifactoryUploader/LCT.ArtifactoryUploader.csproj @@ -4,6 +4,7 @@ Exe net6.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 21e6fe9d..59de2127 100644 --- a/src/LCT.APICommunications/LCT.APICommunications.csproj +++ b/src/LCT.APICommunications/LCT.APICommunications.csproj @@ -3,6 +3,7 @@ Library net6.0 + 7.0.0 diff --git a/src/LCT.Common/LCT.Common.csproj b/src/LCT.Common/LCT.Common.csproj index ef880ba2..6ca411bf 100644 --- a/src/LCT.Common/LCT.Common.csproj +++ b/src/LCT.Common/LCT.Common.csproj @@ -3,6 +3,7 @@ Library net6.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..e3fee6db --- /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; } + } +} 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 f5b5854e..0427a28e 100644 --- a/src/LCT.Facade/LCT.Facade.csproj +++ b/src/LCT.Facade/LCT.Facade.csproj @@ -2,6 +2,7 @@ net6.0 + 7.0.0 diff --git a/src/LCT.PackageIdentifier/BomCreator.cs b/src/LCT.PackageIdentifier/BomCreator.cs index ed578b6e..1db621bb 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; @@ -41,7 +42,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, ProjectReleases projectReleases, CatoolInfo caToolInformation) { Logger.Debug($"GenerateBom():Start"); Bom listOfComponentsToBom; @@ -55,7 +56,7 @@ 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 5de4ef48..4c6b928f 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 NuGet.Packaging.Signing; using System; @@ -24,7 +25,7 @@ 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(); @@ -33,7 +34,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..63135f30 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,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, ProjectReleases projectReleases,CatoolInfo caToolVersion); public Task CheckJFrogConnection(); } diff --git a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj index 4182228e..a8a4457c 100644 --- a/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj +++ b/src/LCT.PackageIdentifier/LCT.PackageIdentifier.csproj @@ -3,7 +3,8 @@ Exe net6.0 - PackageIdentifier + PackageIdentifier + 7.0.0 diff --git a/src/LCT.PackageIdentifier/Program.cs b/src/LCT.PackageIdentifier/Program.cs index ea734e55..459a97e8 100644 --- a/src/LCT.PackageIdentifier/Program.cs +++ b/src/LCT.PackageIdentifier/Program.cs @@ -42,7 +42,7 @@ public class Program protected Program() { } static async Task Main(string[] args) - { + { BomStopWatch = new Stopwatch(); BomStopWatch.Start(); @@ -52,9 +52,8 @@ static async Task Main(string[] args) CommonAppSettings appSettings = settingsManager.ReadConfiguration(args, FileConstant.appSettingFileName); ProjectReleases projectReleases = new ProjectReleases(); string FolderPath = LogFolderInitialisation(appSettings); - - settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer"); - + CatoolInfo caToolInformation = GetCatoolVersionFromProjectfile(); + settingsManager.CheckRequiredArgsToRun(appSettings, "Identifer"); Logger.Logger.Log(null, Level.Notice, $"\n====================<<<<< Package Identifier >>>>>====================", null); Logger.Logger.Log(null, Level.Notice, $"\nStart of Package Identifier execution: {DateTime.Now}", null); @@ -78,6 +77,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 +105,20 @@ 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 af3142d1..26c35b5e 100644 --- a/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj +++ b/src/LCT.SW360PackageCreator/LCT.SW360PackageCreator.csproj @@ -5,6 +5,7 @@ net6.0 SW360PackageCreator LCT.SW360PackageCreator + 7.0.0 diff --git a/src/LCT.SW360PackageCreator/Program.cs b/src/LCT.SW360PackageCreator/Program.cs index 25419dbb..e5225f46 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 3e27f8c0..d56afdad 100644 --- a/src/LCT.Services/LCT.Services.csproj +++ b/src/LCT.Services/LCT.Services.csproj @@ -3,6 +3,7 @@ Library net6.0 + 7.0.0 From 967f32b71b94de24f170134197d5ed161192c685 Mon Sep 17 00:00:00 2001 From: Chalapala RaghavendraReddy Date: Fri, 12 Jul 2024 13:56:53 +0530 Subject: [PATCH 2/2] updated review comments --- doc/UsageDoc/CA_UsageDocument.md | 2 +- src/LCT.Common/appSettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/UsageDoc/CA_UsageDocument.md b/doc/UsageDoc/CA_UsageDocument.md index edbe1bd3..76278e89 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/LCT.Common/appSettings.json b/src/LCT.Common/appSettings.json index 60dda338..f3aa2960 100644 --- a/src/LCT.Common/appSettings.json +++ b/src/LCT.Common/appSettings.json @@ -5,7 +5,7 @@ // -------------------------------------------------------------------------------------------------------------------- { - "CaVersion": "6.1.0", + "CaVersion": "", "TimeOut": 200, "ProjectType": "", "SW360ProjectName": "",