Commit Graph

4 Commits

Author SHA1 Message Date
alexander.akait 9894226149 refactor(types): more 2023-06-14 19:46:53 +03:00
alexander.akait 620c8d5fa4 refactor: more types 2023-05-24 22:37:58 +03:00
Michael Zlatkovsky 2203e24900 Add option to continue on trusted-types policy-creation failure
Webpack already allows for specifying a trusted-types policy name. However, its current implementation is such that if a call to trustedTypes.createPolicy fails, the code will immediately stop executing. This isn't necessarily desirable, as an application could be in the early phases of rolling out trusted types, and thus have the CSP rule for trusted-types LibraryA LibraryB etc, BUT have require-trusted-types-for 'script' be in "report only" mode (Content-Security-Policy-Report-Only). In such a configuration, and when the webpacked code is dynamically-loaded into an application, adding the policy name to the webpack config will break old versions.

This PR keeps the original behavior, but introduces a new option for onPolicyCreationFailure: "continue" | "stop" (with "stop" remaining the default). If a developer chooses the "continue" option, the policy-creation will be wrapped in a try/catch. There is no security risk to this, since for host applications that DO have strict enforcement of trusted-types, the code will simply fail when the dangerous sink is used (e.g., when doing parseFromString). And likewise, wrapping in try/catch and doing nothing on catch is OK, because the code already deals with the possibility of the trustedTypes API not being available on the browser.
2023-05-02 10:12:56 -07:00
Tobias Smolka 1339272be6 Support Trusted Types in EvalSourceMapDevToolPlugin 2021-09-08 12:34:00 +02:00