8000 Revert "Merge pull request #242 from ababushk/JENKINS_50154_unicode_p… · srbala/github-plugin@10418c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10418c4

Browse files
committed
Revert "Merge pull request jenkinsci#242 from ababushk/JENKINS_50154_unicode_payload"
This reverts commit c1aa272, reversing changes made to e394f77.
1 parent c35ebd6 commit 10418c4

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@
8484
<artifactId>commons-lang3</artifactId>
8585
<version>3.11</version>
8686
</dependency>
87-
<dependency>
88-
<groupId>org.apache.commons</groupId>
89-
<artifactId>commons-text</artifactId>
90-
<version>1.9</version>
91-
</dependency>
9287
<dependency>
9388
<groupId>org.jenkins-ci.plugins</groupId>
9489
<artifactId>github-api</artifactId>

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import hudson.util.Secret;
44
import org.apache.commons.codec.binary.Hex;
5-
import org.apache.commons.text.StringEscapeUtils;
65
import org.apache.commons.lang3.StringUtils;
76
import org.slf4j.Logger;
87
import org.slf4j.LoggerFactory;
@@ -55,10 +54,7 @@ public String sha1() {
5554
final SecretKeySpec keySpec = new SecretKeySpec(secret.getPlainText().getByt 8000 es(UTF_8), HMAC_SHA1_ALGORITHM);
5655
final Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
5756
mac.init(keySpec);
58-
59-
final String unescapedPayload = StringEscapeUtils.unescapeJava(payload);
60-
final String convertedUnicode = new String(unescapedPayload.getBytes("latin1"), UTF_8);
61-
final byte[] rawHMACBytes = mac.doFinal(convertedUnicode.getBytes(UTF_8));
57+
final byte[] rawHMACBytes = mac.doFinal(payload.getBytes(UTF_8));
6258

6359
return Hex.encodeHexString(rawHMACBytes);
6460
} catch (Exception e) {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.jenkinsci.plugins.github.webhook;
1+
package org.jenkinsci.plugins.github.extension;
22

33
import hudson.util.Secret;
44
import org.junit.ClassRule;
@@ -14,40 +14,28 @@
1414
*
1515
* @author martinmine
1616
*/
17-
public class GHWebhookSignatureTest {
17+
public class CryptoUtilTest {
1818

1919
private static final String SIGNATURE = "85d155c55ed286a300bd1cf124de08d87e914f3a";
2020
private static final String PAYLOAD = "foo";
2121
private static final String SECRET = "bar";
2222

23-
// Taken from real example of Pull Request update webhook payload
24-
private static final String UNICODE_PAYLOAD = "{\"description\":\"foo\\u00e2\\u0084\\u00a2\"}";
25-
private static final String UNICODE_SIGNATURE = "10e3cb05d27049775aeca89d84d9e6123d5ab006";
26-
2723
@ClassRule
2824
public static JenkinsRule jRule = new JenkinsRule();
2925

3026
@Test
3127
public void shouldComputeSHA1Signature() throws Exception {
3228
assertThat("signature is valid", webhookSignature(
33-
PAYLOAD,
29+
PAYLOAD,
3430
Secret.fromString(SECRET)
3531
).sha1(), equalTo(SIGNATURE));
3632
}
3733

3834
@Test
3935
public void shouldMatchSignature() throws Exception {
4036
assertThat("signature should match", webhookSignature(
41-
PAYLOAD,
37+
PAYLOAD,
4238
Secret.fromString(SECRET)
4339
).matches(SIGNATURE), equalTo(true));
4440
}
45-
46-
@Test
47-
public void shouldComputeSHA1SignatureWithUnicodePayload() throws Exception {
48-
assertThat("signature is valid for unicode payload", webhookSignature(
49-
UNICODE_PAYLOAD,
50-
Secret.fromString(SECRET)
51-
).sha1(), equalTo(UNICODE_SIGNATURE));
52-
}
53-
}
41+
}

0 commit comments

Comments
 (0)
0