-
Notifications
You must be signed in to change notification settings - Fork 80
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-69659] Un-inline multiple occurrences of JavaScript in Jelly templates #130
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a0b9176
Address inline js function call inside matrix.jelly
yaroslavafenkin e7ee4ff
Uninline URL building in checkUrl
yaroslavafenkin 90cf96f
Uninline script in LabelAxis/config.jelly
yaroslavafenkin 4fc157a
Address review feedback
yaroslavafenkin c108a06
Remove overcomplicated `checkUrl` in MatrixProject/configure-entries.…
yaroslavafenkin bd0cea2
Restrict usage of checker method
yaroslavafenkin 5454028
Merge remote-tracking branch 'origin/master' into JENKINS-69659
yaroslavafenkin cc545f6
Merge branch 'master' into JENKINS-69659
basil 4f1c596
Fix merge
basil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ | |
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
import org.kohsuke.stapler.HttpResponse; | ||
import org.kohsuke.stapler.QueryParameter; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
import org.kohsuke.stapler.StaplerResponse; | ||
import org.kohsuke.stapler.TokenList; | ||
|
@@ -1083,6 +1084,10 @@ public List<AxisDescriptor> getAxisDescriptors() { | |
return r; | ||
} | ||
|
||
public FormValidation doCheckDisplayName(@QueryParameter String value, @QueryParameter String name) { | ||
return Jenkins.get().doCheckDisplayName(value, name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some limitations in |
||
} | ||
|
||
/** | ||
* @deprecated as of 1.456 | ||
* This was only exposed for Jelly. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/resources/hudson/matrix/LabelAxis/label-axis-resources.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Behaviour.specify("DIV.labelAxis-tree", 'LabelAxis', 0, function(e) { | ||
var tree = new YAHOO.widget.TreeView(e); | ||
|
||
var i18nContainer = document.querySelector(".label-axis-i18n"); | ||
var labels = new YAHOO.widget.TextNode(i18nContainer.getAttribute("data-i18n-labels"), tree.getRoot(), false); | ||
var machines = new YAHOO.widget.TextNode(i18nContainer.getAttribute("data-i18n-individual-nodes"), tree.getRoot(), false); | ||
|
||
var values = (e.getAttribute("values") || "").split("/"); | ||
function has(v) { | ||
return values.include(v) ? 'checked="checked" ' : ""; | ||
} | ||
|
||
var labelAxisDataContainer = document.querySelector(".label-axis-data-container"); | ||
labelAxisDataContainer.childNodes.forEach(node => { | ||
var labelCheckbox = node.getAttribute("data-label-checkbox"); | ||
|
||
// inserting 'checked' attribute after '<input ' hence index of 7 | ||
yaroslavafenkin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var output = [labelCheckbox.slice(0, 7), has(node.getAttribute("data-label-atom")), labelCheckbox.slice(7)].join(''); | ||
var label = node.getAttribute("data-label"); | ||
new YAHOO.widget.HTMLNode(output, label === "machines" ? machines : labels, false); | ||
}); | ||
|
||
tree.draw(); | ||
/* | ||
force the rendering of HTML, so that input fields are there | ||
even when the form is submitted without this tree expanded. | ||
*/ | ||
tree.expandAll(); | ||
tree.collapseAll(); | ||
|
||
/* | ||
cancel the event. | ||
|
||
from http://yuilibrary.com/forum/viewtopic.php?f=89&t=8209&p=26239&hilit=HTMLNode#p26239 | ||
"To prevent toggling and allow the link to work, add a listener to the clickEvent on that tree and simply return false" | ||
*/ | ||
tree.subscribe("clickEvent", function(node) { | ||
return false; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/resources/lib/hudson/matrix-project/matrix-resources.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
refreshPart('matrix',"./ajaxMatrix"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can revert this if there are objections, this was a refactoring suggested by IDE.
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.
FTR That code was a correction of a previous vulnerability, not sure the current version does not reintroduce issues.
With
new YAHOO.widget.HTMLNode
I am pretty sure it interprets the values as HTML. Have you tried to reproduce the previous vulnerability or to inject some payloads to understand the behavior? :)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 think lines 89 and 90 are related to the vulnerability fix, unless you mean a different one that I'm not aware of.
I've checked with simple payloads I could think of, and content was escaped properly. I'll give it another shot too to make sure.
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've re-checked, it seems fine to me. Tried couple different payloads, couldn't break it. User provided content is escaped. I'd appreciate someone else trying to break it though.