Skip to content

Add error tracking client key

Dmytro Zaporozhets (DZ) requested to merge dz-error-tracking-dsn-auth into master

What does this MR do?

Adds error tracking client key that is required by sentry sdk. Check public key is valid in collector.

Key points:

  1. We are building sentry compatible backend.
  2. We pass URL to sentry sdk. This URL is called DSN. DSN contains hash known as public key.
  3. Sentry sdk will call our API every time exception is triggered. It will pass the public key in header.
  4. To do some basic protection against abuse, we check if public key is valid.

This merge request is part of a bigger plan. Issue => #329596 (closed)

To read more about sentry DSN => https://docs.sentry.io/product/sentry-basics/dsn-explainer

Collector was implemented in !65767 (merged). This MR adds is somewhat a follow-up to it.

FYI: The feature is behind a feature flag while its in active development stage.

Database

The table will contain client keys for those of projects that have error tracking feature enabled (disabled by default). Usually it will be only 1-2 keys per project.

rake db:migrate
== 20210720130006 CreateErrorTrackingClientKeys: migrating ====================
-- create_table(:error_tracking_client_keys, {})
-- quote_column_name(:public_key)
   -> 0.0000s
   -> 0.0083s
-- quote_table_name("check_840b719790")
   -> 0.0000s
-- quote_table_name(:error_tracking_client_keys)
   -> 0.0000s
-- execute("ALTER TABLE \"error_tracking_client_keys\"\nADD CONSTRAINT \"check_840b719790\" CHECK (char_length(\"public_key\") <= 255)\n")
   -> 0.0006s
== 20210720130006 CreateErrorTrackingClientKeys: migrated (0.0156s) ===========
rake db:rollback
== 20210720130006 CreateErrorTrackingClientKeys: reverting ====================
-- drop_table(:error_tracking_client_keys)
   -> 0.0060s
== 20210720130006 CreateErrorTrackingClientKeys: reverted (0.0060s) ===========

Security

  1. This merge request stores public_key token in database as plain text => !66466 (comment 632113638)
  2. This MR checks public_key from auth headers against one stored in database => !66466 (comment 632114618)
  3. Because auth mechanism is easily exposed, we limit its use only to submission of new events. We don't return any information. Its basically spam protection, rather than auth.

Screenshots or Screencasts (strongly suggested)

No UI changes

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