Repository navigation
Fix 120 correctness and security defects in Rust and C# (12 waves) - #68
Merged
Marc-André Moreau (mamoreau-devolutions) merged 5 commits intoNov 8, 2026
Conversation
Two rounds of audits across six areas each found defects in the Rust and
C# implementations; each wave fixed 10 of them on both sides so the two
stay aligned, with tests in per-wave test files (wave{N}_tests.rs,
wave{N}_cli_tests.rs, Wave{N}DefectTests.cs). WinGet behavior was
checked against the upstream winget-cli sources.
Wave 1 - installer execution: InstallerSuccessCodes/ExpectedReturnCodes
and 3010 reboot codes; exact ARP hive/view on uninstall; safe download
file names; C# cmd /S /C quoting; --all-versions keeps first failure;
--uninstall-previous targets the installed match; NSIS /D= last and
unquoted; portable --preserve unregisters; missing hash requires
--ignore-security-hash; case-insensitive switch templates.
Wave 2 - sources: REST single search uses Inclusions; direct-mode refresh
does not save; Cache-Control max-age clamped; sources.json camelCase in
Rust; C# exact single REST lookup; source update continues and saves;
LIKE wildcards escaped; C# case-insensitive source remove; Rust updates
explicit sources; C# case-insensitive version/channel selection.
Wave 3 - pins, correlation, settings: Pinning blocks upgrade --all;
pin add --version creates Gating; gating checks on named upgrade with
part-wise version compare; settings JSON with comments/BOM; --source is
not a filter; registry string trimming; all pins loaded; MSIX family
name without resource id; loose correlation rules; per-key MSIX scan.
Wave 4 - manifests/selection: multi-file --manifest directories;
installer-level dependencies in C#; installer selected before
dependencies; dependency cycles stopped; singleton structured output;
MinimumOSVersion padding; --locale filters; leading 'v' versions;
full upgrade compatibility check; Windows.Universal on desktop.
Wave 5 - CLI: C# YAML quotes non-string scalars; shared WinGet HRESULT
table; error input parsing; non-zero exits on error paths and named
upgrade with no target; streamed lowercase hash and Rust --msix;
--count 1..1000; C# import parsing and dry-run search; PowerShell NoOp
status; C# pin list structured output.
Wave 6 - publisher: lowercase correlation values; serde_json-compatible
canonical JSON in C#; BOM stripping; serde_yaml scalar typing in C#;
WinGet identifier rule; Windows-unsafe names rejected; Rust MSIX
version normalization; stale publish temporaries cleaned; mixed
ManifestVersion rejected; Rust requires Publisher.
Wave 7 - portable/archives: tracked-file uninstall unless --purge;
upgrade keeps user files; nested zip installers dispatched; absolute
System32 tool paths; MSI repair via msiexec /f; single manifest
resolution per install; links for every nested file; standalone alias
rules; x86 machine portables in WOW6432Node; no guessed exe switches.
Wave 8 - manifest model: download honors agreements and
DownloadCommandProhibited; Markets and UnsupportedOSArchitectures;
UpgradeBehavior; dependency MinimumVersion; full download manifest;
Upgrade switch; preferred-language locale ranking; C# show parity;
YAML parse parity; AppsAndFeaturesEntries correlation codes.
Wave 9 - sources/HTTP: index path traversal guard; https-only source
add; REST 204/404 as empty; case-insensitive single REST lookups; Rust
REST manifest cache removed and caches cleared on remove/reset;
packaged tombstones; V1 limit on packages; C# REST update refresh and
contract negotiation; packaged YAML round-trip; Rust URL encoding.
Wave 10 - installed/pins round 2: WinGet pinning.db schema; REST
installed.db correlation versions; Blocking/Gating with
--include-pinned; ARP version fallbacks; flags from the target version
entry; ARM architecture stripping; C# SOFTWARE suffix removed; C# keeps
ARP entries under Windows; real Windows directory; case-insensitive pin
source filters.
Wave 11 - CLI/PowerShell/COM: PowerShell scope mapping; WinGet common
flags; no truncation when redirected; C# UTF-8 output; PreIndexed
default source type; -MatchOption honored; RebootRequired surfaced;
real validate on both sides; Update-PingetPackage continues on failure;
Rust import BOM/UTF-16.
Wave 12 - publisher round 2: superseded-signature policy; interrupted
publish recovery with pendingCommit; casing-change refusal; effective
installers for ARP ranges and correlation; overlapping ARP ranges fail;
latest-version package ARP range; Unicode case collisions in Rust;
AppX name rule; empty PFX password in C#.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to be unused clippy -D warnings on ubuntu-latest flagged build_msi_repair_arguments, determine_portable_alias, wave4's DEPENDENCY_MANIFEST_HEADER and wave7's std::io::Write import, which are only reached from Windows-gated code. Use the existing cfg_attr(not(windows), allow(...)) pattern. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…raries (Rust + C#) #2 verify/publish after a kill mid package-swap: Rust stages the package under --state and writes .source2.*.new only after the pendingCommit marker; verify ignores root swap temporaries (.source2.*.new, source2.msix.<guid>.tmp, legacy .publish-<build>.staging) only while pendingCommit is set and marker write temporaries always (both sides); next publish removes them; real-interruption tests via commit-step hooks (review_b_tests.rs, ReviewFixesBTests.cs); contract.md updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ty, portable registry/directories (Rust + C#) #4 Pins: null/None = no source filter and "" = the source-less pin in C# PinStore.List/Remove/Reset (as in Rust); pin remove --installed uses the same source key as pin add --installed on both sides; Add/add_pin replace a case-variant id/source row in one transaction (WinGet's pin_index kept). #6 Source cache paths: validated_source_relative_segments/ValidatedSourceRelativeSegments require Windows-safe segments (is_safe_file_name/IsSafeFileName) and reject '#'; sanitize_path_segment/SanitizePathSegment replace control chars, trim trailing dots/spaces after replacement, and prefix unsafe names with '_' (falling back to '_'). #7 Portable: PingetPortableDirectories drops obsolete directories that the upgrade removed; portable registry read/remove use arp_uninstall_key_candidates/GetArpUninstallKeyCandidates; C# ARP scan no longer reads HKCU WOW6432Node (WinGet's ARPHelper treats HKCU as the shared x64 view, like Rust). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…L parity (Rust + C#) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Marc-André Moreau (mamoreau-devolutions)
merged commit Nov 8, 2026
7b756a3
into
master
14 checks passed
Marc-André Moreau (mamoreau-devolutions)
deleted the
claude/csharp-rust-defect-fixes-f36765
branch
November 8, 2026 15:24
Marc-André Moreau (mamoreau-devolutions)
added a commit
that referenced
this pull request
Nov 15, 2026
## Summary This PR fixes 100 defects in 10 waves of 10 (waves 13–22). It follows the 12 waves in #68. Each fix covers both Rust (`rust/`) and C# (`dotnet/`) wherever the feature exists in both, so the two implementations stay aligned. - **How the defects were found:** one area audit per wave. Behaviour was checked against the upstream `winget-cli` sources. Findings were dropped when WinGet behaves the same way. - **Tests:** each wave adds its own test files: `wave{N}_tests.rs`, `wave20_cli_tests.rs`, `wave22_com_tests.rs` and `Wave{N}DefectTests.cs`. Each wave can be reviewed on its own, and every defect test was checked to fail before its fix. - **History:** each wave is its own commit, merged into this branch, so `git log --first-parent` lists the waves. | Wave | Area | Highlights | |---|---|---| | 13 | Installer execution | Interactive ARP uninstall falls back to `QuietUninstallString`<br>A blank uninstall string is no longer reported as success<br>Per-mode switch merging now matches WinGet<br>`--uninstall-previous` applies only to updates<br>Downloaded installers are deleted after a successful install<br>An MSIX uninstall can no longer run a same-named ARP uninstaller | | 14 | Pre-indexed sources and settings | An empty `winget source export` no longer breaks loading<br>The mirror cache keys on identifier + URL and repairs itself when corrupt<br>`source update <identifier>` passes the source name to winget<br>A looping V1 `pathparts` chain no longer hangs<br>Packaged sources write `Identifier` and sort by Priority | | 15 | REST sources | `ContinuationToken` paging<br>Unsupported inclusions are dropped and unsupported filters fail the search<br>Null arrays in `/information` are tolerated<br>Ids and versions are trimmed<br>Empty switches are ignored<br>`no-store`/`no-cache` responses are not cached | | 16 | Search, versions, selection | `Latest` and `> x` versions sort correctly<br>Pre-indexed filters are combined with AND<br>Tag and command filters use the request's match type<br>WinGet's `IsFirstBetter` installer ranking (locale, scope, architecture, type)<br>Neutral architecture ranks last<br>REST truncation flag fixed | | 17 | Installed packages, correlation | Name normalization: NFKC, case folding (`ß`→`ss`), SAP lowercase, `@@` cut-off position<br>Architecture-qualified normalized names are looked up first<br>An older `installed.db` no longer breaks `list`<br>`list` matches PackageFamilyName, ProductCode, UpgradeCode and the catalog name<br>ARP entries with `ParentKeyName` are listed | | 18 | Manifests | A null installer key no longer wipes the root value<br>Root `ProductCode`, `PackageFamilyName` and `Nested*` are inherited only by matching installer types<br>Dependencies are trimmed and de-duplicated<br>`Localization` is preserved<br>The C# legacy MSZIP path has a size limit | | 19 | Portable installs and archives | Uninstall data is written under WinGet's registry value names (`TargetFullPath`, `SymlinkFullPath`, `SHA256`); the old pinget names are still read<br>`InstallDirectoryAddedToPath` is removed from PATH on uninstall<br>A failed install is rolled back<br>`COM¹`–`LPT³` device names are rejected<br>Archives with no or several nested installers are rejected | | 20 | CLI | The C# CLI now reports parse errors and handles `--help`<br>CJK and other wide characters are measured in display columns, and truncation uses `…`<br>`export` sorts and de-duplicates<br>`import` reads schema 1.0 `Id`<br>WinGet's exclusive and dependent argument rules are enforced<br>`hash` prints `InstallerSha256:`<br>Positional import/export file | | 21 | Publisher | `Agreement` and `AgreementLabel` are kept as strings<br>Per-installer `Commands` follow WinGet's rule<br>`norm_names2` includes the architecture variant<br>Index terms, names and monikers are trimmed<br>A relative `--psign-tool` path resolves correctly<br>A build recovers when a snapshot was removed<br>C# PackageLocale length limit | | 22 | PowerShell and COM | COM errors are reported, not a bare E_FAIL or a stale message<br>A named `ResetSource` no longer resets every source<br>Piped packages are targeted by id and source<br>`-MatchOption` is honoured<br>WinGet version comparison<br>Channel and identity properties are carried through<br>`RunTests.ps1` runs again | ## Reviewer notes: behaviour changes - **PowerShell agreements:** `Install-`, `Update-` and `Export-PingetPackage` now accept package agreements automatically, as WinGet's cmdlets do. - **Tag and command match type:** in a many-search, `--tag` and `--command` are now substring matches unless `--exact` is given (WinGet's `SearchSourceApplyFilters`). This reverses one assertion that wave 9 kept, in `wave9_tests.rs` and `Wave9DefectTests.cs`. - **ARP `ParentKeyName`:** `list` now shows these entries. WinGet's `ARPHelper` only skips `SystemComponent` entries. - **C# CLI argument parsing:** the C# CLI now rejects unknown options and invalid values it used to ignore. - **Installer cleanup:** downloaded installers are deleted after a successful install (WinGet's `RemoveInstaller`), and kept when the install fails. - **Merge note:** waves 15 and 16 both changed the REST search code. The merge keeps wave 15's `ContinuationToken` paging loop and wave 16's truncation rule: more than `MaximumResults` results, or a non-blank token. ## Validation - `cargo +nightly fmt` and `cargo clippy --workspace --tests -- -D warnings`: clean. - `cargo test --workspace`: all passed (core 471, cli 81 + 2, com 7, publisher 64 + 26 conformance). - `dotnet build dotnet/Devolutions.Pinget.slnx -c Release`: 0 errors. `dotnet format --verify-no-changes`: no changes. - Core.Tests: 814 passed, 1 skipped (an existing live test). - Publisher.Tests: 181/181 on 4 of 5 runs. The failing run hit an intermittent `IOException` ("file is being used by another process") in `Publish_And_VerifyDestination_RejectSignedMsixInUnsignedDevelopmentMode`; that test and the code it covers are unchanged. - `dotnet/tests/RunTests.ps1` under PowerShell 7: 13/13 passed. On the dev machine, Pester reported the container as failed because deleting its temp folder was denied (sandbox restriction). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes 120 defects in 12 waves of 10, in both the Rust (
rust/) and C# (dotnet/) implementations, so they stay aligned. It follows #66 and #67.winget-clisources.--architecture, RequireExplicitUpgrade still skipped with--include-pinned, and the portable-upgrade removal order.wave{N}_tests.rs,wave{N}_cli_tests.rs,wave{N}_com_tests.rsandWave{N}DefectTests.cs. Each wave is self-contained to review.InstallerSuccessCodes/ExpectedReturnCodesand 3010 (reboot-required) handledUninstall opens the exact ARP hive and view
Download file names taken from the URL are sanitized
A missing
InstallerSha256needs--ignore-security-hashNSIS
/D=is passed last and unquoted--uninstall-previousremoves the installed matchInclusions(servers AND theFilterslist)sources.jsonkeys now match between Rust and C#LIKE wildcards in user input are escaped
source updatecontinues past failures and saves the successesupgrade --allpin add --versioncreates a Gating pin, compared part by partSettings JSON may contain comments, trailing commas or a BOM
MSIX family names drop the resource id
--manifest <dir>loads every file of a multi-file manifestThe installer is selected before dependencies are installed
Dependency cycles stop
MinimumOSVersionpads missing parts with zerosA leading
vin a version is ignorederrorcommand uses WinGet's HRESULT table (fromAppInstallerErrors.h)C# YAML output quotes values like
1.10/trueError paths exit non-zero
hashstreams the file and prints lowercase--countmust be 1–1000C# canonical JSON is byte-identical to serde_json
BOMs are stripped before parsing
WinGet's PackageIdentifier rule
Windows-unsafe names (trailing dot or space, device names) are rejected
--purgeUpgrade keeps user files
Nested zip installers actually run
System tools are launched from their absolute System32 path
MSI repair uses
msiexec /fdownloadchecks agreements andDownloadCommandProhibitedMarkets,UnsupportedOSArchitecturesandUpgradeBehaviorare appliedDependency
MinimumVersionand theUpgradeswitch are honouredThe downloaded manifest keeps every installer field
Security:
source addrequireshttps://REST 204 and 404 responses are handled
Packaged-layout tombstones and YAML round-trip
pinning.dbuses WinGet's schemaBlocking and Gating pins still apply with
--include-pinnedARP version fallbacks
ARM architecture stripping in name normalization
Pin source filters are case-insensitive
-Scope SystemworksRebootRequiredis reportedvalidatechecks content on both sidesUpdate-PingetPackagecontinues after a failureAn interrupted publish can be recovered (
pendingCommitmarker)ARP ranges and correlation use effective installers
Overlapping ARP ranges fail the build
The commit message has one line per fix for each wave.
Behaviour changes for reviewers
InstallerSha256now fails unless--ignore-security-hashis given, as in WinGet.source add:http://,ftp://and local paths are refused.--type, it creates aMicrosoft.PreIndexed.Packagesource (WinGet's default) instead of REST.upgradeandupgrade --all.pin addrecords the installed version.upgradewith no target exits 1.source updatewith partial failures exit non-zero.--purgeremoves everything.Program Files (x86)and WOW6432Node.exeinstallers no longer get a guessed/Sor/SILENT.sources.json: now written in camelCase. It still reads the old snake_case keys, but older Rust builds cannot read the new files.pendingCommit.contract.mdis updated.hashprints lowercase. Tables are no longer truncated when stdout is piped.Validation
cargo +nightly fmt --checkandcargo clippy --workspace --tests -D warnings: clean.cargo test --workspace: all pass.dotnet build(Release): succeeds.dotnet testCore.Tests: 650 passed, 1 skipped (live-network test).dotnet testPublisher.Tests: 158 passed.RunTests.ps1: 13 passed, 0 failed, but the run is reported as failed because its AfterAll cleanup throws "Access is denied" (a module DLL is still loaded). I did not check whether this also happens on master.dotnet format --verify-no-changes: reports only IDE0060 unused-parameter warnings, mostly on signatures unchanged from master.InstallerCompletion_DoesNotWaitForDetachedChildProcessfailed once under heavy load and passes when run alone.🤖 Generated with Claude Code