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

[JENKINS-66729] Un-inlining UsageStatistics/footer.jelly (CSP issue) #Hacktoberfest #5787

Merged
merged 5 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Behaviour.addLoadEvent(function() {
loadScript("https://usage.jenkins.io/usage-stats.js?${statData}");
Copy link
Member

Choose a reason for hiding this comment

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

This won't work. Have you tested it at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sir I used #5786 as reference for this issue.
I ran the yarn tests as it was written but is showed 2 test case passed.
Can you help me out. ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It needs to be tested interactively with a web browser in addition to the test automation. Human evaluation of presentation of a web page sees things that the automated test assertions may not be checking.

Copy link
Contributor

Choose a reason for hiding this comment

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

The statData is a java variable that is injected in the Jelly. If you are moving to a separate file, this value will be not provided to the JS file.

You can find more information in https://www.jenkins.io/doc/developer/security/xss-prevention/#passing-values-to-javascript.

But yeah, please test it manually ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Wadeck @MarkEWaite can you check now?

});
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:if test="${it.due}">
<j:set var="statData" value="${it.statData}"/>
<j:if test="${statData != null}">
<script>
Behaviour.addLoadEvent(function() {
loadScript("https://usage.jenkins.io/usage-stats.js?${statData}");
});
</script>
<st:adjunct includes="hudson.model.UsageStatistics.footer-resources" />
<j:if test="${it.due}">
<j:set var="statData" value="${it.statData}"/>
<j:if test="${statData != null}">
</j:if>
</j:if>
</j:if>
</j:jelly>