问题描述
我有两个功能,想允许使用功能c。我能怎么做?
永远不要更改脚本。仅阻止函数b()...
<script nonce="12345">
function b() { return 'b'; }
</script>
<!-- allow me -->
<script nonce="12345">
function c() { return 'c'; }
</script>
解决方法
在这种情况下,只需使用不同的nonce
值,然后在您的CSP中仅允许其中之一。
Content-Security-Policy: script-src 'nonce-[allowed nonce value]'