diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b7e04..df8fb0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/src/HashTool.App/Infrastructure/ShellIntegration.cs b/src/HashTool.App/Infrastructure/ShellIntegration.cs index d942df0..ccbf88a 100644 --- a/src/HashTool.App/Infrastructure/ShellIntegration.cs +++ b/src/HashTool.App/Infrastructure/ShellIntegration.cs @@ -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"; - /// Checksum file types that get "Verify with Hash Tool". - 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" - ]; + /// + /// 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. + /// + private static IReadOnlyList ChecksumExtensions => ChecksumFileNames.KnownExtensions; public static bool IsSupported => OperatingSystem.IsWindows(); diff --git a/src/HashTool.Core/Checksums/ChecksumFileNames.cs b/src/HashTool.Core/Checksums/ChecksumFileNames.cs index c250400..74061c7 100644 --- a/src/HashTool.Core/Checksums/ChecksumFileNames.cs +++ b/src/HashTool.Core/Checksums/ChecksumFileNames.cs @@ -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); + /// + /// 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. + /// + public static IReadOnlyList KnownExtensions { get; } = [.. Extensions.Keys.Order(StringComparer.Ordinal)]; + private static readonly FrozenDictionary WellKnownNames = new Dictionary(StringComparer.OrdinalIgnoreCase) { ["MD5SUMS"] = HashType.MD5, diff --git a/tests/HashTool.App.Tests/UnitTests.cs b/tests/HashTool.App.Tests/UnitTests.cs index deabf51..b4ac28f 100644 --- a/tests/HashTool.App.Tests/UnitTests.cs +++ b/tests/HashTool.App.Tests/UnitTests.cs @@ -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); + } +} diff --git a/tests/HashTool.Core.Tests/Checksums/ChecksumFileNamesTests.cs b/tests/HashTool.Core.Tests/Checksums/ChecksumFileNamesTests.cs index 039a807..724369c 100644 --- a/tests/HashTool.Core.Tests/Checksums/ChecksumFileNamesTests.cs +++ b/tests/HashTool.Core.Tests/Checksums/ChecksumFileNamesTests.cs @@ -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() {