# 查找 CSP 违规错误的更多信息

**URL:** https://meta.discourse.org/t/finding-more-information-about-csp-violation-error/166868
**Category:** Support
**Created:** [2020年十月10日 20:40 UTC](https://meta.discourse.org/t/finding-more-information-about-csp-violation-error/166868 "2020-10-10T20:40:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [2020年十月10日 20:40 UTC](https://meta.discourse.org/t/finding-more-information-about-csp-violation-error/166868/1 "2020-10-10T20:40:40Z")

</div>

我注意到日志中有一些奇怪的条目。看起来有几个来自未知域和 JSONP 的 CSP 违规错误。

有没有办法查明触发该错误的访问者信息（如 IP 地址或用户名）？如果用户在 Discourse 编辑器中粘贴了该 URL，是否会触发此类错误？我认为他们无法利用这一点，但了解这是否由特定用户引发会很有帮助。

```plaintext
Message

CSP Violation: 'https://shady_domain.com/some_dir/some_path?jsonp=some_params'

Backtrace

/var/www/discourse/app/controllers/csp_reports_controller.rb:9:in `create'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.3/lib/abstract_controller/base.rb:195:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.3/lib/action_controller/metal/rendering.rb:30:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/actionpack-6.0.3.3/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/callbacks.rb:112:in `block in run_callbacks'
/var/www/discourse/app/controllers/application_controller.rb:354:in `block in with_resolved_locale'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n.rb:313:in `with_locale'
/var/www/discourse/app/controllers/application_controller.rb:354:in `with_resolved_locale'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.3/lib/active_support/callbacks.rb:121:in `block in run_callbacks'

Env

HTTP HOSTS: forum.example.com

```

我已在日志和数据库中搜索过，但未能找到该 URL。看起来这是通过 [Logster](https://github.com/discourse/discourse/blob/724d2e99de9ed0d5331eb67458e2ab3f0d978d98/app/controllers/csp_reports_controller.rb#L8) 完成的。Logster 文档指出日志的默认位置是 `/var/log/logster`，但在主机上的 `/var/discourse/shared/standalone/log/var-log` 或应用容器内的 `/var/log` 中我都未看到这些日志。
