Repository navigation
GeneralUpdate.Extension 11.0: production hardening, auto-update pipeline, package signatures, ALC loader - #565
Merged
Conversation
Safety fixes: - Resume only on 206 PartialContent; a plain 200 restarts the file; 416 is verified against the server-declared total size before counting as complete - Circular-dependency guard in the recursive dependency installer (no stack overflow) - Local installs register in the catalog (manifest written, survives restarts) - Server UploadTime preserved; package manifest no longer shadows server metadata Hardening: - Sanitize server-controlled Name/Version/Format before filesystem use - Cross-process catalog file lock (.catalog.lock, self-healing on crash) - Zip extraction: traversal entries fail the whole install; entry-count and uncompressed-size limits guard against zip bombs - Corrupt manifests are skipped with a warning instead of failing the whole load - Download retries with exponential backoff, resume-aware (DownloadRetryAttempts) - Thread safety: concurrent auto-update settings, queue processing gate, volatile flags - GeneralTracer no longer clears host Trace listeners; pluggable ITraceSink/ILogger Features: - CheckForUpdatesAsync / CheckAndApplyUpdatesAsync + ExtensionUpdatesChecked event - Built-in auto-update scheduler (interval, global/per-extension flags, persisted) - RSA-SHA256 package signature verification (SigningPublicKey + Signature metadata) - Dependency version constraints: id@^range syntax via VersionRange/DependencyRef - InstallFromLocalAsync: offline install with explicit SHA256 verification - RollbackToAsync with retained previous-version backups; SideBySideVersions layout - ScanAsync health scan with repair (freshness window protects in-flight downloads) - QueryAllExtensionsAsync: auto-paging IAsyncEnumerable iterator - Phase field on update events; AlreadyUpToDate/DowngradeBlocked statuses - CancellationToken across the IExtensionHost surface; CancelDownload API - GET-with-body query auto-falls back to POST (AutoFallbackToPost) - HttpClient options: timeout, explicit proxy, UseSystemProxy, user agent - GeneralUpdate.Extension.Loader (net8.0): collectible AssemblyLoadContext loader Packaging and tests: - Version 11.0.0; Examples moved out of the NuGet package into samples projects - Read-only ServerSmokeTool sample for production-server contract verification - 483 tests: feature suite, real-HTTP end-to-end, production hardening, and a .NET Framework 4.8 runtime smoke project - docs/extension-system.md: full system guide and production deployment checklist
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues allow catalog path traversal and parent-directory deletion, undermine cross-process locking, and can leave downloads hanging during shutdown.
25 open issues
Sanitize the active version before building its path · New Merge disk state before updating active version pointers · New Sanitize side-by-side catalog directory names consistently · New Prevent traversal in root catalog paths · New Keep the lock file after releasing its handle · New Complete dequeued tasks when shutdown races processing · New Enable POST for the POST transport check · New Verify the server honors range requests in the probe · New Normalize the extension directory to an absolute path · New Serialize concurrent extension activation · New Propagate extension entry-point creation failures · New Share the host contract assembly with extensions · New Resolve the active manifest before the legacy root manifest · New Forward HTTP options through the builder's default client · New Fall back to POST when GET fails before a response · New Validate the returned range start before appending · New Atomically replace completed tasks during enqueue · New Remove queued tasks only when the entry still matches · New Detach the file listener when disabling file logging · New Remove or restore the console listener when toggled · New
And 5 more that still need to be addressed.
What changed in this PR
Upgrades GeneralUpdate.Extension to 11.0 with production hardening, expanded update APIs, and a separate collectible assembly loader.
Changes:
- Adds update scheduling, signature verification, dependency ranges, rollback, and health-scan support.
- Hardens downloads, catalog persistence, concurrency, and tracing.
- Expands tests, separates samples, and adds deployment documentation and a server smoke tool.
| File | Description |
|---|---|
| tests/ExtensionTest/Utilities/VersionRangeTests.cs | Tests dependency parsing and range semantics. |
| tests/ExtensionTest/Utilities/PackageSignatureVerifierTests.cs | Tests signature verification and rejection cases. |
| tests/ExtensionTest/Tracer/GeneralTracerSinkTests.cs | Tests custom tracing sinks. |
| tests/ExtensionTest/TestExtensionSample/TestExtensionSample.csproj | Adds the loader test fixture project. |
| tests/ExtensionTest/TestExtensionSample/TestEntryPoint.cs | Implements a sample extension entry point. |
| tests/ExtensionTest/Loader/AssemblyContextExtensionLoaderTests.cs | Tests loading, unloading, and host integration. |
| tests/ExtensionTest/ExtensionTest.csproj | References loader and tracing dependencies. |
| tests/ExtensionTest/Core/ProductionHardeningTests.cs | Tests sanitization, locks, retries, and scheduling. |
| tests/ExtensionTest/Core/ExtensionHostFeatureTests.cs | Covers the expanded host lifecycle. |
| tests/ExtensionTest/Communication/ExtensionHttpClientResumeTests.cs | Tests resume handling and query fallback. |
| tests/ExtensionTest/Communication/ExtensionHostEndToEndTests.cs | Adds real-HTTP lifecycle tests. |
| tests/ExtensionTest/Catalog/ExtensionCatalogTests.cs | Checks corrupt-manifest isolation. |
| tests/ExtensionNet48SmokeTest/Net48SmokeTests.cs | Adds Framework runtime smoke coverage. |
| tests/ExtensionNet48SmokeTest/ExtensionNet48SmokeTest.csproj | Defines the .NET Framework 4.8 test project. |
| tests/Directory.Packages.props | Adds the logging abstraction dependency version. |
| src/GeneralUpdate.slnx | Includes loader, samples, and smoke tests. |
| src/GeneralUpdate.Extension/Utilities/VersionRange.cs | Adds dependency-reference and version-range parsing. |
| src/GeneralUpdate.Extension/Utilities/PackageSignatureVerifier.cs | Adds RSA-SHA256 signing and verification. |
| src/GeneralUpdate.Extension/Tracer/TextTraceListener.cs | Explicitly marks disposal-method hiding. |
| src/GeneralUpdate.Extension/Tracer/GeneralTracer.cs | Adds configurable sinks and preserves host listeners. |
| src/GeneralUpdate.Extension/GeneralUpdate.Extension.csproj | Updates package metadata and dependencies for 11.0. |
| src/GeneralUpdate.Extension/Download/IDownloadQueueManager.cs | Adds task-removal API. |
| src/GeneralUpdate.Extension/Download/DownloadQueueManager.cs | Adds retries, completion signals, and queue coordination. |
| src/GeneralUpdate.Extension/Core/RegistryExtensionLoader.cs | Adds the default registry-only loader. |
| src/GeneralUpdate.Extension/Core/IExtensionMetadataMapper.cs | Maps package signatures. |
| src/GeneralUpdate.Extension/Core/IExtensionLoader.cs | Defines loading and entry-point contracts. |
| src/GeneralUpdate.Extension/Core/IExtensionHost.cs | Expands lifecycle APIs, cancellation, and events. |
| src/GeneralUpdate.Extension/Core/ExtensionHostBuilder.cs | Registers loader and configurable queue/catalog defaults. |
| src/GeneralUpdate.Extension/Concurrency/FileLock.cs | Adds cross-process file locking. |
| src/GeneralUpdate.Extension/Communication/ExtensionHttpClient.cs | Adds resume safeguards, query fallback, and HTTP options. |
| src/GeneralUpdate.Extension/Common/Models/ExtensionUpdateInfo.cs | Describes available updates. |
| src/GeneralUpdate.Extension/Common/Models/ExtensionScanReport.cs | Models health-scan results. |
| src/GeneralUpdate.Extension/Common/Models/ExtensionMetadata.cs | Adds signatures and persisted update preferences. |
| src/GeneralUpdate.Extension/Common/Models/ExtensionHostOptions.cs | Adds security, scheduling, storage, and HTTP settings. |
| src/GeneralUpdate.Extension/Common/Models/DownloadTask.cs | Adds awaitable download completion. |
| src/GeneralUpdate.Extension/Common/Enums/ExtensionUpdateStatus.cs | Adds up-to-date and downgrade-blocked statuses. |
| src/GeneralUpdate.Extension/Common/Enums/ExtensionUpdatePhase.cs | Identifies lifecycle event phases. |
| src/GeneralUpdate.Extension/Common/DTOs/HttpResponseDTO.cs | Exposes transport status without serializing it. |
| src/GeneralUpdate.Extension/Common/DTOs/ExtensionDTO.cs | Adds server-provided package signatures. |
| src/GeneralUpdate.Extension/Catalog/ExtensionCatalog.cs | Adds locking, version selection, and resilient loading. |
| src/GeneralUpdate.Extension.Loader/README.md | Documents loader setup and behavior. |
| src/GeneralUpdate.Extension.Loader/GeneralUpdate.Extension.Loader.csproj | Defines the separate net8.0 loader package. |
| src/GeneralUpdate.Extension.Loader/AssemblyContextExtensionLoader.cs | Implements collectible assembly loading. |
| samples/GeneralUpdate.Extension.SmokeTool/Program.cs | Adds server query and download probes. |
| samples/GeneralUpdate.Extension.SmokeTool/GeneralUpdate.Extension.SmokeTool.csproj | Defines the smoke-tool executable. |
| samples/GeneralUpdate.Extension.Samples/VersionCompatibilityExample.cs | Moves compatibility example into the samples namespace. |
| samples/GeneralUpdate.Extension.Samples/PlatformMatcherExample.cs | Moves platform example into the samples namespace. |
| samples/GeneralUpdate.Extension.Samples/InstallExtensionExample.cs | Moves installation example into the samples namespace. |
| samples/GeneralUpdate.Extension.Samples/GeneralUpdate.Extension.Samples.csproj | Separates examples from the library package. |
| samples/GeneralUpdate.Extension.Samples/ExtensionExample.cs | Moves lifecycle example into the samples namespace. |
| samples/GeneralUpdate.Extension.Samples/ExtensionCatalogExample.cs | Moves catalog example into the samples namespace. |
| samples/GeneralUpdate.Extension.Samples/DownloadQueueExample.cs | Moves queue example into the samples namespace. |
| samples/GeneralUpdate.Extension.Samples/DependencyResolverExample.cs | Moves dependency example into the samples namespace. |
| docs/extension-system.md | Adds system, deployment, and migration guidance. |
Review effort: Balanced
…roduction-hardening
…roduction-hardening
…resume, tracer ownership
Catalog
- A server-supplied name or version goes through the same sanitizer as the
installation (SafeNames.DirectoryName), so a Name/Version of ".." can no
longer point the manifest write - or a later RemoveInstalledExtension -
outside the catalog directory.
- The .active pointer is sanitized on read like any directory name, so a
hostile pointer cannot lead the manifest read outside the extension.
- The side-by-side load resolves the pointer/highest-version manifest first
and uses the legacy root manifest only as a fallback, so a stale
{name}/manifest.json no longer outranks the version that was selected.
- Saving one extension writes only that extension's manifest and pointer under
the lock, instead of every entry of the in-memory snapshot: a second host
loaded at v1 could push the first host's v2 pointer back to v1 by changing
settings for an unrelated extension.
- FileLock keeps the lock file and only releases its handle: mutual exclusion
is tied to the open handle, and deleting the pathname afterwards would let a
third process lock a new file under the same name while a second process
still holds the old one.
Download queue
- Tracking a task is an atomic add-or-replace of a finished task; concurrent
enqueues for one extension cannot both get in.
- Cleanup removes a task only while it is still the one tracked for its ID, so
a finished task can no longer remove its successor.
- A dequeued task is completed as failed when disposal (or anything else)
keeps its download from starting; the loop holds the disposal token from
construction, so reading it after Dispose cannot throw.
Loader (net8.0+)
- The extension directory is made absolute before assembly discovery, so the
documented "./extensions" configuration loads instead of throwing in
LoadFromAssemblyPath.
- Load/unload is serialized per loader; concurrent activations of one ID can
no longer build two contexts and drop one from the record.
- A missing dependency or a throwing entry-point constructor fails the load
(the context is unloaded, the record is not kept) instead of reporting a
load without an entry point.
- The host's contract assembly is shared before extension-local resolution:
an extension that ships its own GeneralUpdate.Extension.dll is still
recognized as implementing the host's IExtensionEntryPoint.
HTTP client
- The POST fallback also runs when GET fails before a response exists
(transport/protocol rejection), so POST-only transports work; a failing
fallback reports both failures.
- A 206 whose Content-Range does not start at the local file's end is not
appended; the download restarts instead of corrupting the file.
Builder
- Proxy, UseSystemProxy, HttpTimeout and UserAgent are forwarded to the
default ExtensionHttpClient registration; they were silently ignored
through the recommended builder.
Tracer
- EnableFileLogging=false detaches and disposes an existing log listener, and
the initial file setup is deferred to the first trace message, so an opt-out
never requires a writable Logs directory.
- EnableConsoleListener=false removes the owned console listener and restores
it when re-enabled; repeated ResetToDefaultListeners calls no longer stack
duplicate listeners.
- SetTracingEnabled only switches the filters of listeners this library owns,
leaving host listeners untouched.
Smoke tool
- The main client uses POST for the query check (the GET probe stays separate).
- The download probe verifies the actual 206 + Content-Range start instead of
declaring resume working when a server ignores the Range.
Range/version-range semantics
- A comparator list that names an empty interval (">=2.0.0 1.0.0") parses to
an empty range - nothing satisfies it - instead of failing to parse, so
dependency resolution reports an unsatisfiable constraint rather than a
syntax error; and comparators now always intersect (exact, caret, tilde
included), closing the widening that made ">=2.0.0 1.0.0" accept 1.0.0.
Framework smoke
- The net48 HTTP test asserts the query transport returned the server item
(registering an installed extension and expecting its update entry), instead
of passing on an empty error response.
Regressions: ExtensionCatalogPathAndPointerTests, GeneralTracerListenerTests,
AssemblyContextLoaderDeploymentTests, ExtensionHttpClientResumeTests
(broken-range restart, GET-transport-failure fallback, synchronous progress),
VersionRangeTests (intersection and order-reversal cases), Net48SmokeTests.
…roduction-hardening
…e layouts Path.GetRelativePath returns the absolute target when the working directory and the temp directory are on different drives - the layout of the Windows CI runner (repository on D:, temp on C:) - so asserting non-rootedness failed there instead of exercising the loader. The assertion now guards the case.
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
Brings
GeneralUpdate.Extensionto production standard: fixes four correctness bugs found in review, hardens security and concurrency, completes the update feature set (update checks, auto-update scheduler, package signatures, rollback, health scan), ships a new AssemblyLoadContext loader package, and raises the test suite from 367 to 483 tests including real-HTTP end-to-end and .NET Framework 4.8 runtime smoke coverage.Version: 10.5.0 → 11.0.0 (interface additions are breaking for custom implementers; migration notes in the docs).
Safety fixes
206 PartialContent; a plain200restarts the file (previously appended a full body onto a partial file → corrupted packages);416is verified against theContent-Rangetotal before counting as "already downloaded"A→B→Ano longer overflows the stack)UploadTimepreserved; package manifest no longer shadows server metadataHardening
Name/Version/Formatsanitized before filesystem use (path-traversal-proof).catalog.lock, self-healing on process crash)DownloadRetryAttempts, default 2)GeneralTracerno longer clears hostTrace.Listeners; pluggableITraceSink/ILoggerFactoryNew features
CheckForUpdatesAsync/CheckAndApplyUpdatesAsync+ExtensionUpdatesCheckedeventSigningPublicKey+Signaturemetadata)id@^rangesyntax (VersionRange/DependencyRef)InstallFromLocalAsync: offline install with explicit SHA256 verificationRollbackToAsyncwith retained previous-version backups; optionalSideBySideVersionslayoutScanAsynchealth scan with repair (freshness window protects in-flight downloads)QueryAllExtensionsAsync: auto-pagingIAsyncEnumerableiteratorPhasefield on update events (download/install/uninstall/activation/rollback/check)CancellationTokenacross the wholeIExtensionHostsurface;CancelDownloadAPIAutoFallbackToPost)UseSystemProxy, user agentGeneralUpdate.Extension.Loader(net8.0): collectibleAssemblyLoadContextloader withIExtensionEntryPointconventionPackaging & tooling
Examples/moved out of the NuGet package intosamples/GeneralUpdate.Extension.Samplessamples/GeneralUpdate.Extension.SmokeTool) for verifying a real server's contract before deploymentdotnet packverified: both packages build with symbols, README, iconsTests
367 → 483, all green:
ExtensionNet48SmokeTest: runs the netstandard2.0 library on the .NET Framework 4.8 runtime (IO/compression/RSA/HTTP/resume)Docs
docs/extension-system.md: full system guide (lifecycle, security model, dependency constraints, scheduler, rollback, loader, server API contract) + production deployment checklist + 10.x→11.0 migration notes