gpt4 book ai didi

java - 如何使用特定模式的 CSP header URL

转载 作者:行者123 更新时间:2023-11-30 06:45:14 27 4
gpt4 key购买 nike

很少有像这样的网址 http://aa.bb.dd.com http://aa.bb1.dd.com

我使用如下模式添加了 CSP 白名单 url,

http://*.bb*.*.com

但是我得到一个错误

The source list for Content Security Policy directive 'script-src' contains an invalid source: 'https://*.bb*.*.com'. It will be ignored

如何添加模式以允许 bb* (aa.bb1.dd.com, aa.bb2.dd.com etc..,)?

最佳答案

你不能。

规范列出主机如下:

; Hosts: "example.com" / "*.example.com" / "https://*.example.com:12/path/to/file.js"
host-source = [ scheme-part "://" ] host-part [ port-part ] [ path-part ]
scheme-part = scheme
; scheme is defined in section 3.1 of RFC 3986.
host-part = "*" / [ "*." ] 1*host-char *( "." 1*host-char )
host-char = ALPHA / DIGIT / "-"
port-part = ":" ( 1*DIGIT / "*" )
path-part = path-abempty
; path-abempty is defined in section 3.3 of RFC 3986.

即主机可以是*,也可以*开头。它们的中间或末尾不能有 *。

因此您可以拥有 *.dd.com(但不是 *.*.dd.com)。

老实说,随意使用通配符会带来安全问题并打败使用 CSP 的意义,因为我可以通过使用其中包含 bb 的子域(例如 http://www.bb.baddomain.com)从任何域加载资源。

关于java - 如何使用特定模式的 CSP header URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49265837/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com