You are here

class SanitizeIntegration in Raven: Sentry Integration 3.x

Sanitizes sensitive data, such as passwords, before sending to Sentry.

Hierarchy

  • class \Drupal\raven\Integration\SanitizeIntegration implements \Sentry\Integration\IntegrationInterface

Expanded class hierarchy of SanitizeIntegration

1 file declares its use of SanitizeIntegration
Raven.php in src/Logger/Raven.php

File

src/Integration/SanitizeIntegration.php, line 16

Namespace

Drupal\raven\Integration
View source
class SanitizeIntegration implements IntegrationInterface {

  /**
   * This constant defines the mask string used to strip sensitive information.
   */
  const STRING_MASK = '********';

  /**
   * {@inheritdoc}
   */
  public function setupOnce() : void {
    Scope::addGlobalEventProcessor(function (Event $event) : Event {
      $currentHub = SentrySdk::getCurrentHub();
      $integration = $currentHub
        ->getIntegration(self::class);
      $client = $currentHub
        ->getClient();

      // The client bound to the current hub, if any, could not have this
      // integration enabled. If this is the case, bail out.
      if (NULL === $integration || NULL === $client) {
        return $event;
      }
      $this
        ->processEvent($event, $client
        ->getOptions());
      return $event;
    });
  }

  /**
   * {@inheritdoc}
   */
  private function processEvent(Event $event, Options $options) : void {
    $request = $event
      ->getRequest();
    if (!empty($request['data']['pass'])) {
      $request['data']['pass'] = self::STRING_MASK;
    }
    $event
      ->setRequest($request);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SanitizeIntegration::processEvent private function
SanitizeIntegration::setupOnce public function
SanitizeIntegration::STRING_MASK constant This constant defines the mask string used to strip sensitive information.