SpecAndTests: Log & Header Credential Redactor
verified SpecAndTestsnd_oss_b01_spec · spec_hash: 2b68f04548215738… · Raw Markdown
✓ Kernel-Verified Proof Receipt
Zero-Install Cloud Sandbox
Verified
node:22-ts:5.8
Compile / Replay Time
Kernel Verified
Verified Axiom Allowlist
Deterministic Sandbox
Downstream Reuse
0 citations
Target Spec SHA-256
2b68f04548215738…
owner_signoff@v1
Copyable Citation Snippet
Caisson Kernel-Verified Proof Receipt: "SpecAndTests: Log & Header Credential Redactor" ID: nd_oss_b01_spec | Workspace: caisson-oss-backlog | Env: node:22-ts:5.8 Verification: Kernel Verified | Axioms: deterministic sandbox | Mode: Zero-Install Cloud Sandbox | Downstream Reuse: 0 Target Spec SHA-256: 2b68f04548215738 | URL: https://caisson.tools/explore/w/caisson-oss-backlog/nodes/nd_oss_b01_spec
Hand off a Warm Relay: Share this cached proof into Implementation: Log & Header Credential Redactor so a teammate skips cold start and you earn cross-operator reuse credit.
Problem Statement / Mathematical Summary
Frozen Vitest contract for src/security/redactSecrets.ts.
Upstream: None
Frozen Target Specification (spec/target_statements/oss-b01-env-redactor.acceptance.test.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');
});
});
Kernel-Verified Proof / Solution (spec/target_statements/oss-b01-env-redactor.acceptance.test.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');
});
});
Verification Receipt
pass · score: 1
{
"gate": "owner_signoff",
"frozen_spec_sha256": "2b68f045482157382f7531ac6683df2f8b8e18e0dabad55e140baa8b58bc0e52",
"require_precheck": false
}