Repository navigation
Conversation
Signed-off-by: Nik Cubrilovic <[email protected]>
Review of the capture tool found gaps in what it scrubs before a sample can be committed: - x-served-by names the cache node, so its value is now redacted (the name stays as evidence). - x-amz-cf-id joins the request-id headers. - x-nf-client-connection-ip and fastly-client-ip join the client-IP headers, so their values are replaced whole. - Every *.netlify.app origin is replaced in bodies and headers, not only the captured host. app.netlify.com is kept, as provider evidence. - An absolute Location has its host replaced whatever the host is, with userinfo removed. A relative Location is kept. The request sends no authorization or cookie header; a test now guards that. Tests cover IPv6 (and keep times and CSS alone), cf-ray, x-amz-cf-id, and each item above. Five of the tests (the flipped x-served-by case and four new ones) fail on the previous script. Signed-off-by: Nik Cubrilovic <[email protected]>
This was referenced Nov 13, 2026
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.
Refs #1328, #1258. Not a close: detection for Netlify and Fastly Next-Gen WAF stays open until real samples exist (Nik is setting up throwaway sites).
What this adds
Dev tooling only.
packages/waf-detect/scripts/capture-block-sample.tsfetches one URL, keeps the status and headers and the body, and writes a JSON fixture shaped like theSampletype inpackages/waf-detect/tests/fixtures/waf-blocks.ts(how: "live").redirect: "manual"so the block page itself is captured, with no credentials and a timeout. The fetch implementation is injected; the test passes a fake one and nothing touches the network. The request sends onlyuser-agentandaccept: noauthorizationorcookieheader, and a test guards that.set-cookieis dropped (counted).x-forwarded-for,cf-connecting-ip,x-nf-client-connection-ip,fastly-client-ip, and others) are replaced whole byREDACTED-IP.REDACTED-REQUEST-ID:x-nf-request-id,x-sigsci-requestid,x-amz-cf-id,cf-ray,x-served-by(names the cache node), and others.*.netlify.apporigin is replaced byexample.comin bodies and headers, not only the captured host. The provider's ownnetlify.compages are kept, since they are evidence.Locationhas its host replaced byexample.comwhatever the host is, with any userinfo removed. A relativeLocationis kept.example.com, IPv4 and IPv6 addresses becomeREDACTED-IP, UUIDs and long hex runs becomeREDACTED-ID, and token-like pairs becomeREDACTED-TOKEN. Otherx-sigsci-*values keep their text and lose only the id-shaped part.redactions.--outwithout--force. Body capped at 256 KiB, withtruncatedrecorded.Not scrubbed, by design: third-party hosts in the body (CDN and asset URLs), since markup is what detection is tested against. Token pairs in headers are not scrubbed either; only bodies get them.
Acceptance (for this tooling step)
Sampleshape: done, see the script header.capture-block-sample.test.ts > sanitises headers and body and leaks neither host nor ip,replaces every *.netlify.app origin in the body and Location, not only the target, andreplaces the host of any absolute Location and keeps a relative one.redacts cf-ray and x-amz-cf-id values and keeps their names,replaces Netlify and Fastly client-IP headers whole, whatever their value looks like, andredacts only the id part of x-sigsci headers.scrubs IPv6 addresses but leaves times and CSS pseudo-elements alone.Gates
bun test ./packages/waf-detect/tests/capture-block-sample.test.ts: 12 pass, 0 failgit show HEAD~1:...): 5 fail, as expected. The IPv6 test passes on both, since IPv6 scrubbing already existed; it guards that behaviour.tsgoon the script and test (temporary tsconfig in/tmp, bun types): exit 0oxfmt --checkon both files: exit 0oxlintwith default config on both files: no findings. The repo configapps/cli/oxlint.config.mjsfails before and after this change withRule 'react-compiler' not found in plugin 'react', so it is not a usable gate here.Scope
Docs: none. Skill: none.