Skip to content

Commit

Permalink
[FAILS] Add a test to show issue with subdomains as additional permis…
Browse files Browse the repository at this point in the history
…sions

According to the documentation, `strictOrigins` is only concerned with
widening of permissions, not additional permissions which are narrower
than a pattern already in the manifest origins.

However, if `https://subdomain.hassubdomains.com/*` is granted by the
user as an optional permission on top of `https://*.hassubdomains.com/*`,
this does not change the effective set of permissions.

So to be consistent with the documentation, when `strictOrigins` is
`true`, the additional subdomain pattern should not be included in the
return value of `extractAdditionalPermissions()`.

Adding a test based on this expectation causes a failure, showing the
current problem.  So either the code should be changed, or the
documentation for `strictOrigins` expanded to clarify that it also
catches narrower permissions as well as wider ones.
  • Loading branch information
aspiers committed Jan 21, 2024
1 parent bac783e commit 5901c4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions source/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ describe.each([
origins: [
'https://*.github.com/*',
'https://git.example.com/*',
// According to the documentation, strictOrigins is only concerned
// with widening of permissions, not narrowing. Therefore
// This should exclude https://subdomain.hassubdomains.com/*
// because it's not an additional permission relative to
// https://*.hassubdomains.com/* which is already in the manifest.
],
permissions: [
'someOtherPermission',
Expand Down
3 changes: 2 additions & 1 deletion test-fixtures/reported-after-addition.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"https://github.com/*",
"https://*.hassubdomains.com/*",
"https://*.github.com/*",
"https://git.example.com/*"
"https://git.example.com/*",
"https://subdomain.hassubdomains.com/*"
],
"permissions": [
"activeTab",
Expand Down

0 comments on commit 5901c4b

Please sign in to comment.