-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix SECURITY-1025 #11
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
41125f6
Fix SECURITY-1025
lacostej 0e461e2
SECURITY-1025 protect more paths
lacostej ffe48df
Adjust tests now that we have enforced security
lacostej 2f0bdaa
Address code review, remove unecessary POST guards
lacostej 82070da
Address code review, use proper function to test with Crumb
lacostej 87dd079
Address code review, fix get/post and add confirmation upon delete
lacostej 7eb6d97
This file doesn't seem to be used, removing
lacostej 047141a
Remove uneeded POST guard
lacostej 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
15 changes: 0 additions & 15 deletions
15
src/main/resources/hudson/plugins/batch_task/BatchTask/delete.jelly
This file was deleted.
Oops, something went wrong.
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
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,46 @@ | ||
package hudson.plugins.batch_task; | ||
|
||
import org.htmlunit.FailingHttpStatusCodeException; | ||
import org.htmlunit.HttpMethod; | ||
import org.htmlunit.WebRequest; | ||
import org.htmlunit.html.HtmlPage; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TestHelper { | ||
/** | ||
* Performs an HTTP POST request to the relative url. | ||
* | ||
* @param webClient the client | ||
* @param relative the url relative to the context path | ||
* @param expectedContentType if expecting specific content type or null if not | ||
* @param expectedStatus if expecting a http status code or null if not | ||
* @throws IOException if so | ||
*/ | ||
public static HtmlPage assertPost(JenkinsRule.WebClient webClient, String relative, | ||
String expectedContentType, Integer expectedStatus) throws IOException { | ||
WebRequest request = new WebRequest(webClient.createCrumbedUrl(relative), HttpMethod.POST); | ||
try { | ||
HtmlPage p = webClient.getPage(request); | ||
if (expectedContentType != null) { | ||
assertThat(p.getWebResponse().getContentType(), is(expectedContentType)); | ||
} | ||
if (expectedStatus != null) { | ||
assertEquals(expectedStatus.intValue(), p.getWebResponse().getStatusCode()); | ||
} | ||
return p; | ||
} catch (FailingHttpStatusCodeException e) { | ||
if (expectedStatus != null) { | ||
assertEquals(expectedStatus.intValue(), e.getStatusCode()); | ||
return null; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
} |
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.
With addition of these annotations UI buttons seem to be broken.
I've create a dummy freestyle job and added 2 batch tasks to it. Then when I go to
JENKINS/job/JOB_NAME/batchTasks/task/TASK_NAME/
and click "Build Now" I get a 404. Same with "Delete Task".I suspect that culprits are https://github.com/jenkinsci/batch-task-plugin/blob/master/src/main/resources/hudson/plugins/batch_task/BatchTask/sidepanel.jelly#L18 and https://github.com/jenkinsci/batch-task-plugin/blob/master/src/main/resources/hudson/plugins/batch_task/BatchTask/delete.jelly#L9C11-L9C23
For
l:task
there exists apost
attribute, so the fix should be straightforward.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.
perfect. Note that I removed the delete.jelly as it does no seem to be used.
I am still able to delete tasks without it.