“style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/”。 'unsafe-inline' 关键字,哈希
Posted
技术标签:
【中文标题】“style-src \'self\' https://maxcdn.bootstrapcdn.com/bootstrap/”。 \'unsafe-inline\' 关键字,哈希【英文标题】:"style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/". Either the 'unsafe-inline' keyword, a hash“style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/”。 'unsafe-inline' 关键字,哈希 【发布时间】:2016-05-04 07:35:14 【问题描述】:我有一个网页托管在 jenkins 服务器上。
我看到在最新的詹金斯更新中有
所以我已经阅读了这篇精彩的 post 关于如何绕过此限制的文章
我已将此<meta>
添加到我的页面
但我不断收到控制台错误:
拒绝应用内联样式,因为它违反了以下内容安全策略指令:“style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/”。启用内联执行需要“unsafe-inline”关键字、哈希(“sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=”)或随机数(“nonce-...”)。
<head>
<title>Bidi: unknown bl version vs. 1.0.487</title>
<meta content="text/html; charset=utf-8 ;" http-equiv="content-type">
<meta content="style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/" http-equiv="Content-Security-Policy"><meta content="script-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/" http-equiv="Content-Security-Policy"><meta content="default-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/" http-equiv="Content-Security-Policy"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"><script type="script" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script><link rel="icon" href="/jenkins/view/QA/job/RoutingRegression/ws/src/main/resources/html_pages/images/favicon.png" type="image/gif" sizes="16x16"><link rel="stylesheet" href="/RoutingRegression/html_pages/css/delta_samples.css">
</head>
【问题讨论】:
【参考方案1】:我认为你应该阅读这个fantastic post 我使用
完全放松了我的 Jenkins 配置System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
【讨论】:
【参考方案2】:向元数据添加“unsafe-inline”属性。
<meta content="style-src 'self' 'unsafe-inline' https://maxcdn.bootstrapcdn.com/bootstrap/" http-equiv="Content-Security-Policy">
<meta content="script-src 'self' 'unsafe-inline' https://maxcdn.bootstrapcdn.com/bootstrap/" http-equiv="Content-Security-Policy">
【讨论】:
以上是关于“style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/”。 'unsafe-inline' 关键字,哈希的主要内容,如果未能解决你的问题,请参考以下文章