-
-
Notifications
You must be signed in to change notification settings - Fork 88
Require-sri-for speciální CSP pravidlo #143
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
Conversation
|
Další speciální pravidlo |
|
Probably Can you add a test? |
|
I can add a test. Wouldnt be better to have some kind of whitelist with all the keywords? |
|
Maybe yes. |
|
I'll add whitelist of all NON qouted keywords. Nonces and hashes are qouted. I dont really understand the reasoning behind the specification... |
|
@peldax As you mentioned and it doesn't make sense to me. It seems like these directives are disabled. More meaningful would be something like this: What do you think about it David? @dg |
|
This would require special section in config or built in list of those "empty" directives.
|
|
Regarding The behaviour should be right opposite. Something like this: private const CSP_QUOTED_SOURCE_VALUES = ['none', 'self', 'unsafe-inline', 'unsafe-eval', 'nonce', 'sha256', 'strict-dynamic', 'unsafe-hashed-attributes'];
...
$isQuoted = false;
foreach (self::CSP_QUOTED_SOURCE_VALUES as $value) {
if (\strpos($item, $value) !== false) {
$isQuoted = true;
break;
}
}
$value .= $isQuoted ? " '$item'" : " $item"; |
|
You have to decide to whitelist one list or the other, whatever you decide to whitelist, there is always going to emerge some new keyword which has to be added to the list. For example hash algorithm doesnt need to be sha256. |
I don't know. Maybe no directive at all, as you said. |
|
@harmim I agree, its just one type-sensitive check. I suggest we PR it later after this is resolved. Syntactic sugar can wait :). |
|
Isn't this solution for true/false directives without source list (arguments)? if (\is_bool($policy)) {
if ($policy) {
$value .= $type . '; ';
}
} else {
$value .= $type;
foreach ((array) $policy as $item) {
$value .= \preg_match('#^[a-z-]+\z#', $item) ? " '$item'" : " $item";
}
$value .= '; ';
} |
|
It is, I would just write it differently - without else - with |
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/require-sri-for
Speciální záznam pro CSP, který ukazuje pro který content má prohlížeč vyžadovat subresource integrity.
Při použití tohoto pravidla v konfigu nette vloží uvozovky kolem
scriptastyle- protože se dávají kolemnone,selfa dalších klíčovách slov. Bohužel očekávané je nekonzistetní bez uvozovek, chrome uvozovky nezkousne.Přidal jsem kontrolu zdali se jedná o typ
require-sri-fora pokud ano nedají se uvozovky.