Emit Jelly file path inside <script> tags to get better CSP samples#612
Emit Jelly file path inside <script> tags to get better CSP samples#612daniel-beck wants to merge 5 commits intomasterfrom
<script> tags to get better CSP samples#612Conversation
|
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.
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.
| "/*" + 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