Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+15
-4
@@ -7,10 +7,11 @@ function makeRequest(headers: Record<string, string>): Request {
|
||||
}
|
||||
|
||||
describe("extractWebActorIp", () => {
|
||||
it("prefers cf-connecting-ip > x-real-ip > x-forwarded-for first hop", () => {
|
||||
expect(extractWebActorIp(makeRequest({ "cf-connecting-ip": "1.1.1.1", "x-forwarded-for": "2.2.2.2" }))).toBe("1.1.1.1");
|
||||
it("accepts Cloudflare client IPs only behind a verified Cloudflare peer", () => {
|
||||
expect(extractWebActorIp(makeRequest({ "cf-connecting-ip": "1.1.1.1", "x-forwarded-for": "2.2.2.2, 173.245.48.10" }))).toBe("1.1.1.1");
|
||||
expect(extractWebActorIp(makeRequest({ "x-real-ip": "2.2.2.2" }))).toBe("2.2.2.2");
|
||||
expect(extractWebActorIp(makeRequest({ "x-forwarded-for": "3.3.3.3, 8.8.8.8" }))).toBe("3.3.3.3");
|
||||
expect(extractWebActorIp(makeRequest({ "x-forwarded-for": "3.3.3.3, 8.8.8.8" }))).toBe("8.8.8.8");
|
||||
expect(extractWebActorIp(makeRequest({ "cf-connecting-ip": "not-an-ip" }))).toBeNull();
|
||||
expect(extractWebActorIp(makeRequest({}))).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -34,7 +35,17 @@ describe("extractWebRequestId", () => {
|
||||
describe("withAuditContext", () => {
|
||||
it("binds the context for the duration of the callback", async () => {
|
||||
expect(getWebAuditContext()).toBeNull();
|
||||
const captured = await withAuditContext({ request: makeRequest({ "cf-connecting-ip": "5.5.5.5", "user-agent": "Test/1.0", "x-request-id": "req_1" }) }, async () => getWebAuditContext());
|
||||
const captured = await withAuditContext(
|
||||
{
|
||||
request: makeRequest({
|
||||
"cf-connecting-ip": "5.5.5.5",
|
||||
"x-forwarded-for": "198.51.100.5, 173.245.48.10",
|
||||
"user-agent": "Test/1.0",
|
||||
"x-request-id": "req_1",
|
||||
}),
|
||||
},
|
||||
async () => getWebAuditContext()
|
||||
);
|
||||
expect(captured).toEqual({ actorIp: "5.5.5.5", actorUserAgent: "Test/1.0", requestId: "req_1" });
|
||||
expect(getWebAuditContext()).toBeNull();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user