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: adjust extension permissions #1613

Closed
wants to merge 5 commits into from
Closed

fix: adjust extension permissions #1613

wants to merge 5 commits into from

Conversation

smoralesd
Copy link
Contributor

@smoralesd smoralesd commented Nov 5, 2019

Description of changes

Using "activeTab" permissions instead of wide-matching patterns ("https://*/*", "http://*/*", "file://*/*") in order to avoid getting flagged with in pending review status when updating the extension on google web store.

We have filed issue #1591 to track cannary not being properly update since 10/24 but this affect all of our extensions. This is related to chrome extension permissions and an effort to prevent malisious extension on the web store. Chrome developer website has a transition guide.

While changing the permissions seems to be working fine on the extension itself(we have a pending general-pass validation session from the team), the change has broke end to end test where we need to inject js/css to the target page (e.g, there is a test for the ad hoc panel where we enable each and every toggle that breaks with a permissions denied-kind of error).

This is due to how the "activeTab" permission works. Simply put, our extension gets permissions to inject js/css when the user activates our extension. There are basically 2 ways this happen:

  1. the user clicks/press the extension icon on the extensions bar righ by the address bar
  2. the user users our extension's shortcut to activate it.

We're using Puppeteer for our end-to-end tests and there is currently no API to efectivle use 1. as mentioned here.

I tried option 2. by using Puppeteer's Keyboard api to no success. I also looked at a couple of npm packages that send keyboard strokes at the OS level (most notably: kbm-robot, node-key-sender) but they relay on Java, which seems a medium to mayor size/impact decission for our infrastructure. After that, I didn't want to invest more time with this approach as we need to unblock ourselves as fast as we can, finding a balance between time spend, robustness and correctness on the approach we choose.

The choosen approach was based on @dbjorge suggestion to follow this chrome ligthouse PR where they decided to modified the manifest.json, adding a permission to facilitated e2e testing.

Pull request checklist

  • Addresses an existing issue: fixes Canary hasn't updated since 10/24 #1591
  • Ran yarn fastpass
  • [n/a] Added/updated relevant unit test(s) (and ran yarn test)
  • [n/a] Verified code coverage for the changes made. Check coverage report at: <rootDir>/test-results/unit/coverage
  • PR title AND final merge commit title both start with a semantic tag (fix:, chore:, feat(feature-name):, refactor:). Check workflow guide at: <rootDir>/docs/workflow.md
  • [n/a] (UI changes only) Added screenshots/GIFs to description above
  • [n/a] (UI changes only) Verified usability with NVDA/JAWS

@smoralesd smoralesd self-assigned this Nov 5, 2019
@smoralesd smoralesd marked this pull request as ready for review November 5, 2019 01:16
@smoralesd smoralesd requested a review from a team as a code owner November 5, 2019 01:17
function addLocalhostPermissionsToManifest(originalManifest: string): string {
const manifest = JSON.parse(originalManifest);

manifest['permissions'].push('http://localhost:9050/*');
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider pulling this number out of testResourceServerConfig.port


export interface ExtensionOptions {
suppressFirstTimeDialog: boolean;
addLocalhostToPermissions?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would probably help prevent bugs for this to be non-optional; if a test wants to not have the extra permissions, it has to choose that explicitly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see it the other way around: we don't give those permissions, unless the test explicitly set this flag to true

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it should default to true, I'm saying I think it should maybe not have any default value (force every test to choose explicitly)

Copy link
Contributor Author

@smoralesd smoralesd Nov 6, 2019

Choose a reason for hiding this comment

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

It defaults to false and having optional make tests that don't need this permissions less verbose about it.

@smoralesd smoralesd changed the title fix: adjust extension permissoons fix: adjust extension permissions Nov 6, 2019
@smoralesd
Copy link
Contributor Author

This PR was more of an exploration and proof-of-concept. We have prove the permissions works and found at least one issue. I'll will abandon this PR and re-work it from latest master again. I'll be also taking care of the comments left on this PR.

@smoralesd smoralesd closed this Nov 7, 2019
@smoralesd smoralesd deleted the permissions branch November 8, 2019 23:16
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.

Canary hasn't updated since 10/24
2 participants