Skip to content

Commit

Permalink
Revert "[Local Network Access] Rename private to local in request.cc"
Browse files Browse the repository at this point in the history
This reverts commit 3037cbc62a25a6a929e6c8cbc3ea41b23df18960.

Reason for revert: The spec has been renamed back to Private Network Access WICG/private-network-access#106

Original change's description:
> [Local Network Access] Rename private to local in request.cc
>
> In WICG/private-network-access#91, we decided to
> rename (public, private, local) IP address spaces to (public, local,
> loopback). The spec has already been renamed in
> WICG/private-network-access#97.
> New spec:
> https://wicg.github.io/local-network-access/#ip-address-space-heading
>
> This CL renames the string representation in request.cc. It also updates
> a mixed content wpt because it uses targetAddressSpace defined in
> Request.
>
> There are so many places to rename, so during the process, there will
> inevitably be inconsistencies. Hopefully, we shall resolve all of them
> soon.
>
> Bug: 1418287
> Change-Id: Ib01eb5385626c410d2b5f2bba4a67b86a28380d6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4317043
> Reviewed-by: Camille Lamy <clamy@chromium.org>
> Commit-Queue: Jonathan Hao <phao@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1115707}

Bug: 1418287
Change-Id: I7c7f1abb26e31c9b5a9531000aa572d16ef0f3ac
  • Loading branch information
johnathan79717 authored and chromium-wpt-export-bot committed Jul 11, 2023
1 parent da8c6fb commit a176872
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// META: script=/common/utils.js
// META: script=resources/support.sub.js
//
// Spec: https://wicg.github.io/local-network-access
// Spec: https://wicg.github.io/private-network-access
//
// These tests verify that secure contexts can fetch non-secure subresources
// from more local address spaces, avoiding mixed context checks, as long as
// from more private address spaces, avoiding mixed context checks, as long as
// they specify a valid `targetAddressSpace` fetch option that matches the
// target server's address space.

Expand All @@ -16,9 +16,9 @@ setup(() => {
// Given `addressSpace`, returns the other three possible IP address spaces.
function otherAddressSpaces(addressSpace) {
switch (addressSpace) {
case "loopback": return ["unknown", "local", "public"];
case "local": return ["unknown", "loopback", "public"];
case "public": return ["unknown", "loopback", "local"];
case "local": return ["unknown", "private", "public"];
case "private": return ["unknown", "local", "public"];
case "public": return ["unknown", "local", "private"];
}
}

Expand Down Expand Up @@ -169,66 +169,64 @@ function makeNoBypassTests({ source, target }) {
},
fetchOptions: { targetAddressSpace: correctAddressSpace },
expected: FetchTestResult.FAILURE,
}), prefix + 'not a local network request.');
}), prefix + 'not a private network request.');
}

// Source: loopback secure context.
// Source: local secure context.
//
// Fetches to the loopback and local address spaces cannot use
// Fetches to the local and private address spaces cannot use
// `targetAddressSpace` to bypass mixed content, as they are not otherwise
// blocked by Local Network Access.
// blocked by Private Network Access.

makeNoBypassTests({ source: "loopback", target: "loopback" });
makeNoBypassTests({ source: "loopback", target: "local" });
makeNoBypassTests({ source: "loopback", target: "public" });
makeNoBypassTests({ source: "local", target: "local" });
makeNoBypassTests({ source: "local", target: "private" });
makeNoBypassTests({ source: "local", target: "public" });

// Source: local secure context.
// Source: private secure context.
//
// Fetches to the loopback address space requires the right `targetAddressSpace`
// Fetches to the local address space requires the right `targetAddressSpace`
// option, as well as a successful preflight response carrying a PNA-specific
// header.
//
// Fetches to the local address space cannot use `targetAddressSpace` to
// bypass mixed content, as they are not otherwise blocked by Local Network
// Fetches to the private address space cannot use `targetAddressSpace` to
// bypass mixed content, as they are not otherwise blocked by Private Network
// Access.

makeTests({ source: "local", target: "loopback" });
makeTests({ source: "private", target: "local" });

makeNoBypassTests({ source: "local", target: "local" });
makeNoBypassTests({ source: "local", target: "public" });
makeNoBypassTests({ source: "private", target: "private" });
makeNoBypassTests({ source: "private", target: "public" });

// Source: public secure context.
//
// Fetches to the loopback and local address spaces require the right
// Fetches to the local and private address spaces require the right
// `targetAddressSpace` option, as well as a successful preflight response
// carrying a PNA-specific header.

makeTests({ source: "public", target: "loopback" });
makeTests({ source: "public", target: "local" });
makeTests({ source: "public", target: "private" });

makeNoBypassTests({ source: "public", target: "public" });

// These tests verify that documents fetched from the `loopback` address space
// yet carrying the `treat-as-public-address` CSP directive are treated as if
// they had been fetched from the `public` address space.
// These tests verify that documents fetched from the `local` address space yet
// carrying the `treat-as-public-address` CSP directive are treated as if they
// had been fetched from the `public` address space.

promise_test_parallel(
t => fetchTest(t, {
source: {
server: Server.HTTPS_LOCAL,
treatAsPublic: true,
},
target: {
server: Server.HTTP_LOCAL,
behavior: {
preflight: PreflightBehavior.optionalSuccess(token()),
response: ResponseBehavior.allowCrossOrigin(),
},
},
fetchOptions: {targetAddressSpace: 'local'},
expected: FetchTestResult.FAILURE,
}),
'https-treat-as-public to http-loopback: wrong targetAddressSpace "local".');
promise_test_parallel(t => fetchTest(t, {
source: {
server: Server.HTTPS_LOCAL,
treatAsPublic: true,
},
target: {
server: Server.HTTP_LOCAL,
behavior: {
preflight: PreflightBehavior.optionalSuccess(token()),
response: ResponseBehavior.allowCrossOrigin(),
},
},
fetchOptions: { targetAddressSpace: "private" },
expected: FetchTestResult.FAILURE,
}), 'https-treat-as-public to http-local: wrong targetAddressSpace "private".');

promise_test_parallel(t => fetchTest(t, {
source: {
Expand All @@ -242,9 +240,9 @@ promise_test_parallel(t => fetchTest(t, {
response: ResponseBehavior.allowCrossOrigin(),
},
},
fetchOptions: { targetAddressSpace: "loopback" },
fetchOptions: { targetAddressSpace: "local" },
expected: FetchTestResult.SUCCESS,
}), "https-treat-as-public to http-loopback: success.");
}), "https-treat-as-public to http-local: success.");

promise_test_parallel(t => fetchTest(t, {
source: {
Expand All @@ -258,9 +256,9 @@ promise_test_parallel(t => fetchTest(t, {
response: ResponseBehavior.allowCrossOrigin(),
},
},
fetchOptions: { targetAddressSpace: "loopback" },
fetchOptions: { targetAddressSpace: "local" },
expected: FetchTestResult.FAILURE,
}), 'https-treat-as-public to http-local: wrong targetAddressSpace "loopback".');
}), 'https-treat-as-public to http-private: wrong targetAddressSpace "local".');

promise_test_parallel(t => fetchTest(t, {
source: {
Expand All @@ -274,6 +272,6 @@ promise_test_parallel(t => fetchTest(t, {
response: ResponseBehavior.allowCrossOrigin(),
},
},
fetchOptions: { targetAddressSpace: "local" },
fetchOptions: { targetAddressSpace: "private" },
expected: FetchTestResult.SUCCESS,
}), "https-treat-as-public to http-local: success.");
}), "https-treat-as-public to http-private: success.");
28 changes: 14 additions & 14 deletions fetch/local-network-access/resources/support.sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ async function postMessageAndAwaitReply(target, message) {
// Maps protocol (without the trailing colon) and address space to port.
const SERVER_PORTS = {
"http": {
"loopback": {{ports[http][0]}},
"local": {{ports[http-private][0]}},
"local": {{ports[http][0]}},
"private": {{ports[http-private][0]}},
"public": {{ports[http-public][0]}},
},
"https": {
"loopback": {{ports[https][0]}},
"other-loopback": {{ports[https][1]}},
"local": {{ports[https-private][0]}},
"local": {{ports[https][0]}},
"other-local": {{ports[https][1]}},
"private": {{ports[https-private][0]}},
"public": {{ports[https-public][0]}},
},
"ws": {
"loopback": {{ports[ws][0]}},
"local": {{ports[ws][0]}},
},
"wss": {
"loopback": {{ports[wss][0]}},
"local": {{ports[wss][0]}},
},
};

Expand Down Expand Up @@ -127,15 +127,15 @@ class Server {
};
}

static HTTP_LOCAL = Server.get("http", "loopback");
static HTTP_PRIVATE = Server.get("http", "local");
static HTTP_LOCAL = Server.get("http", "local");
static HTTP_PRIVATE = Server.get("http", "private");
static HTTP_PUBLIC = Server.get("http", "public");
static HTTPS_LOCAL = Server.get("https", "loopback");
static OTHER_HTTPS_LOCAL = Server.get("https", "other-loopback");
static HTTPS_PRIVATE = Server.get("https", "local");
static HTTPS_LOCAL = Server.get("https", "local");
static OTHER_HTTPS_LOCAL = Server.get("https", "other-local");
static HTTPS_PRIVATE = Server.get("https", "private");
static HTTPS_PUBLIC = Server.get("https", "public");
static WS_LOCAL = Server.get("ws", "loopback");
static WSS_LOCAL = Server.get("wss", "loopback");
static WS_LOCAL = Server.get("ws", "local");
static WSS_LOCAL = Server.get("wss", "local");
};

// Resolves a URL relative to the current location, returning an absolute URL.
Expand Down

0 comments on commit a176872

Please sign in to comment.