Skip to content

Commit 597f959

Browse files
authored
Merge pull request #1 from I-RzR-I/feature/UpgradeReferencePackages
Update reference package version, fixing CVE
2 parents 205a0fc + 3301c12 commit 597f959

File tree

5 files changed

+281
-9
lines changed

5 files changed

+281
-9
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022-2023 RzR
3+
Copyright (c) 2022-2024 RzR
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

build/pack-repo.ps1

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
Param
2+
(
3+
[Parameter(Mandatory = $false)]
4+
[string]$ownVersion,
5+
[Parameter(Mandatory = $false)]
6+
[bool]$runTest
7+
);
8+
9+
$assemblyPath = "..\src\shared\GeneralAssemblyInfo.cs";
10+
$defaultVersion = "1.0.0.0";
11+
$nugetPath = "../nuget";
12+
$data = ("..\src\ItemDistribution\ItemDistribution.csproj");
13+
$testExec = $false;
14+
15+
<#
16+
.SYNOPSIS
17+
A brief description of the Get-CurrentAssemblyVersion function.
18+
19+
.DESCRIPTION
20+
Get current assembly version
21+
22+
.EXAMPLE
23+
PS C:\> Get-CurrentAssemblyVersion
24+
25+
.NOTES
26+
Additional information about the function.
27+
#>
28+
function Get-CurrentAssemblyVersion
29+
{
30+
[OutputType([string])]
31+
param ()
32+
33+
$assemblyInfo = (Get-Content $assemblyPath);
34+
$asVersion = ($assemblyInfo -match 'AssemblyVersion\(".*"\)');
35+
$asVersion = $asVersion -split ('"');
36+
$asVersion = $asVersion[1];
37+
38+
return $asVersion;
39+
}
40+
41+
<#
42+
.SYNOPSIS
43+
A brief description of the Build-And-Pack-BuildPack function.
44+
45+
.DESCRIPTION
46+
Build project and pack as package (u pkg)
47+
48+
.PARAMETER packVersion
49+
Package/Build version
50+
51+
.PARAMETER currentVersion
52+
A description of the currentVersion parameter.
53+
54+
.EXAMPLE
55+
PS C:\> Build-And-Pack-BuildPack -packVersion 'Value1'
56+
57+
.NOTES
58+
Additional information about the function.
59+
#>
60+
function Set-BuildAndPack
61+
{
62+
[CmdletBinding()]
63+
[OutputType([bool])]
64+
param
65+
(
66+
[Parameter(Mandatory = $true)]
67+
[string]$packVersion,
68+
[string]$currentVersion
69+
)
70+
71+
try
72+
{
73+
Write-Host "Project restore '$($_)'!" -ForegroundColor Green;
74+
dotnet restore $($_);
75+
76+
Write-Host "Build in Release '$($_)'!" -ForegroundColor Green;
77+
$buildResult = dotnet build $($_) --source https://api.nuget.org/v3/index.json -c Release /p:AssemblyVersion=$packVersion /p:AssemblyFileVersion=$packVersion /p:AssemblyInformationalVersion=$packVersion;
78+
if ($LASTEXITCODE -ne 0)
79+
{
80+
Set-VersionAssembly -packVersion $currentVersion;
81+
Write-Host $buildResult;
82+
83+
return $false;
84+
}
85+
86+
Write-Host "Pack in Release '$($_)'!" -ForegroundColor Green;
87+
$packResult = dotnet pack $($_) -p:PackageVersion=$packVersion --no-build -c Release --output $nugetPath;
88+
if ($LASTEXITCODE -ne 0)
89+
{
90+
Set-VersionAssembly -packVersion $currentVersion;
91+
Write-Host $buildResult;
92+
93+
return $false;
94+
}
95+
96+
return $true;
97+
}
98+
catch
99+
{
100+
Write-Host -foregroundcolor Red "An error occurred: $_"
101+
102+
return $false;
103+
}
104+
}
105+
106+
<#
107+
.SYNOPSIS
108+
A brief description of the Get-TimeStamp function.
109+
110+
.DESCRIPTION
111+
Get time stamp version
112+
113+
.EXAMPLE
114+
PS C:\> Get-TimeStamp
115+
116+
.NOTES
117+
Additional information about the function.
118+
#>
119+
function Get-TimeStamp
120+
{
121+
[CmdletBinding()]
122+
[OutputType([int])]
123+
param ()
124+
125+
$current = [System.DateTime]::Now;
126+
$end = [System.DateTime]::Now.Date;
127+
$diff = (New-TimeSpan -Start $current -End $end).TotalSeconds / 10;
128+
$timeSec = If ($diff -le 0) { $diff * -1 }
129+
Else { $diff };
130+
131+
return [int]$timeSec;
132+
}
133+
134+
<#
135+
.SYNOPSIS
136+
A brief description of the Set-VersionAssembly function.
137+
138+
.DESCRIPTION
139+
Set current version in assembly file
140+
141+
.PARAMETER packVersion
142+
A description of the packVersion parameter.
143+
144+
.EXAMPLE
145+
PS C:\> Set-VersionAssembly -packVersion 'Value1'
146+
147+
.NOTES
148+
Additional information about the function.
149+
#>
150+
function Set-VersionAssembly
151+
{
152+
[CmdletBinding()]
153+
[OutputType([void])]
154+
param
155+
(
156+
[Parameter(Mandatory = $true)]
157+
[string]$packVersion
158+
)
159+
$NewVersion = 'AssemblyVersion("' + $packVersion + '")';
160+
$NewFileVersion = 'AssemblyFileVersion("' + $packVersion + '")';
161+
$NewAssemblyInformationalVersion = 'AssemblyInformationalVersion("' + $packVersion + '")';
162+
163+
(Get-Content $assemblyPath -encoding utf8) |
164+
%{ $_ -replace 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewVersion } |
165+
%{ $_ -replace 'AssemblyFileVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)', $NewFileVersion } |
166+
%{ $_ -replace 'AssemblyInformationalVersion\("[0-9x]+(\.([0-9x]+|\*)){1,3}"\)', $NewAssemblyInformationalVersion } |
167+
Set-Content $assemblyPath -encoding utf8
168+
}
169+
170+
<#
171+
.SYNOPSIS
172+
A brief description of the Exec-TestSolution function.
173+
174+
.DESCRIPTION
175+
Execute solution test
176+
177+
.EXAMPLE
178+
PS C:\> Exec-TestSolution
179+
180+
.NOTES
181+
Additional information about the function.
182+
#>
183+
function Exec-TestSolution
184+
{
185+
[CmdletBinding()]
186+
[OutputType([bool])]
187+
param ()
188+
189+
# Merge all streams into stdout
190+
#$result = dotnet test "..\src\tests\*.csproj" *>&1
191+
192+
#No test
193+
return $true;
194+
195+
# Evaluate success/failure
196+
if ($LASTEXITCODE -eq 0)
197+
{
198+
return $true;
199+
}
200+
else
201+
{
202+
$errorString = $result -join [System.Environment]::NewLine;
203+
Write-Host -foregroundcolor Red "An error occurred: $errorString";
204+
205+
return $false;
206+
}
207+
}
208+
209+
If ($runTest -eq $true)
210+
{
211+
Write-Host "Init test solution...`n" -ForegroundColor Green;
212+
$testExec = Exec-TestSolution;
213+
}
214+
Else { $testExec = $true; }
215+
216+
If ($testExec -eq $true)
217+
{
218+
Write-Host "Path to pack: '$nugetPath'`n" -ForegroundColor Green;
219+
220+
$currentVersion = "";
221+
If ($ownVersion -eq $null -or $ownVersion -eq "") { $currentVersion = Get-CurrentAssemblyVersion; }
222+
Else { $currentVersion = $ownVersion; }
223+
224+
$directoryInfo = Get-ChildItem $nugetPath | Where-Object { $_.Name -match '[a-z]*.1.0.0.nupkg$' } | Measure-Object;
225+
If ($defaultVersion -eq $currentVersion -and $directoryInfo.count -eq 0)
226+
{
227+
Set-VersionAssembly -packVersion $currentVersion;
228+
229+
$data | ForEach-Object {
230+
$buildResult = Set-BuildAndPack -packVersion $currentVersion;
231+
If ($buildResult -eq $false -or $buildResult -contains $false)
232+
{
233+
Write-Host "`nBuild/pack failed!!!" -ForegroundColor Red;
234+
235+
exit;
236+
}
237+
}
238+
239+
Write-Host "`nPack executed with success with version: $currentVersion!" -ForegroundColor Green;
240+
241+
exit;
242+
}
243+
Else
244+
{
245+
$finalVersion = "";
246+
If ($ownVersion -eq $null -or $ownVersion -eq "")
247+
{
248+
$versArray = $currentVersion.Split('.');
249+
$finalVersion = $versArray[0].ToString() + "." + $versArray[1].ToString() + "." + (([int]$versArray[2]) + 1).ToString() + "." + (Get-TimeStamp).ToString();
250+
}
251+
Else { $finalVersion = $ownVersion; }
252+
253+
Set-VersionAssembly -packVersion $finalVersion;
254+
255+
$data | ForEach-Object {
256+
$buildResult = Set-BuildAndPack -packVersion $finalVersion -currentVersion $currentVersion;
257+
If ($buildResult -eq $false -or $buildResult -contains $false)
258+
{
259+
Write-Host "`nBuild/pack failed!!!" -ForegroundColor Red;
260+
261+
exit;
262+
}
263+
}
264+
265+
Write-Host "`nPack executed with success with version: $finalVersion!" -ForegroundColor Green;
266+
267+
exit;
268+
}
269+
}
270+
Else { exit; }

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### **v1.1.0.0**
2+
-> Update reference package version, fixing CVE (`CVE-2024-43485`).

src/ItemDistribution/ItemDistribution.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<!--<TargetFramework>netstandard2.0</TargetFramework>-->
55
<TargetFrameworks>net45;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
66
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
77
<Authors>RzR</Authors>
@@ -50,7 +50,7 @@
5050
</ItemGroup>
5151

5252
<ItemGroup>
53-
<PackageReference Include="AggregatedGenericResultMessage" Version="1.2.1" />
53+
<PackageReference Include="AggregatedGenericResultMessage" Version="1.3.4.6865" />
5454
</ItemGroup>
5555

5656
<ProjectExtensions>
@@ -59,7 +59,7 @@
5959
</VisualStudio>
6060
</ProjectExtensions>
6161

62-
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
62+
<!--<Target Name="PostBuild" AfterTargets="PostBuildEvent">
6363
<Exec Command="PowerShell -NoProfile -ExecutionPolicy unrestricted -file $(SolutionDir)../build/pack.ps1 $(ConfigurationName)" />
64-
</Target>
64+
</Target>-->
6565
</Project>

src/shared/GeneralAssemblyInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
[assembly: AssemblyCompany("RzR ®")]
3131
[assembly: AssemblyProduct("")]
32-
[assembly: AssemblyCopyright("Copyright © 2022-2023 RzR All rights reserved.")]
32+
[assembly: AssemblyCopyright("Copyright © 2022-2024 RzR All rights reserved.")]
3333
[assembly: AssemblyTrademark("® RzR™")]
3434
[assembly: AssemblyDescription("An item/document distribution suggestion based on user load calculation.")]
3535

@@ -39,6 +39,6 @@
3939
[assembly: AssemblyMetadata("ContactEmail", "ddpRzR@hotmail.com")]
4040
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
4141

42-
[assembly: AssemblyVersion("1.0.0.0")]
43-
[assembly: AssemblyFileVersion("1.0.0.0")]
44-
[assembly: AssemblyInformationalVersion("1.0.0.x")]
42+
[assembly: AssemblyVersion("1.1.0.0")]
43+
[assembly: AssemblyFileVersion("1.1.0.0")]
44+
[assembly: AssemblyInformationalVersion("1.1.0.0")]

0 commit comments

Comments
 (0)