8000 [SECURITY-1849] · kutzi/github-plugin@11d1d79 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11d1d79

Browse files
committed
[SECURITY-1849]
1 parent 23ea472 commit 11d1d79

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/jenkinsci/plugins/github/webhook/GHWebhookSignature.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
import hudson.util.Secret;
44
import org.apache.commons.codec.binary.Hex;
5-
import org.apache.commons.lang3.StringUtils;
65
import org.slf4j.Logger;
76
import org.slf4j.LoggerFactory;
87

98
import javax.crypto.Mac;
109
import javax.crypto.spec.SecretKeySpec;
1110

11+
import java.security.MessageDigest;
12+
1213
import static com.google.common.base.Preconditions.checkNotNull;
1314
import static java.nio.charset.StandardCharsets.UTF_8;
1415

@@ -71,6 +72,12 @@ public String sha1() {
7172
public boolean matches(String digest) {
7273
String computed = sha1();
7374
LOGGER.trace("Signature: calculated={} provided={}", computed, digest);
74-
return StringUtils.equals(computed, digest);
75+
if (digest == null && computed == null) {
76+
return true;
77+
} else if (digest == null || computed == null) {
78+
return false;
79+
} else {
80+
return MessageDigest.isEqual(computed.getBytes(UTF_8), digest.getBytes(UTF_8));
81+
}
7582
}
7683
}

0 commit comments

Comments
 (0)
0