8000 Redacting/scrubbing by jessarcher · Pull Request #203 · laravel/nightwatch · GitHub
[go: up one dir, main page]

Skip to content

Redacting/scrubbing #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2025
Merged

Redacting/scrubbing #203

merged 2 commits into from
Jun 30, 2025

Conversation

jessarcher
Copy link
Member
@jessarcher jessarcher commented Jun 27, 2025

This PR adds support for redacting/scrubbing several fields that could contain sensitive data.

// AppServiceProvider.php

use Laravel\Nightwatch\Facades\Nightwatch;
use Laravel\Nightwatch\Records\CacheEvent;
use Laravel\Nightwatch\Records\Command;
use Laravel\Nightwatch\Records\Mail;
use Laravel\Nightwatch\Records\OutgoingRequest;
use Laravel\Nightwatch\Records\Query;
use Laravel\Nightwatch\Records\Request;

Nightwatch::redactCacheEvents(function (CacheEvent $cacheEvent) {
    $cacheEvent->key = str_replace('secret', '***', $cacheEvent->key);
});

Nightwatch::redactCommands(function (Command $command) {
    $command->command = str_replace('secret', '***', $command->command);
});

Nightwatch::redactMail(function (Mail $mail) {
    $mail->subject = str_replace('secret', '***', $mail->subject);
});

Nightwatch::redactOutgoingRequests(function (OutgoingRequest $outgoingRequest) {
    $outgoingRequest->url = str_replace('secret', '***', $outgoingRequest->url);
});

Nightwatch::redactQueries(function (Query $query) {
    $query->sql = str_replace('secret', '***', $query->sql);
});

Nightwatch::redactRequests(function (Request $request) {
    $request->url = str_replace('secret', '***', $request->url);
    $request->ip = str_replace('secret', '***', $request->ip);
});

@jessarcher jessarcher marked this pull request as ready for review June 27, 2025 10:06
@jessarcher jessarcher requested a review from timacdonald June 27, 2025 10:11
Copy link
Member
@timacdonald timacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@jessarcher jessarcher merged commit d9ac331 into 1.x Jun 30, 2025
25 checks passed
@jessarcher jessarcher deleted the redact branch June 30, 2025 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0