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: CSP Restriction for TrustedTypePolicy Creation in Loading Indicator #986

Merged
merged 1 commit into from
Jun 8, 2024

Conversation

HT808s
Copy link
Contributor

@HT808s HT808s commented Jun 1, 2024

Details

This PR aimes to fix the issue #985

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I agree to license this contribution under the MIT LICENSE
  • I checked the current PR for duplication.

Contacts

  • (OPTIONAL) Discord ID:

If your PR is accepted, we will award you with the Contributor role on Discord server.

To join the server, visit: https://www.plasmo.com/s/d

@R-iskey
Copy link

R-iskey commented Jun 6, 2024

When is it planned to merge?

Copy link

@OFNEILL OFNEILL left a comment

Choose a reason for hiding this comment

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

this works

@gBusato
Copy link

gBusato commented Jun 8, 2024

Please merge it since it's quite an issue while developing

@louisgv
Copy link
Contributor

louisgv commented Jun 8, 2024

Thanks for the PR! Will merge soon!

Copy link
Contributor

@louisgv louisgv left a comment

Choose a reason for hiding this comment

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

lgtm, nice find! 👍

Comment on lines +18 to +29
return true
}

const currentCSP = cspMetaTag.getAttribute('content')
const newPolicy = ` trusted-html-${LOADING_ID}`

if (!currentCSP.includes(newPolicy)) {
const updatedCSP = currentCSP + newPolicy
cspMetaTag.setAttribute('content', updatedCSP)
}

return true
Copy link
Contributor

Choose a reason for hiding this comment

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

The true returned here is mainly for the caller's control flow. It's a bit convoluted, but the tech debt seems localized to this module so we can deal with it later.

@louisgv louisgv merged commit 1eb588f into PlasmoHQ:main Jun 8, 2024
1 check passed
@louisgv louisgv changed the title Fix CSP Restriction for TrustedTypePolicy Creation in Loading Indicator fix: CSP Restriction for TrustedTypePolicy Creation in Loading Indicator Jun 8, 2024
@axelschapmann
Copy link

Do you know when this problem will be solved?

I still have the error on my side. Although I have update plasmo for my project with pnpm up -L plasmo

@OFNEILL
Copy link

OFNEILL commented Jun 10, 2024

Has this been pushed to pnpm as well?

@R-iskey
Copy link

R-iskey commented Jun 10, 2024

Is it fix the issue on dev runtime?
Refused to create a TrustedTypePolicy named 'trusted-html-__plasmo-loading__' because it violates the following Content Security Policy directive: "trusted-types 'allow-duplicates' default jSecure highcharts dompurify".

@louisgv
Copy link
Contributor

louisgv commented Jun 10, 2024

@OFNEILL yes it's pushed to the registry

@louisgv
Copy link
Contributor

louisgv commented Jun 10, 2024

Is it fix the issue on dev runtime? Refused to create a TrustedTypePolicy named 'trusted-html-__plasmo-loading__' because it violates the following Content Security Policy directive: "trusted-types 'allow-duplicates' default jSecure highcharts dompurify".

Hmm, I think if the user has multiple CSUI, this fix will not work because it will try to inject multiple loaders simultaneously... :-?..... @HT808s

@axelschapmann
Copy link

I still have the error on my side @louisgv , even with the latest version of Plasmo.

-> it occurs on LinkedIn

Refused to create a TrustedTypePolicy named 'trusted-html-__plasmo-loading__' because it violates the following Content Security Policy directive: "trusted-types 'allow-duplicates' default jSecure highcharts dompurify". Uncaught TypeError: Failed to execute 'createPolicy' on 'TrustedTypePolicyFactory': Policy "trusted-html-__plasmo-loading__" disallowed.

The error occurs on the home page, but if you go to a more specific url, like "https://www.linkedin.com/blog/member". There is no more error (i don't know if it helps)

@R-iskey
Copy link

R-iskey commented Jun 10, 2024

@axelschapmann correct, it working on "https://www.linkedin.com/blog/member" but home and user's profile page still throw this error

@agungjk
Copy link
Contributor

agungjk commented Jun 13, 2024

i create a hotfix for this issue on this PR #1000
you can test or use my bugfix

  1. clone the repo
    git clone [email protected]:agungjk/plasmo.git --recurse-submodules

  2. install dependency
    pnpm install

  3. build the repo
    pnpm run build:cli

  4. go to the folder cd cli/plasmo and link the runtime pnpm link --global

  5. you can test it by running plasmo dev instead of pnpm run dev on your plasma project

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.

7 participants