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

fixing SECURITY-1506 / CVE-2020-2249 #244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -9,6 +9,7 @@
import hudson.plugins.tfs.model.servicehooks.Event;
import hudson.tasks.Publisher;
import hudson.util.DescribableList;
import hudson.util.Secret;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -138,7 +139,7 @@ private void createReleaseWebHook(final ReleaseWebHookResource resource) {
}

String payloadUrl = validateAndGetPayloadUrl(resource);
String secret = resource.getSecret();
Secret secret = resource.getSecret();
String webHookName = resource.getWebHookName();

if (StringUtils.isBlank(webHookName)) {
Expand Down
9 changes: 5 additions & 4 deletions tfs/src/main/java/hudson/plugins/tfs/rm/ReleaseWebHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.util.FormValidation;
import hudson.util.Secret;
import java.net.URI;
import java.net.URISyntaxException;
import org.kohsuke.stapler.DataBoundConstructor;
Expand All @@ -21,10 +22,10 @@ public class ReleaseWebHook extends AbstractDescribableImpl<ReleaseWebHook> {

private final String webHookName;
private final String payloadUrl;
private final String secret;
private final Secret secret;

@DataBoundConstructor
public ReleaseWebHook(final String webHookName, final String payloadUrl, final String secret) {
public ReleaseWebHook(final String webHookName, final String payloadUrl, final Secret secret) {
this.webHookName = webHookName;
this.payloadUrl = payloadUrl;
this.secret = secret;
Expand All @@ -33,7 +34,7 @@ public ReleaseWebHook(final String webHookName, final String payloadUrl, final S
public ReleaseWebHook(final String webHookName, final String payloadUrl) {
this.webHookName = webHookName;
this.payloadUrl = payloadUrl;
this.secret = StringUtils.EMPTY;
this.secret = Secret.fromString("");
}

public String getWebHookName() {
Expand All @@ -44,7 +45,7 @@ public String getPayloadUrl() {
return this.payloadUrl;
}

public String getSecret() {
public Secret getSecret() {
return this.secret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ private ReleaseWebHookStatus sendJobCompletedEvent(final JSONObject json, final
request.addHeader("Content-Type", "application/json");
request.addHeader("Accept", "application/json; api-version=" + apiVersion);

if (!StringUtils.isBlank(webHook.getSecret())) {
String signature = ReleaseWebHookHelper.getPayloadSignature(webHook.getSecret(), payload);
String password = webHook.getSecret().getPlainText();
if (!StringUtils.isBlank(password)) {
String signature = ReleaseWebHookHelper.getPayloadSignature(password, payload);
request.addHeader("X-Jenkins-Signature", signature);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package hudson.plugins.tfs.rm;

import hudson.util.Secret;

/**
* Implements ReleaseWebHookResource. Model to represent webHook register event.
* @author Kalyan
Expand All @@ -9,7 +11,7 @@ public class ReleaseWebHookResource {
private String webHookName;
private String projectName;
private String payloadUrl;
private String secret;
private Secret secret;

public String getOperationType() {
return this.operationType;
Expand Down Expand Up @@ -43,11 +45,11 @@ public void setPayloadUrl(final String payloadUrl) {
this.payloadUrl = payloadUrl;
}

public String getSecret() {
public Secret getSecret() {
return this.secret;
}

public void setSecret(final String secret) {
public void setSecret(final Secret secret) {
this.secret = secret;
}
}