Giter Site home page Giter Site logo

Comments (3)

luke-belton avatar luke-belton commented on May 25, 2024

Hi @MakerTim - you should be able to use the redactedKeys config option to filter out breadcrumb metadata that contains sensitive data. Do you think this will work for your use case?

from bugsnag-php.

natepage avatar natepage commented on May 25, 2024

@MakerTim Hi! We've faced a similar situation in different projects and agree that sanitizing data within breadcrumbs is a bit tricky with the current implementation. It would be nice to see an easier way to do it in this package directly, in the meantime here is the code we are using to do so.

It's a little "magic" as we are using a closure that we bind to the report instance to modify the value of its $breadcrumbs property but it works 😄

// Our own sanitizer service
$sanitizer = $this->sensitiveDataSanitizer;

// Call registerCallback on Client
$bugsnag->registerCallback(static function (Report $report) use ($sanitizer): void {
    // First we sanitise the metadata of the report itself
    $report->setMetaData($sanitizer->sanitize($report->getMetaData()), false);

    // Fetch breadcrumbs from report array representation
    $breadcrumbs = $report->toArray()['breadcrumbs'] ?? [];
    $redactedBreadcrumbs = [];

    // Build our own breadcrumbs array with sanitized data
    foreach ($breadcrumbs as $breadcrumb) {
        if (isset($breadcrumb['metaData'])) {
            $breadcrumb['metaData'] = $sanitizer->sanitize($breadcrumb['metaData']);
        }

        $redactedBreadcrumbs[] = $breadcrumb;
    }

    // Override the value of $breadcrumbs property on report using bound closure
    (function ($property, $value): void {
        $this->{$property} = $value;
    })->call($report, 'breadcrumbs', $redactedBreadcrumbs);
});

from bugsnag-php.

johnkiely1 avatar johnkiely1 commented on May 25, 2024

Going to close this out as there are a couple of workaround options suggested above.

from bugsnag-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.