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

fixes GH-161: Check if a policy is using strict-dynamic #162

Merged
merged 1 commit into from
Dec 7, 2016

Conversation

shekyan
Copy link
Collaborator

@shekyan shekyan commented Dec 2, 2016

introduces hasStrictDynamic, as well as modifying behaviour of
unsafe-inline, hash-source, nonce-source querying functions to
take into account presence of strict-dynamic keyword in the expression.
strict-dynamic invalidates unsafe-inline for the scripts and has no
effect for the styles.

introduces hasStrictDynamic, as well as modifying behaviour of
`unsafe-inline`, hash-source, nonce-source querying functions to
take into account presence of strict-dynamic keyword in the expression.
strict-dynamic invalidates unsafe-inline for the scripts and has no
effect for the styles.
return this.hasUnsafeInlineScript() && !this.hasStrictDynamic();
}

public boolean hasUnsafeInlineScript() {
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be private.

}
return styleSrcDirective.values().anyMatch(x -> x == KeywordSource.UnsafeInline);
}

public boolean allowsUnsafeInlineStyle() {
return this.hasUnsafeInlineStyle();
Copy link
Member

Choose a reason for hiding this comment

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

Why does this indirection exist? Just rename hasUnsafeInlineStyle to allowsUnsafeInlineStyle.

@@ -519,7 +539,7 @@ public boolean allowsScriptWithNonce(@Nonnull Base64Value nonce) {
}

public boolean allowsStyleWithNonce(@Nonnull String nonce) {
if (this.allowsUnsafeInlineScript())
if (this.allowsUnsafeInlineStyle())
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch.

@michaelficarra michaelficarra merged commit 9e494ea into master Dec 7, 2016
@michaelficarra michaelficarra deleted the GH-161 branch December 7, 2016 20:54
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