Skip to content

Use whitelist to restrict urlReplacement for scoped analytics element#8360

Merged
zhouyx merged 4 commits intoampproject:masterfrom
zhouyx:whitelist
Mar 27, 2017
Merged

Use whitelist to restrict urlReplacement for scoped analytics element#8360
zhouyx merged 4 commits intoampproject:masterfrom
zhouyx:whitelist

Conversation

@zhouyx
Copy link
Copy Markdown
Contributor

@zhouyx zhouyx commented Mar 24, 2017

@dvoytenko As we agreed, used whitelist to apply the restriction as the first step
I created #8396 to for future review of adding extra variables to the whitelist.

*/
export const ScopedElementWhiteList = {
// TODO: Please Review the list!
'RANDOM': true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest we turn off everything for now so we can get the PR in independently of a privacy review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

even for variables like RAMDOM ?

*/
export const ScopedElementWhiteList = {
// TODO: Please Review the list!
'RANDOM': true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i suggest we only keep the trues to shorten the list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's what I plan to do eventually. I put the complete list for the convenience of privacy review. But If we turn off everything for now, I can definitely do this now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

this.type_ = null;

/** @private {!boolean} */
this.isScoped_ = !!element.getAttribute('scope');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

element.hasAttribute

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

// TODO: Please Review the list!
'RANDOM': true,
'COUNTER': true,
'CANONICAL_URL': false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CANONICAL should be allowed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I assume all CANONICAL_URL, CANONICAL_HOST, CANONICAL_HOSTNAME, CANONICAL_PATH are good. I set all of them to true.

'CANONICAL_PATH': false,
'DOCUMENT_REFERRER': false,
'TITLE': true,
'AMPDOC_URL': false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AMPDOC_ URL stuff is good too.

'AMPDOC_URL': false,
'AMPDOC_HOST': false,
'AMPDOC_HOSTNAME': false,
'SOURCE_URL': false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SOURCE_ as well

@zhouyx
Copy link
Copy Markdown
Contributor Author

zhouyx commented Mar 24, 2017

@lannka convinced me that we should first turn off everything in the whitelist. And only turn them on if anyone request.
@dvoytenko WDYT?

@dvoytenko
Copy link
Copy Markdown
Contributor

@zhouyx I think it's safe to turn on AMPDOC_* vars and if we do that, it's the same as enabling CANONICAL_ and SOURCE_. 3p ampcontext is a good source for this data and canonical, et all are allowed there. So, let's enable these right away.

@dvoytenko
Copy link
Copy Markdown
Contributor

Otherwise, LGTM

@lannka lannka self-assigned this Mar 24, 2017
this.type_ = null;

/** @private {!boolean} */
this.isScoped_ = element.hasAttribute('scope');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shall we give it a different name? scope is already used in selectionMethod which has a quite different meaning.
how about <amp-analytics sandbox>

* Used for inserted scoped analytics element.
* @const {!Object<string, boolean>}
*/
export const ScopedElementWhiteList = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SANDBOX_AVAILABLE_VARS

maybe also change the file name.

@zhouyx zhouyx merged commit c9bf78f into ampproject:master Mar 27, 2017
@zhouyx zhouyx deleted the whitelist branch March 27, 2017 17:00
lironzluf pushed a commit to lironzluf/amphtml that referenced this pull request Mar 28, 2017
* master: (34 commits)
  Prevent amp-carousel next/previous icons fade away on desktop (ampproject#8428)
  Turn on flag slidescroll-disable-css-snap” (ampproject#8436)
  Revert "temporarily turn off yarn (ampproject#8356)" (ampproject#8384)
  initial commit (ampproject#8404)
  Upgrades for Index Exchange amp-ad tags to report load statistics (ampproject#8054)
  amp-bind validation tweak (ampproject#8414)
  Fix an amp-instagram race condition (ampproject#8192)
  Use whitelist to restrict urlReplacement for scoped analytics element (ampproject#8360)
  Report active experiments in error logs (ampproject#8108)
  amp-bind: Catch exceptions in mutatedAttributesCallback (ampproject#8383)
  Fixing custom scroll-snap on IOS (ampproject#8391)
  Add experiment for using AmpContext class in integration.js (ampproject#8348)
  add (ampproject#8349)
  swipe api (ampproject#8357)
  skip 3 flaky tests (ampproject#8388)
  amp-bind: Expression complexity limit (ampproject#8321)
  add margin-bottom (ampproject#8350)
  Flying carpet: make container full viewport and center content (ampproject#8292)
  Service Registration: Document Click (ampproject#7882)
  Add a8ad (ampproject#8036)
  ...
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
…ampproject#8360)

* use whitelist when replace scoped url

* address comment

* shorten-whitelist

* rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants