Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-write default handling and supply default values. #60

Merged
merged 14 commits into from
Mar 23, 2021

Conversation

otherdaniel
Copy link
Collaborator

@otherdaniel otherdaniel commented Feb 11, 2021

This PR

  • distinguishes between built-ins (non-overridable) and defaults (what you get without an explicit config)
  • makes the default an allow-list (plus a provisional allow list for attributes)
  • I snuck in special-casing for <template>

The first commit defined the built-ins as a block-list; the second also as an allow-list.
I find the second one to be somewhat harder to read. (E.g. it's more difficutl to find the difference between built-in and default lists.)

index.bs Outdated Show resolved Hide resolved
index.bs Outdated
@@ -198,6 +208,14 @@ dictionary which describes modifications to the sanitze operation.
: dropAttributes
:: The <dfn>attribute drop list</dfn> is an [=attribute match list=], which
determines whether an attribute (on a given element) should be dropped.
: allowUnknownElements
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want a blanket allow-boolean for this case (and the attribute case below). I think we should ask developers to specifically list the elements & attributes they need.

I know this puts an extra onus on e.g., framework authors, but I'd rather do this than provide a footgun that turns this into a security bug. Happy to debate this further.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure I agree, honestly. I'll remove them in the next update, but I guess I'll make an attempt at getting them back in again. :)

index.bs Outdated Show resolved Hide resolved
index.bs Outdated
"allowUnknownElements": false
"allowUnknownAttributes": false,
"allowCustomElements": false,
"allowElements": [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same nit as above, plus I'd prefer we figure out a way to name it once in the spec and then reference it from there instead of having it fully enumerated in two places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I agree. The baseline and the default config will differ in subtle ways. Otherwise, we could just merge them again.

Arguably, it'd make sense to have an easier way to construct them, like:
default = { allowElement: baseline.allowElements + ["bla", "bla", "blubb"] }
Or so. That'd likely be much easier to understand.

Incidentally, today someone brought up exactly that point when discussing allowUnknownElements. So if someone wants to add an "unknown" element to the list, they shouldn't have to research and repeat the entire allow-list. I guess we're missing a mechanism there.

(Could be: Default config exposed, so people can easily build on it. Or every Sanitizer exposes their config. Or "inheritance", where you name a "parent" Sanitizer. Or... )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would it make sense to add a (non-normative, I guess?) section that explains how the values were constructed? Ideally in executable form.

Something like: https://github.com/otherdaniel/purification/blob/default-construction/resources/configurations.html

The idea is that one can copy&paste the results into the spec (or generate them as part of the deploy script). If all goes well, the code version could be more easily readable & modifyable than the spec version, but we'd still have a definite version in the spec.

@@ -0,0 +1,755 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've run these files through a tool called json_pp (JSON pretty print) that I found on my machine. I'm not sure this format is the best, but it's very diff-able.

blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this pull request Feb 23, 2021
Change the default lists and sanitizing logics according to:
WICG/sanitizer-api#38 and
WICG/sanitizer-api#60

Bug: 1116418
Change-Id: Ie4866b09ec3cd94a6bb38075ba7068ddd2a448a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2698917
Commit-Queue: Yifan Luo <[email protected]>
Reviewed-by: Daniel Vogelheim <[email protected]>
Cr-Commit-Position: refs/heads/master@{#856648}
@otherdaniel
Copy link
Collaborator Author

I've uploaded a re-write of this PR. I'll re-add actual default values next.
@mozfreddyb could you take a quick look and offer an opinion on whether this is going in the right direction?

@otherdaniel
Copy link
Collaborator Author

I've also (re-) added actual default values, as well as a script that computes them. The intention is that the script is easier to understand and modify, but we'd still have exact values in the spec. I'd appreciate another round of reviews, looking both at the actual default values, as well as the mechanics for how we construct them.

@yoavweiss yoavweiss changed the base branch from master to main March 5, 2021 21:36
Copy link
Collaborator

@mozfreddyb mozfreddyb left a comment

Choose a reason for hiding this comment

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

Thanks for the hard work! Sorry it took me so long.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Show resolved Hide resolved
resources/baseline-attribute-allow-list.json Show resolved Hide resolved
@mozfreddyb
Copy link
Collaborator

oh darn. merging #70 before this made this a revision with merge conflicts. 😖

@mozfreddyb
Copy link
Collaborator

let's land this :)

@otherdaniel otherdaniel merged commit 3be8e05 into WICG:main Mar 23, 2021
@otherdaniel otherdaniel deleted the new-default branch March 23, 2021 12:09
@otherdaniel
Copy link
Collaborator Author

Landed! :)

mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Change the default lists and sanitizing logics according to:
WICG/sanitizer-api#38 and
WICG/sanitizer-api#60

Bug: 1116418
Change-Id: Ie4866b09ec3cd94a6bb38075ba7068ddd2a448a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2698917
Commit-Queue: Yifan Luo <[email protected]>
Reviewed-by: Daniel Vogelheim <[email protected]>
Cr-Commit-Position: refs/heads/master@{#856648}
GitOrigin-RevId: 716ecaeea7b768608631d61682b3fdf9e086ec78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants