Skip to content

Commit

Permalink
Merge pull request #153 from siemens/Bugfix_for_nuget
Browse files Browse the repository at this point in the history
Bug fix for  components count mismatch.
  • Loading branch information
sumanthkb44 authored Apr 18, 2024
2 parents 0f8baff + f09e95f commit 456e3d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
$sourceFolder = Join-Path $env:GITHUB_WORKSPACE "out" | Join-Path -ChildPath "*"
$outFolder = Join-Path $env:GITHUB_WORKSPACE "out" | Join-Path -ChildPath "continuous-clearing"
New-Item -ItemType Directory -Force -Path $outFolder
$fileName = "continuous-clearing-v6.1.0.zip"
$fileName = "continuous-clearing-v6.2.0.zip"
Write-Host "Filename: '$fileName'"
Write-Host "sourceFolder: '$sourceFolder'"
Write-Host "Outfolder: '$outFolder'"
Expand Down Expand Up @@ -139,8 +139,8 @@ jobs:
- name: Create Nuget Packages
id: createNupkg
run: |
nuget pack CA.nuspec -Version 6.1.0
Write-Host "::set-output name=nupkg-LicenseClearingTool::continuous-clearing.6.1.0.nupkg"
nuget pack CA.nuspec -Version 6.2.0
Write-Host "::set-output name=nupkg-LicenseClearingTool::continuous-clearing.6.2.0.nupkg"
- name: Archive NuGet Packages
uses: actions/upload-artifact@v2
Expand All @@ -153,9 +153,9 @@ jobs:
id: builddocker
#if: ${{ false }} # disable for now
run: |
docker build . --file Dockerfile --tag ${{ github.repository }}:continuous-clearing-v6.1.0
docker save ${{ github.repository }}:continuous-clearing-v6.1.0 -o continuous-clearing-v6.1.0.tar
Write-Host "::set-output name=docker-LicenseClearingTool::continuous-clearing-v6.1.0.tar"
docker build . --file Dockerfile --tag ${{ github.repository }}:continuous-clearing-v6.2.0
docker save ${{ github.repository }}:continuous-clearing-v6.2.0 -o continuous-clearing-v6.2.0.tar
Write-Host "::set-output name=docker-LicenseClearingTool::continuous-clearing-v6.2.0.tar"
- name: Archive docker image
#if: ${{ false }} # disable for now
Expand Down Expand Up @@ -196,8 +196,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v6.1.0
release_name: Release v6.1.0
tag_name: v6.2.0
release_name: Release v6.2.0
body: |
${{ github.event.head_commit.message }}
draft: true
Expand Down
25 changes: 10 additions & 15 deletions src/LCT.PackageIdentifier/NugetProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,14 @@ public Bom ParsePackageFile(CommonAppSettings appSettings)
{
Logger.Debug($"ParsePackageFile():Start");
List<Component> listComponentForBOM = new List<Component>();
Bom bom = new Bom();
int totalComponentsIdentified = 0;
Bom bom = new Bom();

ParsingInputFileForBOM(appSettings, ref listComponentForBOM, ref bom);
totalComponentsIdentified = listComponentForBOM.Count;

listComponentForBOM = listComponentForBOM.Distinct(new ComponentEqualityComparer()).ToList();
if (BomCreator.bomKpiData.DuplicateComponents == 0)
{
BomCreator.bomKpiData.DuplicateComponents = totalComponentsIdentified - listComponentForBOM.Count;
}

var componentsWithMultipleVersions = listComponentForBOM.GroupBy(s => s.Name)
.Where(g => g.Count() > 1).SelectMany(g => g).ToList();
var componentsWithMultipleVersions = bom.Components.GroupBy(s => s.Name).Where(g => g.Count() > 1).SelectMany(g => g).ToList();

CheckForMultipleVersions(appSettings, componentsWithMultipleVersions);

Logger.Debug($"ParsePackageFile():End");
bom.Components = listComponentForBOM;
return bom;
}

Expand Down Expand Up @@ -362,6 +351,7 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref List<Comp
List<string> configFiles;
List<Component> componentsForBOM = new List<Component>();
List<Dependency> dependencies = new List<Dependency>();
int totalComponentsIdentified = 0;

configFiles = FolderScanner.FileScanner(appSettings.PackageFilePath, appSettings.Nuget);

Expand Down Expand Up @@ -399,7 +389,13 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref List<Comp
}

BomCreator.bomKpiData.ComponentsinPackageLockJsonFile = listComponentForBOM.Count;
totalComponentsIdentified = listComponentForBOM.Count;
listComponentForBOM = KeepUniqueNonDevComponents(listComponentForBOM);
listComponentForBOM = listComponentForBOM.Distinct(new ComponentEqualityComparer()).ToList();
if (BomCreator.bomKpiData.DuplicateComponents == 0)
{
BomCreator.bomKpiData.DuplicateComponents = totalComponentsIdentified - listComponentForBOM.Count;
}
BomCreator.bomKpiData.DevDependentComponents = listComponentForBOM.Count(s => s.Properties[0].Value == "true");
bom.Components = listComponentForBOM;

Expand All @@ -411,9 +407,8 @@ private void ParsingInputFileForBOM(CommonAppSettings appSettings, ref List<Comp
CycloneDXBomParser.CheckValidComponentsForProjectType(templateDetails.Components, appSettings.ProjectType);
SbomTemplate.AddComponentDetails(bom.Components, templateDetails);
}

bom = RemoveExcludedComponents(appSettings, bom);

bom = RemoveExcludedComponents(appSettings, bom);
}

private static void ConvertToCycloneDXModel(List<Component> listComponentForBOM, List<NugetPackage> listofComponents, List<Dependency> dependencies)
Expand Down

0 comments on commit 456e3d0

Please sign in to comment.