-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix incorrect ETag values #3490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix incorrect ETag for compressed files by resetting the compressed stream to the beginning before computing the SHA256 hash. See #3486.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures the compressed stream is reset before computing the hash so that ETag values for compressed files are correct.
- Reset the compressed stream position in
EmbeddedResourceProviderbefore hashing. - Introduce a shared constant for the empty-string hash in tests and replace hard-coded literals.
- Add assertions to verify the empty-string hash does not appear in the ETag tag.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs | Added EmptyStringSha256Hash constant, replaced literals, and added Assert.DoesNotContain checks on ETag. |
| test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs | Mirrored the same constant and assertions changes for ReDoc tests. |
| src/Shared/EmbeddedResourceProvider.cs | Inserted compressed.Seek(0, SeekOrigin.Begin) before hashing. |
Comments suppressed due to low confidence (2)
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs:10
- The constant name suggests SHA256 but the code uses SHA1; consider renaming it to
EmptyStringSha1Hashfor accuracy.
private const string EmptyStringSha256Hash = "2jmj7l5rSw0yVb/vlWAYkK/YBwk=";
test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs:13
- The constant name suggests SHA256 but the code uses SHA1; consider renaming it to
EmptyStringSha1Hashfor accuracy.
private const string EmptyStringSha256Hash = "2jmj7l5rSw0yVb/vlWAYkK/YBwk=";
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3490 +/- ##
=======================================
Coverage 93.91% 93.91%
=======================================
Files 110 110
Lines 3810 3811 +1
Branches 723 723
=======================================
+ Hits 3578 3579 +1
Misses 232 232
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Updated [swashbuckle.aspnetcore.cli](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) from 9.0.3 to 9.0.6. <details> <summary>Release notes</summary> _Sourced from [swashbuckle.aspnetcore.cli's releases](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/releases)._ ## 9.0.6 ## What's Changed * Bump redoc from 2.5.0 to 2.5.1 by @dependabot in domaindrivendev/Swashbuckle.AspNetCore#3587 * Bump swagger-ui from 5.29.1 to 5.29.2 by @dependabot in domaindrivendev/Swashbuckle.AspNetCore#3595 **Full Changelog**: domaindrivendev/Swashbuckle.AspNetCore@v9.0.5...v9.0.6 ## 9.0.5 ## What's Changed * .NET 10 preparation by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3565 * Update NuGet packages by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3573 * Fix anchors by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3577 * Bump swagger-ui-dist from 5.27.1 to 5.29.1 **Full Changelog**: domaindrivendev/Swashbuckle.AspNetCore@v9.0.4...v9.0.5 ## 9.0.4 ## What's Changed * Fix incorrect `ETag` values by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3490 * Fix `Accept-Encoding` parsing by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3492 * Check `Accept-Encoding` quality by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3493 * Update xunit packages by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3500 * Add release notes configuration by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3502 * Simplify release workflow by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3503 * Bump xunit dependencies by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3508 * Update NuGet dependencies by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3513 * Remove `WebHost` usage from tests by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3517 * Fix typos by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3520 * Sign-off commits by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3526 * Add zizmor by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3528 * Fix permissions by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3529 * Bump zizmor by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3535 * Add default `$type` discriminator for `[JsonPolymorphic]` by @lilinus in domaindrivendev/Swashbuckle.AspNetCore#3496 * Update NuGet dependencies by @martincostello in domaindrivendev/Swashbuckle.AspNetCore#3545 ## New Contributors * @lilinus made their first contribution in domaindrivendev/Swashbuckle.AspNetCore#3496 **Full Changelog**: domaindrivendev/Swashbuckle.AspNetCore@v9.0.3...v9.0.4 Commits viewable in [compare view](domaindrivendev/Swashbuckle.AspNetCore@v9.0.3...v9.0.6). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fix incorrect
ETagfor compressed files by resetting the compressed stream to the beginning before computing the SHA256 hash.See #3486 (comment).