Skip to content

Commit

Permalink
bitbucket: Fix UserPermissions not returning anything (#64482)
Browse files Browse the repository at this point in the history
This is currently only used in the connectivity check, but could be a
massive footgun if someone ever used it - the `ps` is NOT passed to
`send`, it's assigned to the `Values` property of the struct that is
sent there, so `ps` will always be empty.a

Test plan: CI passes.
  • Loading branch information
eseliger committed Aug 16, 2024
1 parent 6540e8e commit 19b7c03
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions internal/extsvc/bitbucketserver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,15 @@ func (c *Client) UserPermissions(ctx context.Context, username string) (perms []
Permission Perm `json:"permission"`
}

var ps []permission
_, err := c.send(ctx, "GET", "rest/api/1.0/admin/permissions/users", qry, nil, &struct {
resp := &struct {
Values []permission `json:"values"`
}{
Values: ps,
})
}{}
_, err := c.send(ctx, "GET", "rest/api/1.0/admin/permissions/users", qry, nil, &resp)
if err != nil {
return nil, err
}

for _, p := range ps {
for _, p := range resp.Values {
if p.User.Name == username {
perms = append(perms, p.Permission)
}
Expand Down

0 comments on commit 19b7c03

Please sign in to comment.