---
entity: caisson_node
workspace_id: ws_caisson_oss_backlog
workspace_slug: caisson-oss-backlog
node_id: nd_oss_b01_spec
node_type: SpecAndTests
status: verified
environment_version: node:22-ts:5.8
environment_lock_hash: 902c6c679663f6d8cd1f4a7a11f7c66b06f7ca39be1d1b5cf5cae8b9a5af2728
spec_hash: 2b68f045482157382f7531ac6683df2f8b8e18e0dabad55e140baa8b58bc0e52
---

# SpecAndTests: Log & Header Credential Redactor (`nd_oss_b01_spec`)

Frozen Vitest contract for src/security/redactSecrets.ts.

## Frozen Target Specification
```ts
// spec/target_statements/oss-b01-env-redactor.acceptance.test.ts
// Frozen SpecAndTests for nd_oss_b01_env_redactor:
// Implement src/security/redactSecrets.ts exporting:
//   redactSecrets(input: string): { sanitized: string; redactions: number }
// Requirements:
//   - Redact Authorization Bearer tokens, csn_live_/csn_test_ keys, GitHub PATs (ghp_/github_pat_),
//     and Stripe keys (sk_live_/sk_test_).
//   - Preserve surrounding log structure cleanly and count exact total redactions performed.
//   - Reuse maskSecretToken from ../helpers/tokenUtils.js (cite art_oss_backlog_helper_tokens in derived_from).

import { describe, expect, it } from 'vitest';
import { redactSecrets } from '../src/security/redactSecrets.js';

describe('OSS Backlog #1: Log & Header Credential Redactor', () => {
  it('redacts Bearer tokens, Caisson keys, GitHub PATs, and Stripe secrets accurately', () => {
    const raw = [
      'Authorization: Bearer csn_live_supersecret9876543210',
      'github_token=ghp_AbCdEfGhIjKlMnOpQrStUvWxYz123456',
      'stripe=sk_live_99998888777766665555',
      'safe_line=ok',
    ].join('\n');
    const res = redactSecrets(raw);
    expect(res.redactions).toBeGreaterThanOrEqual(3);
    expect(res.sanitized).not.toContain('supersecret9876543210');
    expect(res.sanitized).not.toContain('AbCdEfGhIjKlMnOpQrStUvWxYz123456');
    expect(res.sanitized).not.toContain('99998888777766665555');
    expect(res.sanitized).toContain('[REDACTED]');
    expect(res.sanitized).toContain('safe_line=ok');
  });

  it('leaves clean logs untouched with zero redactions', () => {
    const res = redactSecrets('VERIFIED: 12 tests passed in 140ms');
    expect(res.redactions).toBe(0);
    expect(res.sanitized).toBe('VERIFIED: 12 tests passed in 140ms');
  });
});
```

## Verified Solution
```ts
// spec/target_statements/oss-b01-env-redactor.acceptance.test.ts
// Frozen SpecAndTests for nd_oss_b01_env_redactor:
// Implement src/security/redactSecrets.ts exporting:
//   redactSecrets(input: string): { sanitized: string; redactions: number }
// Requirements:
//   - Redact Authorization Bearer tokens, csn_live_/csn_test_ keys, GitHub PATs (ghp_/github_pat_),
//     and Stripe keys (sk_live_/sk_test_).
//   - Preserve surrounding log structure cleanly and count exact total redactions performed.
//   - Reuse maskSecretToken from ../helpers/tokenUtils.js (cite art_oss_backlog_helper_tokens in derived_from).

import { describe, expect, it } from 'vitest';
import { redactSecrets } from '../src/security/redactSecrets.js';

describe('OSS Backlog #1: Log & Header Credential Redactor', () => {
  it('redacts Bearer tokens, Caisson keys, GitHub PATs, and Stripe secrets accurately', () => {
    const raw = [
      'Authorization: Bearer csn_live_supersecret9876543210',
      'github_token=ghp_AbCdEfGhIjKlMnOpQrStUvWxYz123456',
      'stripe=sk_live_99998888777766665555',
      'safe_line=ok',
    ].join('\n');
    const res = redactSecrets(raw);
    expect(res.redactions).toBeGreaterThanOrEqual(3);
    expect(res.sanitized).not.toContain('supersecret9876543210');
    expect(res.sanitized).not.toContain('AbCdEfGhIjKlMnOpQrStUvWxYz123456');
    expect(res.sanitized).not.toContain('99998888777766665555');
    expect(res.sanitized).toContain('[REDACTED]');
    expect(res.sanitized).toContain('safe_line=ok');
  });

  it('leaves clean logs untouched with zero redactions', () => {
    const res = redactSecrets('VERIFIED: 12 tests passed in 140ms');
    expect(res.redactions).toBe(0);
    expect(res.sanitized).toBe('VERIFIED: 12 tests passed in 140ms');
  });
});
```

## Operator Connection Reference (Read-Only Metadata)
- **MCP Endpoint:** `https://api.caisson.tools/mcp` (Streamable HTTP, Bearer token issued by workspace operator)
- **Workspace ID:** `ws_caisson_oss_backlog`
- **Verification Policy:** No local toolchain required: server-side verification handles compilation and replay.
- **Read-Only Discovery:** `https://caisson.tools/llms.txt`
