-
Notifications
You must be signed in to change notification settings - Fork 325
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(recovery): 🐛 false-positive for non-gateway URLs #1163
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0d765a5
fix(recovery): :bug: No recovery for URLs being redirected.
whizzzkid 6796c9d
fix(recovery): :test_tube: test added.
whizzzkid 91a9567
fix(recovery): :memo: Adding comments
whizzzkid 74cb934
fix(recovery): :rotating_light: linter warnings
whizzzkid 78ce18d
fix: false-positives in sameGateway
lidel 5fd1816
test: ensure recovery does not depend on redirects
lidel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,11 +184,23 @@ describe('ipfs-path.js', function () { | |
const gw = 'http://localhost:8080' | ||
expect(sameGateway(url, gw)).to.equal(true) | ||
}) | ||
it('should return true on 127.0.0.1/0.0.0.0 host match', function () { | ||
it('should return true on localhost subdomain host match', function () { | ||
const url = 'http://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi.ipfs.localhost:8080/foo/bar' | ||
const gw = 'http://localhost:8080' | ||
expect(sameGateway(url, gw)).to.equal(true) | ||
}) | ||
it('should return true on RPC webui path 127.0.0.1/0.0.0.0 host match', function () { | ||
// this is misconfiguration, but handling it in sameGateway ensures users who do this dont waste our time debugging | ||
const url = 'http://0.0.0.0:5001/webui' | ||
const api = 'http://127.0.0.1:5001' | ||
expect(sameGateway(url, api)).to.equal(true) | ||
}) | ||
it('should return true on RPC /api/v0 path 127.0.0.1/0.0.0.0 host match', function () { | ||
// this is misconfiguration, but handling it in sameGateway ensures users who do this dont waste our time debugging | ||
const url = 'http://0.0.0.0:5001/api/v0/id' | ||
const api = 'http://127.0.0.1:5001' | ||
Comment on lines
+198
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ℹ️ this saves us a day of debugging when user puts wrong port in wrong field in their config, and then tweets about it ;-) |
||
expect(sameGateway(url, api)).to.equal(true) | ||
}) | ||
it('should return false on hostname match but different port', function () { | ||
const url = 'https://localhost:8081/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR/foo/bar' | ||
const gw = 'http://localhost:8080' | ||
|
@@ -289,7 +301,7 @@ describe('ipfs-path.js', function () { | |
expect(ipfsPathValidator.isRedirectPageActionsContext(url)).to.equal(true) | ||
}) | ||
it('should return false for /ipfs/ URL at Local Gateway', function () { | ||
const url = `${state.gwURL}/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest` | ||
const url = `${state.gwURL}ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest` | ||
expect(ipfsPathValidator.isRedirectPageActionsContext(url)).to.equal(false) | ||
}) | ||
it('should return false for IPFS content loaded from IPFS API port', function () { | ||
|
This file contains 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
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.
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.
ℹ️ we were missing subdomain test, so I've added it