有一个wordpress主题,自动拉取选择字体选择并从谷歌字体请求它.当几个选定页面需要ssl时,字体就变成了missing
查看控制台日志:
[已屏蔽]" https://www.example.com/ "上的页面是通过HTTPS加载的,但是运行了来自" http://fonts.googleapis.com/css?family=Alegreya+Sans:300,400,500,700,800 "的不安全内容:此内容也应通过HTTPS加载.
会进入代码并使用谷歌字体的所有https请求工作吗?这有什么解决方法吗?
找到了源代码......但好像它已经在做了这个......在if逻辑中会出现错误吗?
$prefix = "http";
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') $prefix = "https";
if($get_google_font){
if(!in_array($rule_split[0], $this->used_fonts))
{
$this->extra_output .= "\n<!-- google webfont font replacement -->\n";
$this->extra_output .= '<link id="google_webfont_'.$this->webfont_count.'" rel="stylesheet" type="text/css" href="'.$prefix.'s://fonts.googleapis.com/css?family='.str_replace(' ','+',$rule_split[0]).$font_weight.'" />';
}
Run Code Online (Sandbox Code Playgroud) 我对Jenkins内容安全策略感到困惑.
我知道这些网站:
我有一个通过Jenkins Clover插件显示的html页面.这个html页面使用内联样式,例如:
<div class='greenbar' style='width:58px'>
Run Code Online (Sandbox Code Playgroud)
div元素可视化进度条.使用默认的Jenkins CSP配置会产生以下结果: Progressbar_FAIL
我想要的结果如下: Progressbar_WORKS
我试图放松CSP规则,添加不同级别的参数(script-src,style-src)的不同组合(self,unsafe-inline,..)但没有任何作用.
所以我现在的问题是:
更新
1.尝试:
-Dhudson.model.DirectoryBrowserSupport.CSP="default-src 'self'
在jenkins.xml文件中.然后发生以下错误:
拒绝应用内联样式,因为它违反了以下内容安全策略指令:"default-src'self'".要求内联执行,需要'unsafe-inline'关键字,散列('sha256-')或nonce('nonce -...').另请注意,'style-src'未明确设置,因此'default-src'用作后备.
2.尝试
-Dhudson.model.DirectoryBrowserSupport.CSP="default-src 'self'; style-src 'self' jenkins.xml文件.然后发生以下错误:
拒绝应用内联样式,因为它违反了以下内容安全策略指令:"style-src'self'".要启用内联执行,需要'unsafe-inline'关键字,散列('sha256-')或nonce('nonce -...')
我明白这个尝试无法解决我的问题,因为default-src包含style-src
3.尝试
-Dhudson.model.DirectoryBrowserSupport.CSP="default-src 'self'; style-src 'unsafe-inline' jenkins.xml文件.然后发生以下错误:
拒绝加载样式表s://jenkins/andsomedir/stylesheet.css [其https:// ...不允许发布两个以上的链接:(]因为它违反了以下内容安全策略指令:"style-src "不安全的内联"".
我试图.html在Jenkins中使用HTML发布者插件报告我的文件,但是由于HTML发布者已更新到版本1.10,因此无法发布HTML.
我收到的错误消息:
Blocked script execution in '{mydomain}' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': The document is sandboxed and lacks the 'allow-same-origin' flag.
Run Code Online (Sandbox Code Playgroud)
我找到了这个文档:https: //wiki.jenkins-ci.org/display/JENKINS/Configuring+Content+Security+Policy
它讲述了CSP.
我用arg运行Jenkins:
/usr/bin/java -Djava.awt.headless=true -Dhudson.model.DirectoryBrowserSupport.CSP=sandbox allow-scripts; style-src 'unsafe-inline' *;script-src 'unsafe-inline' *; -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 --ajp13Port=-1
Run Code Online (Sandbox Code Playgroud)
但仍然有同样的错误.
我试过args:
1. -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox; default-src 'self';"
2. -Dhudson.model.DirectoryBrowserSupport.CSP=
3. -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox; default-src *;"
4. -Dhudson.model.DirectoryBrowserSupport.CSP="sandbox allow-scripts; default-src *;"
Run Code Online (Sandbox Code Playgroud)
.html位于:
{mydomain}/job/{job_name}/Doc/index.html
Run Code Online (Sandbox Code Playgroud) 我需要向 webpack 创建的内联脚本添加一个随机数,但我找不到任何关于如何配置它的文档。我找到了这个公关:https : //github.com/webpack/webpack/pull/3210/files但我不知道如何__webpack_nonce__在我的开发环境中进行设置。
我嵌入了这样的分析:
<script type="text/javascript" async="" src="http://www.google-analytics.com/plugins/ua/linkid.js"></script>
Run Code Online (Sandbox Code Playgroud)
然后我将一些谷歌域名添加到CSP中,如下所示:
BrowserPolicy.content.allowScriptOrigin("*.google-analytics.com");
BrowserPolicy.content.allowImageOrigin("*.google.com");
Run Code Online (Sandbox Code Playgroud)
这样可以很好地加载,但是一旦Google Analytics尝试发送一些跟踪信息,它有时会尝试从google.pl加载图片(基于位置).有没有办法确保只使用.com?我显然无法列出CSP标头中的所有谷歌域名.
确切的错误是:
拒绝加载图片" https://www.google.pl/blabla ",因为它违反了以下内容安全策略指令:"img-src data:' self'http://*.doubleclick.net https://*.doubleclick.net http://*.facebook.com https://*.facebook.com http://*.google.com https://*.google.com http://www.google-analytics .com https://www.google-analytics.com ".
如果它很重要,这里使用的框架是:Meteor 1.3.5.1和浏览器策略包browser-policy@1.0.9
出于安全目的,我在我的公共站点中实现了 CSP 标头,并重构了代码以删除任何内联 javascript 实例,如 onclick=foo()和<a href='javascript: bar()'。
我们最近与将代码注入页面的第 3 方集成。每个面向公众的页面都需要这样做。问题是他们的代码包含大量内联 javascript(与上面提到的相同)并且违反了我们禁止内联脚本的 CSP 标头。
我的理解是,如果您必须'unsafe-inline'为脚本添加内容,那么由于存在剩余的安全风险,您还不如根本不实施 CSP。
我们能够更改每页的 CSP 标头,但由于每个页面都需要代码,因此似乎要么全部要么全无。
看起来您不能'unsafe-inline'只允许页面的特定部分,或者我们可以只允许该部分。
是我允许'unsafe-inline'和打败 CSP 的唯一选择吗?
在解析XML文件时,Stax会产生错误:
Unicode(0xb)错误 - 在文档的元素内容中找到了无效的XML字符(Unicode:0xb).
只需点击下面的链接,使用带有特殊字符"x"的xml行.它不是一个字母字符:当你尝试将它复制并粘贴到记事本中时,你会将它作为一些符号.我尝试使用Stax解析它.它显示出上述错误.
请有人能给我一个解决方案吗?
提前致谢.
我们在Magento商店的购物车页面上收到了大量混合内容错误
Mixed Content: The page at 'https://www.magento.com/onestepcheckout/index/' was loaded over HTTPS, but requested an insecure stylesheet 'http://fonts.googleapis.com/css?family=Lato:400,300,700,900'. This request has been blocked; the content must be served over HTTPS.
Run Code Online (Sandbox Code Playgroud)
我可以看到google字体文件是通过http在我们主题的head部分调用的
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
Run Code Online (Sandbox Code Playgroud)
我想知道如果我将上面的行更改为以下是解决此问题的最佳方法是什么:
选项1
<link href='https://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
Run Code Online (Sandbox Code Playgroud)
或 选项2
<link href='//fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
Run Code Online (Sandbox Code Playgroud)
考虑到我们大多数网站使用http,哪种方法最好?我不知道选项2,这似乎是一个非常好的方法.
我在我的网站中使用 gmaps 显示地图。
我的代码
<div class="col-md-12" >
<script type="text/javascript" content="zk.googleAPIkey='***MyKey***'" />
<gmaps id="gmaps" zoom="${initialZoom}" lat="${initialLatitude}" lng="${initialLongitude}" width="100%" height="350px" showSmallCtrl="false" >
<gmarker id="marker" content="" visible="${false}" />
</gmaps>
</div>
Run Code Online (Sandbox Code Playgroud)
在我的本地服务器中工作正常,但在我的生产服务器中https不起作用,并且出现此错误:
例外
zk.wpd:20 Mixed Content: The page at 'https://www.domain.com/' was loaded over HTTPS, but requested an insecure script 'http://www.google.com/jsapi?key=***MyKey***'. This request has been blocked; the content must be served over HTTPS.loadScript @ zk.wpd:20
Run Code Online (Sandbox Code Playgroud) 我目前有以下问题
Mixed Content: The page at 'https://www.example.com/' was loaded over HTTPS, but requested an insecure stylesheet
Run Code Online (Sandbox Code Playgroud)
这是httpd安装了Centos服务器上的Wordpress网站。
我在`http.conf中有以下虚拟主机设置:
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:443>
DocumentRoot /var/www/html/example
ServerName www.example.com
ServerAlias example.com
SSLEngine on
SSLCACertificateFile /etc/httpd/conf/ssl.crt/intermediate.crt
SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/server.key
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
Redirect / https://www.example.com/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
在我这里,httpd.conf我改变AllowOverride了所有,所以看起来像这样:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
我可以确认htaccess正在使用iTheme安全插件,并且可以正常运行,如果在“我”中输入了一些垃圾,也会htacces收到服务器配置错误。
我已经更改了仪表板中的两个Wordpress URL来https代替http。 …
目前,我在Apache中的CSP配置看起来像这样:
Header set Content-Security-Policy "default-src 'self' 'unsafe-inline' https:"
Run Code Online (Sandbox Code Playgroud)
我想删除该unsafe-inline指令以提高我网站的安全性,请参阅Mozilla的Observatory.
然而,每当我删除它时,我的浏览器控制台都会显示一个错误,指示内联GA无法加载...
有解决方法吗?