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

Superfluous requirements for directives in CSP #2458

Closed
edukisto opened this issue Jul 4, 2020 · 0 comments · Fixed by #2461
Closed

Superfluous requirements for directives in CSP #2458

edukisto opened this issue Jul 4, 2020 · 0 comments · Fixed by #2461

Comments

@edukisto
Copy link
Contributor

edukisto commented Jul 4, 2020

Information

  • Language: CSP.
  • Plugins: none.

Does the problem still occur in the latest version of Prism?

Yes.

Description

As stated in CSP 1.0, CSP 1.1, CSP2, and CSP3, values of directives may be omitted.

For example, empty values of default-src, script-src, style-src, etc., are equivalent to 'none' (see CSP 1.0, CSP 1.1, CSP2, CSP3).

Some directives don’t have values at all. These are block-all-mixed-content, upgrade-insecure-requests, etc.

However, Prism doesn’t recognize the following values:

block-all-mixed-content
default-src
sandbox
upgrade-insecure-requests

We could use trailing spaces (block-all-mixed-content ), but this looks ugly. We could use trailing semicolons (block-all-mixed-content;), but CSP allows semicolons only as delimiters. Moreover, sandbox may or may not have a value, but the following doesn’t work either.

sandbox;

I think, spaces and semicolons should be removed from this regular expression.

May I suggest the following as a replacement?

/\b(?:base-uri|block-all-mixed-content|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src|disown-opener|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox|upgrade-insecure-requests)\b/i

Code snippet

The code being highlighted incorrectly.
block-all-mixed-content
default-src
sandbox
sandbox;
upgrade-insecure-requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant