Skip to content

Policy container inheritance for service workers#34941

Merged
chromium-wpt-export-bot merged 1 commit into
masterfrom
chromium-export-cl-3766681
Aug 26, 2022
Merged

Policy container inheritance for service workers#34941
chromium-wpt-export-bot merged 1 commit into
masterfrom
chromium-export-cl-3766681

Conversation

@chromium-wpt-export-bot

@chromium-wpt-export-bot chromium-wpt-export-bot commented Jul 22, 2022

Copy link
Copy Markdown
Collaborator

Project: https://docs.google.com/document/d/1mAuxWRLcmhghtCoapc30nLo0H12XTMZUJWqw079XOR8/edit?hl=en&forcehl=1

This is the part about service worker.

Attach a PolicyContainerHost to ServiceWorkerVersion. This
PolicyContainerHost is obtained:

  • for local schemes by cloning the creator’s PolicyContainerHost in
    ServiceWorkerRegisterJob::StartWorkerForUpdate
  • for network schemes by parsing the policies from the response headers
    inside ServiceWorkerNewScriptLoader::OnReceiveResponse (new script) or
    ServiceWorkerSingleScriptUpdateChecker::OnReceiveResponse (updated
    script).
  • for previously loaded script which is stored in the database, we write
    the policy container policies to db just like the existing service
    worker data, hence the changes around service worker database and
    protocol buffer. - The sandbox flags is represented as a int32 instead
    of a enum because protocol buffer enums can't be or'ed like a flag.
  • CSP is skipped in this CL because the type is quite complicated and
    require a lot more work. We don't seem to use the policy container CSP
    in the renderer anyway.
  • I added a test to make sure that the encoding and decoding works

The policy container is then passed down to renderer and set as the
execution context's policy container.

This CL also fixes
external/wpt/html/cross-origin-embedder-policy/reflection-credentialless.tentative.https.any.serviceworker.html
and
external/wpt/html/cross-origin-embedder-policy/reflection-require-corp.tentative.https.any.serviceworker.html
because the passed down policy container contains the correct COEP.

Follow-ups: merge CSPs into our policy container.

Bug: 1177199
Change-Id: Ie90c02b8dd3e295c5456e7e2ff03685339277d6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3766681
Commit-Queue: Jonathan Hao <phao@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1039661}

@wpt-pr-bot wpt-pr-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot
chromium-wpt-export-bot force-pushed the chromium-export-cl-3766681 branch 2 times, most recently from 4015ba8 to ef5286d Compare July 25, 2022 16:41
@chromium-wpt-export-bot
chromium-wpt-export-bot force-pushed the chromium-export-cl-3766681 branch 9 times, most recently from a087d27 to d47ac46 Compare August 8, 2022 22:16
@chromium-wpt-export-bot
chromium-wpt-export-bot force-pushed the chromium-export-cl-3766681 branch 3 times, most recently from c17dc0a to 1efe79d Compare August 15, 2022 13:17
@chromium-wpt-export-bot
chromium-wpt-export-bot force-pushed the chromium-export-cl-3766681 branch 11 times, most recently from 4b6f3ae to 050769e Compare August 25, 2022 17:30
Project: https://docs.google.com/document/d/1mAuxWRLcmhghtCoapc30nLo0H12XTMZUJWqw079XOR8/edit?hl=en&forcehl=1

This is the part about service worker.

Attach a PolicyContainerHost to ServiceWorkerVersion. This
PolicyContainerHost is obtained:
- for local schemes by cloning the creator’s PolicyContainerHost in
  ServiceWorkerRegisterJob::StartWorkerForUpdate
- for network schemes by parsing the policies from the response headers
  inside ServiceWorkerNewScriptLoader::OnReceiveResponse (new script) or
  ServiceWorkerSingleScriptUpdateChecker::OnReceiveResponse (updated
  script).
- for previously loaded script which is stored in the database, we write
  the policy container policies to db just like the existing service
  worker data, hence the changes around service worker database and
  protocol buffer. - The sandbox flags is represented as a int32 instead
  of a enum because protocol buffer enums can't be or'ed like a flag.
- CSP is skipped in this CL because the type is quite complicated and
  require a lot more work.  We don't seem to use the policy container CSP
  in the renderer anyway.
- I added a test to make sure that the encoding and decoding works

The policy container is then passed down to renderer and set as the
execution context's policy container.

This CL also fixes
external/wpt/html/cross-origin-embedder-policy/reflection-credentialless.tentative.https.any.serviceworker.html
and
external/wpt/html/cross-origin-embedder-policy/reflection-require-corp.tentative.https.any.serviceworker.html
because the passed down policy container contains the correct COEP.

Follow-ups: merge CSPs into our policy container.

Bug: 1177199
Change-Id: Ie90c02b8dd3e295c5456e7e2ff03685339277d6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3766681
Commit-Queue: Jonathan Hao <phao@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1039661}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants