Skip to content

Commit 5e39143

Browse files
authored
Merge branch 'master' into allow_ignoring_rate_limits
2 parents bdec8b6 + 919f2b4 commit 5e39143

File tree

5 files changed

+64
-8
lines changed

5 files changed

+64
-8
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "maven"
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"

pom.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.jenkins-ci.plugins</groupId>
66
<artifactId>plugin</artifactId>
7-
<version>4.2</version>
7+
<version>4.6</version>
88
<relativePath />
99
</parent>
1010
<artifactId>github-branch-source</artifactId>
@@ -27,7 +27,6 @@
2727
<java.level>8</java.level>
2828
<jenkins.version>2.176.4</jenkins.version>
2929
<useBeta>true</useBeta>
30-
<jcasc.version>1.35</jcasc.version>
3130
<jjwt.version>0.10.5</jjwt.version>
3231
</properties>
3332

@@ -79,7 +78,7 @@
7978
<dependency>
8079
<groupId>org.jenkins-ci.plugins.workflow</groupId>
8180
<artifactId>workflow-multibranch</artifactId>
82-
<version>2.20</version>
81+
<version>2.22</version>
8382
<scope>test</scope>
8483
</dependency>
8584
<dependency>
@@ -98,13 +97,11 @@
9897
<dependency>
9998
<groupId>io.jenkins</groupId>
10099
<artifactId>configuration-as-code</artifactId>
101-
<version>${jcasc.version}</version>
102100
<scope>test</scope>
103101
</dependency>
104102
<dependency>
105103
<groupId>io.jenkins.configuration-as-code</groupId>
106104
<artifactId>test-harness</artifactId>
107-
<version>${jcasc.version}</version>
108105
<scope>test</scope>
109106
</dependency>
110107
<dependency>

src/main/java/org/jenkinsci/plugins/github_branch_source/JwtHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static String createJWT(String githubAppId, final String privateKey) {
6060
* @throws GeneralSecurityException if we couldn't parse the string
6161
*/
6262
private static PrivateKey getPrivateKeyFromString(final String key) throws GeneralSecurityException {
63-
if (key.contains("RSA")) {
63+
if (key.contains(" RSA ")) {
6464
throw new InvalidPrivateKeyException(
6565
"Private key must be a PKCS#8 formatted string, to convert it from PKCS#1 use: "
6666
+ "openssl pkcs8 -topk8 -inform PEM -outform PEM -in current-key.pem -out new-key.pem -nocrypt"

src/test/java/org/jenkinsci/plugins/github_branch_source/EndpointTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ private Page post(String relative, String userName) throws Exception {
9595
client = j.createWebClient();
9696
}
9797

98-
final WebRequest request = new WebRequest(new URL(client.getContextPath() + relative), client.getBrowserVersion().getHtmlAcceptHeader());
99-
request.setHttpMethod(HttpMethod.POST);
98+
final WebRequest request = new WebRequest(new URL(client.getContextPath() + relative), HttpMethod.POST);
99+
request.setAdditionalHeader("Accept", client.getBrowserVersion().getHtmlAcceptHeader());
100100
request.setRequestParameters(Arrays.asList(new NameValuePair(Functions.getCrumbRequestField(), Functions.getCrumb(null))));
101101
return client.getPage(request);
102102
}

src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,45 @@ public class JwtHelperTest {
9191
"WXeajzno43UHZksae1LP1B3J1+0adxpykCMzWl19XZkxtVkYVi0Q3g==\n" +
9292
"-----END RSA PRIVATE KEY-----";
9393

94+
private static final String PKCS8_PRIVATE_KEY_CONTAINING_RSA_CHARS = "-----BEGIN PRIVATE KEY-----\n"
95+
+ "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDGKsPHpCMqBVUw\n"
96+
+ "BB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0OYxD6DDdLZDd9OUw2tvMqZoag2TeprP6qtu0HKSEQj\n"
111+
+ "7YjA5BMAWqqyn8RXada0swr/y3ARKe+1haZKKzS/7qeNjD8GGTQp+NvtOgQ5DfJl\n"
112+
+ "hDDolKOhlq0CgYEAnsPQr9tbXtCV9LJLPwKtGy4Uo+UElmadaqrfoFW4n3vObkKM\n"
113+
+ "G8agV0Zu3KRCAI/kN9876hUxxxQixwip/QMqqlpb5USLrzsIHCqy5ry5h7LYW6JT\n"
114+
+ "36WkJPqiLTnxv62zRRDldYevBGQv0+DDonNmYN6ZG186DV5HMVWM4T+jllsCgYAe\n"
115+
+ "iEj0+qejPd1TECOeo0qYztoEd/5/qmoTdNw1WI2O6HHlDGUT6XSWUkJiqjg0yrJN\n"
116+
+ "5lHNy4/7CwpaeQC3lvEmJJBH1Hj7rt4/zKrJV46u9/IhfGCPMKhaK+TW2C6m2oT7\n"
117+
+ "Z9PLUEhL0j4N6A8RoFFEHi4R289+C8TWlGMtVcXXKQKBgEd1zPh3okoOEBLWBswc\n"
118+
+ "rYeW6a5YMUlWdjv3AaVGWvXCBVQV/nHLbHePDw8/Lj71+tW+aJP3/RSA38T1EbJc\n"
119+
+ "NbI/fRyHodR+Cf7jCm8DWg/lORzzGSA7FGZyV8M/AW4WQ/NjFuHme4Dg7qULEuk+\n"
120+
+ "CK428WLq7hhesv0p8tsmJP+n\n"
121+
+ "-----END PRIVATE KEY-----";
122+
123+
private static final String PKCS8_PUBLIC_KEY_CONTAINING_RSA_CHARS = "-----BEGIN PUBLIC KEY-----\n"
124+
+ "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxirDx6QjKgVVMAQcQ994\n"
125+
+ "/1koU1QdL3ZrvkqoGXjVC0stPoqQWg0YE28oQdJgNpfTNuJh+wf72NAo56zfuNm1\n"
126+
+ "fdnzBUEQr8YEPXEbItm4C+FzoEnSQfXB/xlnr9OJFKlkYoY5uarj86ets0T5jaEm\n"
127+
+ "62y1lbY3HwGDkgwNUj+FwXUWllvAo0FO1Qe90RmnCae5jg74tYKnHLFiukIrun2x\n"
128+
+ "o03opq1k5xDxRRnbLyoC6xqismQRgY/biiguaPpeB170niklK2CW7dG1rLjnoqw6\n"
129+
+ "kNstkGNTsaIlxh9jeRVSCf6KVcjqvy8hoFaDkqo1M5kVtg7mU+y0JvxpfRJobhFA\n"
130+
+ "XwIDAQAB\n"
131+
+ "-----END PUBLIC KEY-----";
132+
94133
@Test
95134
public void createJWT_is_valid() throws Exception {
96135
String jwt = createJWT("123", PKCS8_PRIVATE_KEY);
@@ -100,6 +139,15 @@ public void createJWT_is_valid() throws Exception {
100139
assertThat(parsedJwt.getBody().getIssuer(), is("123"));
101140
}
102141

142+
@Test
143+
public void createJWT_with_key_containing_RSA_is_valid() throws Exception {
144+
String jwt = createJWT("123", PKCS8_PRIVATE_KEY_CONTAINING_RSA_CHARS);
145+
Jws<Claims> parsedJwt = Jwts.parser()
146+
.setSigningKey(getPublicKeyFromString(PKCS8_PUBLIC_KEY_CONTAINING_RSA_CHARS))
147+
.parseClaimsJws(jwt);
148+
assertThat(parsedJwt.getBody().getIssuer(), is("123"));
149+
}
150+
103151
@Test
104152
public void createJWT_with_pkcs1_is_invalid() {
105153
expectedException.expect(InvalidPrivateKeyException.class);

0 commit comments

Comments
 (0)