fix(app): Explorer verifies every checksum file type Hash Tool reads

ShellIntegration kept its own list of extensions, which had drifted from the one the app reads: .sha384sum and .b3sum
had no "Verify with Hash Tool" entry. It now uses ChecksumFileNames.KnownExtensions, and since the entries are written
again at every start, existing installations pick them up. Tests keep the Core list, the algorithms' extensions and
the macOS document types in build/macos/Info.plist in step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 5.5 committed 2026-11-16 09:17:31 +07:00
1 parent 6c4cd062cc
commit ca9bf37fb4
5 files changed
+45 -6

No files matched your search

+1
View File
@@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
- Accessibility: when a file does not match, Verify shows the hash it really has under the expected one, in a box the keyboard and screen readers reach; before, it was only in a tooltip, which also ignored hash masking. The expected-hash box is announced as "Expected hash" instead of its placeholder text.
- Accessibility: the result of a run of one file (for example "photo.jpg: VALID") is announced by screen readers and shown at the top of the page; a run of several files still ends with the summary dialog.
- Accessibility: tooltips show shortcuts the macOS way (⌘O) on macOS, and screen readers announce the shortcuts of Add Files, Add Folder, Compute/Verify All, Cancel and the search box.
- Windows: the Explorer context menu offers "Verify with Hash Tool" for `.sha384sum` and `.b3sum` files too; the menu is updated the next time Hash Tool starts.
### Security
- Updated to the .NET 10.0.15 runtime, which the self-contained downloads include. It fixes denial of service and elevation of privilege vulnerabilities in .NET (CVE-2026-109475, CVE-2026-105544, CVE-2026-114155, CVE-2026-118747).
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HashTool.Core.Checksums;
using Microsoft.Win32;
namespace HashTool.App.Infrastructure;
@@ -16,12 +18,11 @@ public static partial class ShellIntegration
private const string VerifyVerb = "HashTool.Verify";
private const string OwnerValue = "HashToolOwner";
/// <summary>Checksum file types that get "Verify with Hash Tool".</summary>
private static readonly string[] ChecksumExtensions =
[
".md5", ".sha1", ".sha256", ".sha384", ".sha512", ".sfv", ".b3", ".blake3", ".crc32", ".xxh32", ".xxh64", ".xxh3",
".xxh128", ".xxhash32", ".xxhash64", ".xxhash3", ".xxhash128", ".md5sum", ".sha1sum", ".sha256sum", ".sha512sum"
];
/// <summary>
/// Checksum file types that get "Verify with Hash Tool": every type Hash Tool reads. The entries are written again at
/// each start (see SettingsViewModel.RefreshShellIntegration), so new types reach existing installations.
/// </summary>
private static IReadOnlyList<string> ChecksumExtensions => ChecksumFileNames.KnownExtensions;
public static bool IsSupported => OperatingSystem.IsWindows();
@@ -2,6 +2,7 @@ using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using HashTool.Core.Hashing;
namespace HashTool.Core.Checksums;
@@ -36,6 +37,12 @@ public static class ChecksumFileNames
[".sfv"] = HashType.CRC32
}.ToFrozenDictionary(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Every checksum file extension Hash Tool recognises (with the dot). The Windows context menu and the macOS
/// document types (build/macos/Info.plist) offer "Verify" for exactly these.
/// </summary>
public static IReadOnlyList<string> KnownExtensions { get; } = [.. Extensions.Keys.Order(StringComparer.Ordinal)];
private static readonly FrozenDictionary<string, HashType?> WellKnownNames = new Dictionary<string, HashType?>(StringComparer.OrdinalIgnoreCase)
{
["MD5SUMS"] = HashType.MD5,
+17
View File
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Text.Json;
using HashTool.App.Infrastructure;
using HashTool.App.Infrastructure.Logging;
@@ -126,3 +127,19 @@ public sealed class TextHelperTests
Assert.Equal("08:30:05.123 [WARN] Test: message", entry.ToString());
}
}
public sealed class PackagingTests
{
[Fact]
public void MacOSDocumentTypes_ListEveryChecksumExtension()
{
// Info.plist (build/macos) is kept by hand; Windows registers ChecksumFileNames.KnownExtensions directly.
var plist = System.Xml.Linq.XDocument.Load(Path.Combine(RepositoryFiles.Root, "build", "macos", "Info.plist"));
var declared = plist.Descendants("key")
.Where(k => k.Value == "CFBundleTypeExtensions")
.SelectMany(k => ((System.Xml.Linq.XElement)k.NextNode!).Elements("string").Select(e => "." + e.Value))
.Order(StringComparer.Ordinal);
Assert.Equal(HashTool.Core.Checksums.ChecksumFileNames.KnownExtensions.Order(StringComparer.Ordinal), declared);
}
}
@@ -23,6 +23,19 @@ public sealed class ChecksumFileNamesTests
Assert.Equal(expected, algorithm);
}
[Fact]
public void KnownExtensions_CoverEveryAlgorithm_AndAreAllRecognised()
{
Assert.All(HashAlgorithms.All, a => Assert.Contains("." + HashAlgorithms.FileExtension(a), ChecksumFileNames.KnownExtensions));
Assert.All(ChecksumFileNames.KnownExtensions, e =>
{
Assert.StartsWith(".", e, System.StringComparison.Ordinal);
Assert.True(ChecksumFileNames.IsChecksumFile("file" + e, out _), e);
});
Assert.Contains(".sha384sum", ChecksumFileNames.KnownExtensions);
Assert.Contains(".b3sum", ChecksumFileNames.KnownExtensions);
}
[Fact]
public void GenericChecksumsFile_HasNoAlgorithmHint()
{