Resolve CA5389

This commit is contained in:
JustArchi 2021-05-07 22:57:59 +02:00
parent 89d41e7cb3
commit 69a12fadcf
2 changed files with 5 additions and 2 deletions

View file

@ -115,7 +115,6 @@ dotnet_diagnostic.ca1028.severity = silent
dotnet_diagnostic.ca1031.severity = silent
# TODO - one at a time
dotnet_diagnostic.ca5389.severity = silent
dotnet_diagnostic.ca5392.severity = silent
dotnet_diagnostic.ca5394.severity = silent

View file

@ -1004,7 +1004,11 @@ namespace ArchiSteamFarm {
// Now enumerate over files in the zip archive, skip directory entries that we're not interested in (we can create them ourselves if needed)
foreach (ZipArchiveEntry zipFile in archive.Entries.Where(zipFile => !string.IsNullOrEmpty(zipFile.Name))) {
string file = Path.Combine(targetDirectory, zipFile.FullName);
string file = Path.GetFullPath(Path.Combine(targetDirectory, zipFile.FullName));
if (!file.StartsWith(targetDirectory, StringComparison.Ordinal)) {
throw new InvalidOperationException(nameof(file));
}
if (File.Exists(file)) {
// This is possible only with files that we decided to leave in place during our backup function