Skip to content

Modify CSP when Sentry is configured

Dominic Couture requested to merge csp-sentry into master

What does this MR do?

Fixes #337972 (closed)

This MR makes it so that the CSP adapts automatically when Sentry is configured in gitlab.yml.

At the moment the CSP is enabled only in dev, but in its current state configuring sentry would lead to CSP errors and would block reporting.

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (strongly suggested)

  1. Configure sentry settings (doesn't need to be valid sentry DSN for testing this)

      ## Error Reporting and Logging with Sentry
      sentry:
        enabled: true
        # dsn: https://<key>@sentry.io/<project>
        clientside_dsn: https://sentrykey@sentry.example.com/project
        environment: 'development' # e.g. development, staging, production
  2. Observe the clientside_dsn (with the key@ part) added to the CSP's connect-src directive in the dev tools or with curl

    $ curl -is https://gitlab.local:3443/ | grep -Eo 'connect-src [^;]*;'
    connect-src 'self' http://gitlab.local:3808 ws://gitlab.local:3808 https://sentry.example.com/project;

    (The gitlab.local:3808 part is the webpack dev server and is unrelated to this change)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Dominic Couture

Merge request reports