| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
[Connection-Allowlist] Dedicated workers local and network basednit but will you format the CL description?
Text wrapping is usually not aligned with the "markdown" you add, and I have a bit difficulty on reading the description smoothly.
/*creator_coep_reporter=*/nullptr, std::nullopt,nit but /* network_restrictions_id= */?
const PolicyContainerPolicies& creator_policies,I just have wondered why `creator_policies` are always set while `creator_network_restriction_id` is optional. What is the case `creator_network_restriction_id` will be be `std::nullopt`?
std::nullopt),nit `/*network_restrictions_id=*/`
policies.connection_allowlists =For the non-local scheme, we use the policy coming from the network, and we ignores creator's, right?
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,creator and worker?
} else {It respects the response header's connection allowlist for non-local schemes, right?
t.step_timeout(() => resolve(SUCCESS), 1000);Does this assume that the expectation should be FAILURE for this time?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[Connection-Allowlist] Dedicated workers local and network basednit but will you format the CL description?
Text wrapping is usually not aligned with the "markdown" you add, and I have a bit difficulty on reading the description smoothly.
Done
/*creator_coep_reporter=*/nullptr, std::nullopt,nit but /* network_restrictions_id= */?
Done
const PolicyContainerPolicies& creator_policies,I just have wondered why `creator_policies` are always set while `creator_network_restriction_id` is optional. What is the case `creator_network_restriction_id` will be be `std::nullopt`?
The creator RenderFrameHost does not always have a network restrictions id, see https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/network_restrictions_navigation_throttle.cc;l=40 for conditions where it is not created (feature is disabled or it is a fenced frame)
std::nullopt),Shivani Sharmanit `/*network_restrictions_id=*/`
Done
For the non-local scheme, we use the policy coming from the network, and we ignores creator's, right?
That's correct
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,Shivani Sharmacreator and worker?
Done
It respects the response header's connection allowlist for non-local schemes, right?
That's right
Does this assume that the expectation should be FAILURE for this time?
that's right, from line 99
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
LGTM % some nits. I have a CL in flight to add reporting, but I think I'll wait for this to land first so I can pass the reporting group in along with the worker-based network restrictions.
assert_true(msgEvent.data.success, `Fetch to ${origin} currently succeeds but should be blocked.`);Nit for next time: rather than landing incorrect test expectations, I'd recommend landing tests in the shared WPT respository that verify the behavior you want, alongside `-expectation.txt` files that accept the behavior we have while we're working on things. :)
assert_false(expectation, "Worker constructor threw unexpectedly");Nit: It's a little confusing to call this `false` here, and `SUCCESS` below. I'd suggest shifting this to `assert_equals` instead to make the comparison clear.
t.step_timeout(() => resolve(SUCCESS), 1000);I'm confused about resolving this as `SUCCESS`, or resolving it at all, really. It seems like it might hide errors. Why not just let the test itself time out if something unexpected happens?
worker.onerror = (e) => resolve({ data: { success: false, error: "Worker Error" } });Semantically, I'd suggest you could reject here (and on #72 above), but that would likely require rewriting some additional tests for consistency. Perhaps doing that in a future CL would be reasonable?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Thanks!
assert_true(msgEvent.data.success, `Fetch to ${origin} currently succeeds but should be blocked.`);Nit for next time: rather than landing incorrect test expectations, I'd recommend landing tests in the shared WPT respository that verify the behavior you want, alongside `-expectation.txt` files that accept the behavior we have while we're working on things. :)
Ack, thanks!
assert_false(expectation, "Worker constructor threw unexpectedly");Nit: It's a little confusing to call this `false` here, and `SUCCESS` below. I'd suggest shifting this to `assert_equals` instead to make the comparison clear.
Done
I'm confused about resolving this as `SUCCESS`, or resolving it at all, really. It seems like it might hide errors. Why not just let the test itself time out if something unexpected happens?
Agree this is confusing. Removed it
worker.onerror = (e) => resolve({ data: { success: false, error: "Worker Error" } });Semantically, I'd suggest you could reject here (and on #72 above), but that would likely require rewriting some additional tests for consistency. Perhaps doing that in a future CL would be reasonable?
ack, I'll create a follow up with the reject option.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
arthursonzogni@ PTAL for owner's approval of the following, thanks!
content/browser/compute_pressure/pressure_service_for_worker_unittest.cc
content/browser/devtools/service_worker_devtools_agent_host.cc
content/browser/renderer_host/render_frame_host_impl.cc
content/browser/url_loader_factory_params_helper.cc
content/browser/url_loader_factory_params_helper.h
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
Thanks!
LGTM with nits.
/* network_restrictions_id= */ std::nullopt,nit: remove extra spaces.
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,nit The format should be:
```
/*arg=*/value
```
This make clang tidy to check the `arg` matches the function argument name.
I don't understand what this TODO means. Could you move it above and add a proper line explaining what this TODO means?
std::move(client_security_state),
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,ditto
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,ditto
/*TODO(crbug.com/447954811): worker_network_restrictions_id*/
std::nullopt,
/*TODO(crbug.com/447954811): creator_network_restrictions_id*/
std::nullopt, std::nullopt,ditto
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
/* network_restrictions_id= */ std::nullopt,Shivani Sharmanit: remove extra spaces.
Done
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,nit The format should be:
```
/*arg=*/value
```
This make clang tidy to check the `arg` matches the function argument name.I don't understand what this TODO means. Could you move it above and add a proper line explaining what this TODO means?
Done
std::move(client_security_state),
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,Shivani Sharmaditto
Done
/*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,Shivani Sharmaditto
Done
/*TODO(crbug.com/447954811): worker_network_restrictions_id*/
std::nullopt,
/*TODO(crbug.com/447954811): creator_network_restrictions_id*/
std::nullopt, std::nullopt,Shivani Sharmaditto
Done
*worker_network_restrictions_id, creator_policies->Clone())) {Also made this change since creator_policies is being used further again in this function so std::move was incorrect to be used here.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
12 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: content/browser/service_worker/embedded_worker_instance.cc
Insertions: 3, Deletions: 1.
@@ -880,6 +880,8 @@
factory_type == ContentBrowserClient::URLLoaderFactoryType::
kServiceWorkerSubResource);
+ // TODO(crbug.com/447954811): Pass network_restrictions_id so script fetch
+ // can be restricted based on connection allowlist.
network::mojom::URLLoaderFactoryParamsPtr factory_params =
URLLoaderFactoryParamsHelper::CreateForWorker(
rph, origin, isolation_info, std::move(coep_reporter),
@@ -889,7 +891,7 @@
ToOriginatingProcess(rph->GetID()), origin),
NetworkServiceDevToolsObserver::MakeSelfOwned(devtools_worker_token),
std::move(client_security_state),
- /*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,
+ /*network_restrictions_id=*/std::nullopt,
"EmbeddedWorkerInstance::CreateFactoryBundle",
/*require_cross_site_request_for_cookies=*/false,
/*is_for_service_worker=*/true);
```
```
The name of the file: content/browser/worker_host/shared_worker_host.cc
Insertions: 4, Deletions: 1.
@@ -524,6 +524,9 @@
if (dip_reporter_) {
dip_reporter_->Clone(dip_reporter.InitWithNewPipeAndPassReceiver());
}
+
+ // TODO(crbug.com/447954811): Pass network_restrictions_id so script fetch
+ // can be restricted based on connection allowlist.
network::mojom::URLLoaderFactoryParamsPtr factory_params =
URLLoaderFactoryParamsHelper::CreateForWorker(
GetProcessHost(), origin, GetStorageKey().ToPartialNetIsolationInfo(),
@@ -533,7 +536,7 @@
ToOriginatingProcess(GetProcessHost()->GetID()), origin),
/*devtools_observer=*/mojo::NullRemote(),
mojo::Clone(worker_client_security_state_),
- /*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,
+ /*network_restrictions_id=*/std::nullopt,
/*debug_tag=*/
"SharedWorkerHost::CreateNetworkFactoryForSubresource",
instance_.DoesRequireCrossSiteRequestForCookies(),
```
```
The name of the file: content/browser/worker_host/worker_script_fetcher.cc
Insertions: 4, Deletions: 1.
@@ -169,6 +169,9 @@
// The load succeeded iff `main_script_load_params` is not nullptr.
if (main_script_load_params) {
+ // TODO(crbug.com/41478971): Pass the PolicyContainerPolicies. It can
+ // be built from the
+ // `main_script_load_params.response_head->parsed_headers`.
PolicyContainerPolicies policies;
if (final_response_url.SchemeIsLocal() && creator_policies) {
policies.connection_allowlists =
@@ -539,7 +542,7 @@
if (worker_network_restrictions_id && creator_policies) {
if (auto throttle = NetworkRestrictionsWorkerThrottle::Create(
factory_process->GetStoragePartition(),
- *worker_network_restrictions_id, std::move(*creator_policies))) {
+ *worker_network_restrictions_id, creator_policies->Clone())) {
throttles.push_back(std::move(throttle));
}
}
```
```
The name of the file: content/browser/compute_pressure/pressure_service_for_worker_unittest.cc
Insertions: 1, Deletions: 1.
@@ -150,7 +150,7 @@
rfh->BuildClientSecurityState(),
rfh->policy_container_host()->policies(),
/*creator_coep_reporter=*/nullptr,
- /* network_restrictions_id= */ std::nullopt,
+ /*network_restrictions_id=*/std::nullopt,
mojo::PendingReceiver<blink::mojom::DedicatedWorkerHost>(),
net::StorageAccessApiStatus::kNone);
mojo::Receiver<blink::mojom::BrowserInterfaceBroker>& bib =
```
```
The name of the file: content/browser/worker_host/shared_worker_service_impl.cc
Insertions: 6, Deletions: 4.
@@ -428,6 +428,10 @@
worker_origin == host->instance().storage_key().origin())
<< worker_origin << " and " << host->instance().storage_key().origin()
<< " should be the same.";
+
+ // TODO(crbug.com/447954811): Pass worker_network_restrictions_id and
+ // creator_network_restrictions_id so subresources and script fetch
+ // can be restricted based on connection allowlist.
WorkerScriptFetcher::CreateAndStart(
worker_process_host->GetDeprecatedID(), host->token(),
host->instance().url(), creator, &creator,
@@ -445,10 +449,8 @@
SharedWorkerDevToolsAgentHost::GetFor(host), host->GetDevToolsToken(),
host->instance().DoesRequireCrossSiteRequestForCookies(),
storage_access_api_status,
- /*TODO(crbug.com/447954811): worker_network_restrictions_id*/
- std::nullopt,
- /*TODO(crbug.com/447954811): creator_network_restrictions_id*/
- std::nullopt, std::nullopt,
+ /*worker_network_restrictions_id=*/std::nullopt,
+ /*creator_network_restrictions_id=*/std::nullopt, std::nullopt,
base::BindOnce(&SharedWorkerServiceImpl::StartWorker,
weak_factory_.GetWeakPtr(), weak_host, message_port,
std::move(cloned_outside_fetch_client_settings_object)));
```
```
The name of the file: content/browser/devtools/service_worker_devtools_agent_host.cc
Insertions: 3, Deletions: 1.
@@ -438,6 +438,8 @@
const auto* version = context_wrapper_->GetLiveVersion(version_id_);
// TODO(crbug.com/40190528): make sure client_security_state is no longer
// nullptr anywhere.
+ // TODO(crbug.com/447954811): Pass network_restrictions_id so script fetch
+ // can be restricted based on connection allowlist.
auto factory = URLLoaderFactoryParamsHelper::CreateForWorker(
rph, origin, version->key().ToPartialNetIsolationInfo(),
/*coep_reporter=*/mojo::NullRemote(),
@@ -447,7 +449,7 @@
ToOriginatingProcess(rph->GetID()), origin),
NetworkServiceDevToolsObserver::MakeSelfOwned(GetId()),
/*client_security_state=*/nullptr,
- /*TODO(crbug.com/447954811): network_restrictions_id*/ std::nullopt,
+ /*network_restrictions_id=*/std::nullopt,
/*debug_tag=*/"SWDTAH::CreateNetworkFactoryParamsForDevTools",
/*require_cross_site_request_for_cookies=*/false,
/*is_for_service_worker_=*/false);
```
[Connection-Allowlist] Dedicated workers local and network based
1. Updated `URLLoaderFactoryParamsHelper::CreateForWorker`: Added a
network_restrictions_id parameter to allow URLLoaderFactories created
for workers to be subject to network restrictions.
2. Inheritance in `DedicatedWorkerHost`:
- The DedicatedWorkerHost now accepts and stores a
creator_network_restrictions_id representing the restrictions of the
frame or worker that created it.
- creator_network_restrictions_id is passed to
WorkerScriptFetcher::CreateAndStart to ensure the initial fetch of the
worker's main script is subject to the restrictions of the creator.
- For nested workers, the parent worker passes its own network_restrictions_id_ as the creator_network_restrictions_id for the
nested worker.
3. Refined `WorkerScriptFetcher`:
- CreateAndStart and CreateScriptLoader now handle both a
worker_network_restrictions_id (to be used by the response throttle to
restrict the fetches from the worker) and a
creator_network_restrictions_id (to restrict the fetch of the script).
- Updated DidCreateScriptLoader to correctly initialize
PolicyContainerPolicies for the worker, ensuring local workers inherit
from their creator.
4. Registration in the network service:
- Added NetworkRestrictionsWorkerThrottle which handles calling
RevokeNetworkForNoncesInNetworkContext. By passing the worker's network
restrictions id to this throttle, the policy found in the script
response is automatically registered for the worker.
5. Updated Call Sites:
- RenderFrameHostImpl now passes its network restriction id when
creating a dedicated worker factory.
- SharedWorkerServiceImpl, EmbeddedWorkerInstance, and
ServiceWorkerDevToolsAgentHost have been updated to pass std::nullopt
for the restriction IDs with a TODO for future implementation.
6. Enhanced WPT Tests:
- Added tests in dedicated-worker.sub.window.js verifying that:
-- Main script fetches are blocked if they are cross-origin relative to
a restricted creator.
-- Workers created with an empty Connection-Allowlist: () header are
unable to perform any fetches.
Bug: 447954811
Change-Id: I755252a9841dccf819d098b0485bc66dee231263
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7535781
Commit-Queue: Shivani Sharma <shiva...@chromium.org>
Reviewed-by: Arthur Sonzogni <arthurs...@chromium.org>
Reviewed-by: Yoshisato Yanagisawa <yyana...@chromium.org>
Reviewed-by: Mike West <mk...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1584680}
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
The WPT PR for this CL has been merged upstream! https://github.com/web-platform-tests/wpt/pull/57780
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |