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(cid): localhost should only be considered as proxy if prefix is c or v. #1289

Merged
merged 1 commit into from
Jan 7, 2016

Conversation

erwinmombay
Copy link
Member

No description provided.

@cramforce
Copy link
Member

Do the unit tests still go through the same code path?

@erwinmombay
Copy link
Member Author

@cramforce with this current code, i can't 100% guarantee that. i think there could certainly be an indirect use of the cid service in the tests that used to go through the getBaseCid path but would now go through the Promise.resolve path. (any test that had cid usage where url is localhost w/o v or c prefix).

im thinking of just removing the changes i made and doing this:

  if (url.origin.indexOf('http://localhost:') != 0) {
    assert(prefix == 'c' || prefix == 'v',
        'Unknown path prefix in url %s', url.href);
  }

in getSourceOrigin which fixes my localhost warning problems and would ensure all tests still go through the same code path.

@cramforce
Copy link
Member

I'm confused by the changeset that GH is showing now. Otherwise it was fine.

@jridgewell
Copy link
Contributor

This LGTM. What's the v prefix for?

@erwinmombay
Copy link
Member Author

@cramforce i dont think i was confident that the previous code wouldn't be forcing the tests into the Promise.resolve path (a test using localhost:8000/test for example). had to change from localDev since localDev also checks that the files come from dist or base (should we just remove that check in localDev?).

not sure what the v/c stands for, @cramforce can you shed some light on that one?

@erwinmombay erwinmombay force-pushed the proxy-change branch 2 times, most recently from a641501 to 21563f5 Compare January 5, 2016 16:50
if (!(mode.localDev &&
(prefix == 'examples.build' || prefix == 'examples'))) {
// whitelist localhost
const localDev = location.hostname == 'localhost' ||
Copy link
Member

Choose a reason for hiding this comment

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

I think what we discussed was to instead make #isProxyOrigin only return true if the assert would not fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

@cramforce reverted to original change. PTAL

// List of well known proxy hosts. New proxies must be added here
// to generate correct tokens.
return (url.origin == 'https://cdn.ampproject.org' ||
url.origin.indexOf('http://localhost:') == 0);
(url.origin.indexOf('http://localhost:') == 0 &&
(prefix == 'c' || prefix == 'v')));
Copy link
Member Author

Choose a reason for hiding this comment

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

@cramforce PTAL. changed to check if localhost has prefix c/v

@cramforce
Copy link
Member

LGTM

erwinmombay added a commit that referenced this pull request Jan 7, 2016
fix(cid): localhost should only be considered as proxy if prefix is c or v.
@erwinmombay erwinmombay merged commit e3fd74b into ampproject:master Jan 7, 2016
@dparikh dparikh mentioned this pull request Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants