Skip to content

Updated Content Security Policy to be more strict#306

Closed
zzeebbii wants to merge 1 commit into
microsoft:mainfrom
zzeebbii:add-content-policy
Closed

Updated Content Security Policy to be more strict#306
zzeebbii wants to merge 1 commit into
microsoft:mainfrom
zzeebbii:add-content-policy

Conversation

@zzeebbii

@zzeebbii zzeebbii commented Feb 6, 2020

Copy link
Copy Markdown

This PR fixes #171. As no resources are being used by the extension right now, so default source can be none. Later if the extension needs some image, script or style then the policy can be updated.

- No script, image or styles are being loaded right now, so it can be
  set to none. Later it can be updated if required.
@msftclas

msftclas commented Feb 6, 2020

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@akaroml akaroml requested a review from jdneo February 14, 2020 13:32
@akaroml

akaroml commented Feb 14, 2020

Copy link
Copy Markdown
Member

@jdneo please help take a look.

@jdneo jdneo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm afraid this won't work. If you open the Getting Started page, you will get an warning like following:

[Embedded Page] Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'none'". Either the 'unsafe-inline' keyword, a hash ('sha256-JFinOq+GM9ozZBqjltSr0PP7/fN3NmpyjSvRGddk43k='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

Maybe a better way to fix this issue is to use the nonce mechanism: https://github.com/microsoft/vscode-extension-samples/blob/master/webview-sample/src/extension.ts#L194-L207

@zzeebbii

Copy link
Copy Markdown
Author

I will continue working on this one.

@chagong

chagong commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

clean out-of-date PR.

@chagong chagong closed this Nov 4, 2025
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.

Webview does not set a content security policy

5 participants