Skip to content

Commit 4d5f9ff

Browse files
committed
Update .gitignore, enhance file extraction validation, and upgrade Newtonsoft.Json package
1 parent 91f4959 commit 4d5f9ff

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/Application/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## Ignore Visual Studio temporary files, build results, and
22
## files generated by popular Visual Studio add-ons.
33

4+
# Local configuration file for developers
5+
src/Application/src/RazorPagesTestSample/config.json
6+
47
# User-specific files
58
*.suo
69
*.user

src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ public async Task<IActionResult> OnPostAnalyzeMessagesAsync()
9595
public static void WriteToDirectory(ZipArchiveEntry entry, string destDirectory)
9696
{
9797
string destFileName = Path.Combine(destDirectory, entry.FullName);
98+
99+
// Ensure the destination file is within the destination directory
100+
if (!destFileName.StartsWith(destDirectory, StringComparison.OrdinalIgnoreCase))
101+
{
102+
throw new InvalidOperationException("Entry is outside the target dir: " + entry.FullName);
103+
}
104+
98105
entry.ExtractToFile(destFileName);
99106
}
100107
}

src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
1515
<PackageReference Include="Moq" Version="4.20.70" />
16-
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
16+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1717
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
1818
<PackageReference Include="System.Net.Http" Version="4.3.4" />
1919
<PackageReference Include="xunit" Version="2.7.0" />

0 commit comments

Comments
 (0)