-
-
Notifications
You must be signed in to change notification settings - Fork 113
Emit Jelly file path inside <script> tags to get better CSP samples
#612
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
base: master
Are you sure you want to change the base?
Conversation
|
FTR from Daniel in Gitter:
|
|
nit suggestion: use Daniel found the spec: https://www.w3.org/TR/CSP3/#violation-sample
|
Seems less safe to do to me. Also FTR I will need to confirm it's fine to not have |
Examples in https://developer.mozilla.org/en-US/docs/Web/API/CDATASection indicate |
<script> tags to get better CSP samples
Kevin-CB
left a comment
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 tested the PR, it works fine, except from my feedback on the line number, we're good to go there.
| getTagBody().run(context, bodyOutput); | ||
| if (writer.getBuffer().length() > 0) { | ||
| output.write( | ||
| "/*" + getFileName().substring(getFileName().length() - 33) + ":" + getLineNumber() |
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.
| "/*" + getFileName().substring(getFileName().length() - 33) + ":" + getLineNumber() | |
| "/*" + getFileName().substring(getFileName().length() - 31) + ":" + getLineNumber() |
If we’re limited to 40 characters, I think we should reserve 4 for the line number to avoid mistakenly indicating the wrong line. Or at least 3, if you don’t think Jelly files with thousands of lines are that common. In any case, it’s better to be sure we indicate the correct line than to have one extra char at the start of the file name.
This makes it easier to identify the source of a CSP violation from
<script>tags in Jelly/Groovy views: Instead of the first 30 characters, we get a substring of the file path.Additional benefit: If this isn't present, the source is something else (like an adjunct, or browser extension).
This is not a prerequisite for jenkinsci/jenkins#11269 nor vice versa, but this would complement the core change well.
Testing done
Submitter checklist