Skip to content

LibWeb/CSP: Implement source expression parsing, URL matching and support for setting CSP by the meta element and prepare stylesheets to work with style-src #4367

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

Merged
merged 5 commits into from
Jun 30, 2025

Conversation

Lubrsi
Copy link
Contributor

@Lubrsi Lubrsi commented Apr 15, 2025

Part 7 of splitting up #2854

Final bit of prep work before implementing the directives. See individual commits.

Copy link
Member

@ADKaster ADKaster left a comment

Choose a reason for hiding this comment

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

your comments seem to have promised 2 spec issues, o.w. looks good

policy->remove_directive({}, ContentSecurityPolicy::Directives::Names::FrameAncestors);
policy->remove_directive({}, ContentSecurityPolicy::Directives::Names::Sandbox);

// FIXME: File spec issue stating the policy's self origin isn't set here.
Copy link
Member

Choose a reason for hiding this comment

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

👀 Spec issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened an issue here: whatwg/html#11389

Comment on lines +491 to +496
// 6. If expression contains a non-empty path-part, and redirect count is 0, then:
if (host_source_parse_result->path_part.has_value() && !host_source_parse_result->path_part->is_empty() && redirect_count == 0) {
// 1. Let path be the resulting of joining url’s path on the U+002F SOLIDUS character (/).
// FIXME: File spec issue that if path_part is only '/', then plainly joining will always fail to match.
// It should likely use the URL path serializer instead.
Copy link
Member

Choose a reason for hiding this comment

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

👀 Spec issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened an issue here: w3c/webappsec-csp#772

@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Apr 28, 2025
Copy link

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

@github-actions github-actions bot added the stale label May 20, 2025
Copy link

This pull request has been closed because it has not had recent activity. Feel free to open a new pull request if you wish to still contribute these changes. Thank you for your contributions!

@github-actions github-actions bot closed this May 28, 2025
@Lubrsi Lubrsi reopened this Jun 9, 2025
@github-actions github-actions bot removed the conflicts Pull request has merge conflicts that need resolution label Jun 9, 2025
@ADKaster ADKaster removed the stale label Jun 9, 2025
@ADKaster
Copy link
Member

This seems mostly good to go, just missing filing (and referencing) two spec issues?

@Lubrsi
Copy link
Contributor Author

Lubrsi commented Jun 29, 2025

This seems mostly good to go, just missing filing (and referencing) two spec issues?

Done :^)

Lubrsi added 5 commits June 29, 2025 19:15
This will be used by Content Security Policy to consume the next
character, if it matches a whole range of characters, such as
is_ascii_alpha.
This follows the implementation method that was used for the
implementation of ISO8601 parsing for Temporal in LibJS. Doing it this
way allows us to have state transactions, and thus pick out individual
parse nodes that the specification steps want to use.
These are used by all the *-src attributes, to check if a given URL,
origin and redirect count matches a source list entry specified in
the *-src attribute's values, if it's allowed to.
@shannonbooth shannonbooth merged commit 07231e7 into LadybirdBrowser:master Jun 30, 2025
14 of 16 checks passed
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.

3 participants