【问题标题】:Content Security Policy violation onmouseout内容安全策略违反 onmouseout
【发布时间】:2017-01-09 19:48:09
【问题描述】:

我已经在我的应用程序上实施了内容安全策略,现在它在仅报告模式下进行测试。在适当调整政策后,我得到了很多类似这样的报告:

{
    "csp-report": {
        "blocked-uri": "self",
        "document-uri": "https://example.com/path/to/app/page.php",
        "original-policy": "script-src 'nonce-DrZQpFyD2k9sGWT5' https://example.com https://ajax.googleapis.com https://maps.googleapis.com; default-src https://example.com; style-src https://example.com 'unsafe-inline' https://maxcdn.bootstrapcdn.com; img-src * data:; font-src https://example.com https://maxcdn.bootstrapcdn.com; frame-src https://example.com; frame-ancestors https://example.com; form-action *; report-uri https://<>.report-uri.io/r/default/csp/reportOnly",
        "script-sample": "onmouseout attribute on DIV element",
        "source-file": "https://example.com/path/to/app/page.php?id=143",
        "violated-directive": "script-src 'nonce-DrZQpFyD/k9sGWT5' https://example.com https://ajax.googleapis.com https://maps.googleapis.com https://code.jquery.com/ "
    }
}

该应用程序的大多数用户使用 Chrome,但这些报告完全来自 Firefox。有时脚本示例会显示onmouseover 或其他一些鼠标事件。我查看了应用程序中的所有代码,没有任何地方使用属性鼠标事件。

关于造成这种情况的任何想法?

【问题讨论】:

标签: javascript firefox content-security-policy


【解决方案1】:

很难确定。然而,一种可能性是您的一些用户安装了浏览器插件,这些插件将 HTML 注入您的页面,其中包含内联事件处理程序(如onmouseout,在这种情况下)。

很难检测到这一点。无法枚举用户已安装的插件;我知道的唯一选择是:

  1. 找出您的哪些用户触发了此错误并直接与他们联系——这只有在您与用户关系密切的情况下才可行。

  2. 开始安装流行的 Firefox 插件!最终,您可能会找到负责的人。 (但你可能不会。它可能是一个私人插件,或者一个 Greasemonkey 脚本。)

【讨论】:

    猜你喜欢
    • 2022-10-18
    • 2016-07-19
    • 2021-12-07
    • 2022-01-12
    • 2021-03-14
    • 2019-04-06
    • 2021-12-15
    • 2014-11-29
    相关资源
    最近更新 更多