question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Trusted Types in EvalSourceMapDevToolPlugin

See original GitHub issue

Feature request

What is the expected behavior?

Say webpack is configured with output.trustedTypes = true and devtool = “eval-cheap-module-source-map”. I expect that generated code can still use eval but the script will be created using createScript method from Trusted Types policy.

What is motivation or use case for adding/changing the behavior?

This is needed when working with Trusted Types during local development. Passing string argument into eval() is forbidden when you enforce require-trusted-types-for 'script' CSP directive. This is exactly what EvalSourceMapDevToolPlugin is doing and therefore it is hard to debug such application locally.

How should this be implemented in your opinion?

We could probably follow similar approach as with CreateScriptUrlRuntimeModule and based on whether trusted types are enabled or not return either raw string or output of policy.createScript(). This value can then be passed to eval().

Are you willing to work on this yourself? yes

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
tosmolkacommented, Jan 20, 2022

@alexander-akait , @sokra , can we pls get a feedback on https://github.com/webpack/webpack/pull/14173? Happy to change the approach if you have any suggestions. Thank you.

0reactions
alexander-akaitcommented, Jan 20, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Trusted Types for DOM manipulation | Can I use... Support ...
An API that forces developers to be very explicit about their use of powerful DOM-injection APIs. Can greatly improve security against XSS attacks....
Read more >
Content Security Policies - webpack
Webpack is also capable of using Trusted Types to load dynamically constructed scripts, to adhere to CSP require-trusted-types-for directive restrictions.
Read more >
CSP: trusted-types - HTTP - MDN Web Docs
This directive declares an allowlist of trusted type policy names created with trustedTypes.createPolicy from Trusted Types API. Syntax. Content-Security-Policy ...
Read more >
Trusted Types - W3C
4 Should Trusted Type policy creation be blocked by Content Security Policy? 4.9.5 Violation object changes; 4.9.6 Support for dynamic code ...
Read more >
Update docs to reflect support status of trusted types #41637
bug report Affected Package Angular-CLI (webpack) and CSP trusted types integration. Is this a regression? Not that I can determine.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found