Skip to content

Commit 326a147

Browse files
[JENKINS-74972] BitbucketUsernamePasswordCredentialMatcher returns invalid CQL (#940)
Remove the CredentialsMatcher.CQL implementations from BitbucketUsernamePasswordCredentialMatcher and BitbucketOAuthCredentialMatcher. The Credentials Query Language grammar does not support static method calls like StringUtils.isNotBlank(username). I didn't find any credential provider that uses CQL, so let's just not implement it.
1 parent 1db3d33 commit 326a147

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketOAuthCredentialMatcher.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@
3030
import java.util.logging.Level;
3131
import java.util.logging.Logger;
3232

33-
public class BitbucketOAuthCredentialMatcher implements CredentialsMatcher, CredentialsMatcher.CQL {
33+
// Although the CredentialsMatcher documentation says that the best practice
34+
// is to implement CredentialsMatcher.CQL too, this class does not implement
35+
// CredentialsMatcher.CQL, for the following reasons:
36+
//
37+
// * CQL supports neither method calls like username.contains(".")
38+
// nor any regular-expression matching that could be used instead.
39+
// * There don't seem to be any public credential-provider plugins that
40+
// would benefit from CQL.
41+
public class BitbucketOAuthCredentialMatcher implements CredentialsMatcher {
3442
private static int keyLength = 18;
3543
private static int secretLength = 32;
3644

@@ -63,16 +71,4 @@ public boolean matches(Credentials item) {
6371
return false;
6472
}
6573
}
66-
67-
/**
68-
* {@inheritDoc}
69-
*/
70-
@Override
71-
public String describe() {
72-
return String.format(
73-
"(username.lenght == %d && password.lenght == %d && !(username CONTAINS \".\" && username CONTAINS \"@\")",
74-
keyLength, secretLength);
75-
}
76-
77-
7874
}

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketUsernamePasswordCredentialMatcher.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@
2929
import hudson.util.Secret;
3030
import org.apache.commons.lang.StringUtils;
3131

32-
public class BitbucketUsernamePasswordCredentialMatcher implements CredentialsMatcher, CredentialsMatcher.CQL {
32+
// Although the CredentialsMatcher documentation says that the best practice
33+
// is to implement CredentialsMatcher.CQL too, this class does not implement
34+
// CredentialsMatcher.CQL, for the following reasons:
35+
//
36+
// * CQL supports neither method calls like StringUtils.isNotBlank(username)
37+
// nor any regular-expression matching that could be used instead.
38+
// * There don't seem to be any public credential-provider plugins that
39+
// would benefit from CQL.
40+
public class BitbucketUsernamePasswordCredentialMatcher implements CredentialsMatcher {
3341
private static final long serialVersionUID = -9196480589659636909L;
3442

3543
/**
@@ -46,13 +54,4 @@ public boolean matches(Credentials item) {
4654
String password = Secret.toString(usernamePasswordCredential.getPassword());
4755
return StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password);
4856
}
49-
50-
/**
51-
* {@inheritDoc}
52-
*/
53-
@Override
54-
public String describe() {
55-
return "username and password are not empty";
56-
}
57-
5857
}

0 commit comments

Comments
 (0)