-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support 'report-sample' keyword-source #184
Conversation
c84efaa
to
0e2706a
Compare
p = parseWithNotices("style-src 'report-sample' 'unsafe-hashed-attributes' 'report-sample' 'nonce-123'", notices); | ||
assertEquals(1, p.getDirectives().size()); | ||
assertEquals(2, notices.size()); | ||
assertEquals("Invalid base64-value (should be multiple of 4 bytes: 3).", notices.get(0).message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have two notices and the one you're asserting on is unrelated to report-sample. Just fix the nonce and assert on the remaining notice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both notices are unrelated to report-sample
, removed the test
p = parseWithNotices("script-src 'report-sample' 'report-sample'", notices); | ||
assertEquals(1, p.getDirectives().size()); | ||
assertEquals("script-src 'report-sample'", p.getDirectiveByType(ScriptSrcDirective.class).show()); | ||
assertEquals(0, notices.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two report-samples, but no notices?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be addressed in #185
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to seem some expected parse failures in the tests. Try using report-sample outside of a source expression list.
@@ -391,6 +391,8 @@ private void enforceMissingDirectiveValue(@Nonnull Token directiveNameToken) thr | |||
seenStates.add(SeenStates.SEEN_HOST_OR_SCHEME_SOURCE); | |||
} else if (se == KeywordSource.UnsafeHashedAttributes) { | |||
seenStates.add(SeenStates.SEEN_UNSAFE_HASHED_ATTR); | |||
} else if (se == KeywordSource.ReportSample) { | |||
seenStates.add(SeenStates.SEEN_REPORT_SAMPLE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems silly to add this if it's not going to be read, but whatever.
fixes #183