Skip to content

Commit 6aa2a23

Browse files
rsandellCarroll Chiou
authored andcommitted
[SECURITY-3300]
1 parent e4f044c commit 6aa2a23

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/ForkPullRequestDiscoveryTrait.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,16 @@ public TrustTeamForks() {
301301
@Override
302302
protected boolean checkTrusted(@NonNull BitbucketSCMSourceRequest request, @NonNull PullRequestSCMHead head)
303303
throws IOException, InterruptedException {
304-
if (!head.getOrigin().equals(SCMHeadOrigin.DEFAULT)) {
304+
SCMHeadOrigin origin = head.getOrigin();
305+
if (!origin.equals(SCMHeadOrigin.DEFAULT)) {
306+
if(origin instanceof SCMHeadOrigin.Fork) {
307+
String forkOwner = ((SCMHeadOrigin.Fork) origin).getName();
308+
int index = forkOwner.lastIndexOf('/');
309+
if (index > 0) { //hasn't happened yet in my testing, so this might be wrong
310+
forkOwner = forkOwner.substring(0, index);
311+
}
312+
return request.getRepoOwner().equalsIgnoreCase(forkOwner);
313+
}
305314
return head.getRepoOwner().equalsIgnoreCase(request.getRepoOwner());
306315
}
307316
return false;

0 commit comments

Comments
 (0)