@lidofinance/secret-guard-reporter
v1.1.0
Published
A Playwright reporter that automatically scrubs sensitive values (secrets, tokens, private keys) from all test output before it reaches other reporters or is written to disk.
Downloads
1,481
Readme
Secret Guard Reporter
A Playwright reporter that automatically scrubs sensitive values (secrets, tokens, private keys) from all test output before it reaches other reporters or is written to disk.
Install
yarn add @lidofinance/secret-guard-reporterUsage
Use as the only top-level reporter and list all other reporters inside the reporters option. SecretGuard scrubs every piece of data before forwarding it to the inner reporters, and scrubs the report directory at the end of the run.
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
[
'@lidofinance/secret-guard-reporter',
{
sensitiveEnvKeys: ['WALLET_SECRET_PHRASE', 'WALLET_PASSWORD'],
reporters: [
['html', { open: 'never' }],
['list'],
],
},
],
],
});Options
| Option | Type | Required | Default | Description |
|--------------------|-------------------|----------|-----------------------|-------------|
| sensitiveEnvKeys | string[] | ✅ | — | Env variable names whose runtime values will be redacted everywhere. |
| reporters | [string, any?][]| — | [] | Inner reporters to wrap. Supports all built-in Playwright reporter names and third-party paths. |
| reportDir | string | — | 'playwright-report' | Directory to scrub after the run (HTML report, traces, etc.). |
How it works
During tests —
onStdOut/onStdErrscrub real-time output chunks before forwarding to inner reporters.onTestEndscrubsstdout,stderr, error messages, stack traces, and attachment files in-place, then forwards the clean data.After all tests —
onEndawaits each inner reporter'sonEnd(so the HTML reporter finishes writing its files first), then scrubs every text-based file inreportDirand re-encodes any base64-embedded ZIP trace archives found inindex.html.
Scrubbed surfaces:
- Real-time
stdout/stderrstream chunks stdout/stderrchunks inTestResult- Error messages and stack traces
- Text-based attachment files (
.html,.json,.txt,.log,.har,.md,.xml) - ZIP trace archives (
.zipattachments) - All text-based files in
reportDirafter the run - Base64-embedded ZIPs inside
reportDir/index.html
reportDir should match the outputFolder of your HTML reporter (or wherever Playwright writes its report). Defaults to 'playwright-report'. Set it explicitly if you use a custom path:
['@lidofinance/secret-guard-reporter', {
sensitiveEnvKeys: ['WALLET_SECRET_PHRASE'],
reportDir: 'my-custom-report',
reporters: [['html', { outputFolder: 'my-custom-report' }]],
}]Safety: Values shorter than 5 characters are ignored to avoid false positives.
License
MIT
