Skip to content
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

fix(gateway): ensure 'X-Ipfs-Root' header is valid #337

Merged
merged 8 commits into from
Jun 27, 2023
Merged

fix(gateway): ensure 'X-Ipfs-Root' header is valid #337

merged 8 commits into from
Jun 27, 2023

Conversation

hacdias
Copy link
Member

@hacdias hacdias commented Jun 7, 2023

Fixes #221.

My idea is to create this struct requestData that is passed onto the handlers in order to keep the most possible information around. The other option would be to make handleIfNoneMatch return one more variable (the path metadata) and then pass it around. However, our functions already have a lot of parameters.

I also cleaned up the existing tests and added a bunch of new tests for Etag, If-None-Match and X-Ipfs-Roots. Some of these tests should be also done in the gateway conformance. However, these have to be slightly different since we can't expect specific Etag values. See ipfs/gateway-conformance#73 (comment).

@hacdias hacdias self-assigned this Jun 7, 2023
@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Merging #337 (a4effaf) into main (290613a) will increase coverage by 0.37%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
+ Coverage   51.01%   51.38%   +0.37%     
==========================================
  Files         277      280       +3     
  Lines       33416    33443      +27     
==========================================
+ Hits        17048    17186     +138     
+ Misses      14629    14527     -102     
+ Partials     1739     1730       -9     
Impacted Files Coverage Δ
gateway/handler_ipns_record.go 18.75% <50.00%> (ø)
gateway/handler_car.go 70.22% <81.81%> (+5.34%) ⬆️
gateway/handler_defaults.go 40.26% <82.35%> (ø)
gateway/handler_codec.go 62.18% <85.00%> (+7.23%) ⬆️
gateway/handler_block.go 83.78% <85.71%> (ø)
gateway/handler.go 75.83% <86.27%> (+4.47%) ⬆️
gateway/handler_tar.go 79.36% <87.50%> (ø)

... and 21 files with indirect coverage changes

@hacdias hacdias force-pushed the feat/gateway-ipip-402 branch 3 times, most recently from df19eb1 to a93ce13 Compare June 8, 2023 08:59
@hacdias hacdias force-pushed the issue/221 branch 2 times, most recently from ea4603e to a845fce Compare June 8, 2023 09:31
@hacdias hacdias force-pushed the feat/gateway-ipip-402 branch from a93ce13 to c5f0cad Compare June 8, 2023 09:39
@hacdias hacdias force-pushed the feat/gateway-ipip-402 branch from c5f0cad to 7be4474 Compare June 8, 2023 14:48
Base automatically changed from feat/gateway-ipip-402 to main June 8, 2023 15:18
@hacdias hacdias force-pushed the issue/221 branch 3 times, most recently from 3c75a32 to 7be9206 Compare June 9, 2023 09:35
@hacdias hacdias requested a review from aschmahmann June 9, 2023 09:50
@hacdias hacdias marked this pull request as ready for review June 9, 2023 09:50
@hacdias hacdias requested a review from lidel as a code owner June 9, 2023 09:50
@hacdias hacdias force-pushed the issue/221 branch 4 times, most recently from 63714df to a9794ec Compare June 20, 2023 13:45
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hacdias, especially for adding a lot of missing tests. ❤️

Looks good, but we should add one test for HAMT (usual edge case) just to be sure + see some questions/style suggestions inline.

gateway/gateway_test.go Outdated Show resolved Hide resolved
gateway/gateway_test.go Outdated Show resolved Hide resolved
gateway/handler_block.go Outdated Show resolved Hide resolved
gateway/handler.go Outdated Show resolved Hide resolved
gateway/handler.go Outdated Show resolved Hide resolved
gateway/gateway_test.go Outdated Show resolved Hide resolved
gateway/gateway_test.go Show resolved Hide resolved
Co-authored-by: Marcin Rataj <lidel@lidel.org>
@hacdias hacdias requested a review from lidel June 26, 2023 11:51
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm (only a small hamt testing nit inline). Improved test coverage here is really valuable, thanks! 👍

gateway/gateway_test.go Outdated Show resolved Hide resolved
@hacdias hacdias enabled auto-merge (squash) June 27, 2023 09:32
@hacdias hacdias disabled auto-merge June 27, 2023 10:00
@hacdias hacdias merged commit 72238ea into main Jun 27, 2023
@hacdias hacdias deleted the issue/221 branch June 27, 2023 10:00
@hacdias hacdias mentioned this pull request Jun 27, 2023
hacdias added a commit that referenced this pull request Jun 29, 2023
Co-authored-by: Marcin Rataj <lidel@lidel.org>
@lidel lidel mentioned this pull request Jun 29, 2023
hacdias added a commit that referenced this pull request Jun 29, 2023
Co-authored-by: Marcin Rataj <lidel@lidel.org>
(cherry picked from commit 72238ea)
@BigLep BigLep mentioned this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Gateway: Possible Invalid 'X-Ipfs-Roots' Header
2 participants