test: add fast-check property-based tests (sanitizers, LineBuffer, DAP framing)#162
Merged
Conversation
…tadata, untrack Go example binary Three OpenSSF Scorecard fixes: - Token-Permissions (currently 0/10): move 'security-events: write' in codeql.yml and 'contents: write' + 'pull-requests: write' in dependabot-auto-merge.yml from the workflow top level down to the single job that needs them; top level becomes 'contents: read'. Top-level write permissions zero this check; job-level writes are accepted least-privilege. - Pinned-Dependencies: pin dependabot/fetch-metadata to the v3.1.0 commit SHA -- the only remaining non-SHA 'uses:' across all seven workflows. - Binary-Artifacts (9/10): untrack examples/go/hello_world/hello_world, a 2.4 MB compiled Go ELF that slipped into the index before the .gitignore rule (line 203) existed. The example builds from source. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ing, and DAP framing Three new property test files (12 properties total): - env-sanitizer: generated secret shapes (ghp_/github_pat_/sk-/xox*/ AKIA/PEM) never survive sanitizeStderr or sanitizeStderrTail; env objects at any payload depth are always redacted; key-set/structure preservation and idempotency of sanitizeEnvForLogging. - LineBuffer: chunking invariance (any split of any input produces the same lines as the unsplit input -- the exact guarantee the stderr redaction path depends on, issue #151), plus the maxPendingLength memory bound with no data loss. - MinimalDapClient framing: generated DAP event streams survive arbitrary byte-level chunk splits (including mid-UTF-8-character) losslessly and in order; any two chunkings agree. Mutation-verified: weakening a sanitizer regex fails the properties within ~10 generated cases. fast-check is also what the OpenSSF Scorecard Fuzzing check recognizes for JS/TS (currently 0/10). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
# Conflicts: # pnpm-lock.yaml
…und by property tests The first CI run of the new fast-check properties generated an env key named '__proto__' and caught a real bug: 'sanitized[key] = value' routes through the Object.prototype setter, so the entry silently vanishes from sanitizeEnvForLogging output -- and in redactEnvDeep an object value would replace the output object's prototype instead of being copied. Assign via Object.defineProperty (own, enumerable, writable) in both sanitizers. The property generators now always include '__proto__', 'constructor', 'hasOwnProperty' and 'toString' in the key pool, plus an example-based regression test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
The first CI run of these property tests caught a real bug: fast-check generated an env key named |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
fast-checkand 12 property-based tests in 3 files — genuine coverage for the recently-hardened security-sensitive paths, and the integration OpenSSF Scorecard's Fuzzing check recognizes for JS/TS (currently 0/10, +0.51 aggregate expected):env-sanitizer.property.test.ts— generated secret shapes (ghp_*,github_pat_*,sk-*,xox?-*,AKIA*, PEM headers) never survivesanitizeStderr/sanitizeStderrTailwherever they sit on a line; env objects at any payload depth are always redacted bysanitizePayloadForLogging;sanitizeEnvForLoggingpreserves key sets and is idempotent. (Follows up the Proxy init failure dumps full environment (including secrets) into the MCP tool error response #146/Proxy stderr sanitization is per-chunk, not per-line: a secret split across a stream chunk can leak its tail #151/Worker's adapter-stderr capture is unsanitized and per-chunk: adapter secrets can reach proxy logs verbatim #153 leak audits.)line-buffer.property.test.ts— chunking invariance: any split of any input yields the same lines as the unsplit input (the exact guarantee the stderr redaction path depends on), plus themaxPendingLengthmemory bound with zero data loss.minimal-dap-framing.property.test.ts— generated DAP event streams survive arbitrary byte-level chunk splits (including mid-UTF-8-character) losslessly and in order.Verification
AKIA[0-9A-Z]{16}→{99}) fails the properties within ~10 generated cases; reverting restores green.🤖 Generated with Claude Code