如何将nonce或sha添加到表格的内容安全策略中

发布于 2025-01-30 11:17:17 字数 611 浏览 2 评论 0原文

我正在尝试实施CSP,到目前为止,直到我可以跨越具有大型形式的页面。

我已经在“脚本src”中添加了一个“ nonce”,但是当生成表单时,它添加了一个自动标签,我不知道如何添加安全或如何为其生成SHA值。

对于先前的SHA值,它已在控制台面板中列出,因此我添加了它们,但是对于这些自动化的值,它只是在下面丢弃了错误,而没有其他内容可以缩小范围:

拒绝执行内联脚本,因为它违反了以下内容Content Security Policy directive: "script-src https: nonce-123 'sha256-123=' 'unsafe-inline' 'unsafe-eval'".请注意,如果源列表中存在哈希值或nonce值。

我检查了此线程将nonce属性添加到自动生成的webforms脚本,但我不明白他如何生成SHA值以添加到CSP中?

如何计算或添加nonce的表单自动脚本?

I am attempting to implement a CSP and so far it was ok until i can across a page with a large form.

I have added a 'nonce' to 'script src' but when the form is generated it adds an automated tag that i dont know either how to add as safe or how to generate the sha value for it.

For previous sha values it was listed in the console panel so i added them but for these automated ones it just throws the error below and nothing else to narrow it down:

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src https: nonce-123 'sha256-123=' 'unsafe-inline' 'unsafe-eval'". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.

I checked this thread Add nonce attribute to auto-generated WebForms script but i dont understand how he generated the sha value to add to the CSP?

How could i calculate or add a nonce to this automated script for a form?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文