Open idiotwithalaptop opened 5 years ago
There's usually a question of trust when building pull request from forks. E.g. could a pull request be opened from a (malicious) public repository to a private repository to extract secrets from the build environment?
Does buildkite have any security controls for managing this?
@azz I would have thought that was more a concern of the origin repository, rather than buildkite. The origin repository should have the ability to control who can raise PRs and fork their code and also choose where those changes come from.
@idiotwithalaptop I would hope so. I'm not sure how bitbucket.org handles public-private pull requests. I found this documentation from TravisCI.
Regardless this is tangential to the issue you've raised.
Does buildkite have any security controls for managing this?
We certainly do for Github:
I'll have to investigate for Bitbucket.
@idiotwithalaptop it looks like recently Bitbucket started supporting git refs for pull requests: https://www.atlassian.com/git/articles/pull-request-proficiency-fetching-abilities-unlocked
We support setting a custom refspec in the agent via a special environment BUILDKITE_REFSPEC
. You should be able to set this via a pre-checkout
hook on your agent to something like:
export BUILDKITE_REFSPEC='+refs/pull-requests/*/from:refs/remotes/origin/pr/*'
I think that should do the trick! I'll get a bitbucket setup and do some testing and see if there is a way we can do that for you automatically.
@lox I noticed that blog a few days ago too, not sure how recent it is though as it still references atlassian.stash.com
and the featured article for https://www.atlassian.com/git/articles
dates back to 2014. I did try following what it said by using the refspec mentioned, but had no success unfortunately.
There is an open issue on Bitbucket about this (see https://bitbucket.org/site/master/issues/5814/reify-pull-requests-by-making-them-a-ref), but it's been open since 2012 so I'm not holding my breath for a fix anytime soon.
I ran into an interesting shortcoming recently that may need some attention.
Part of the standard practice I have been using when working with git repositories is that I always fork a copy of the repo, make my changes there, keep it up to date using
git fetch remote
and then contribute back using a pull request.Turns out that when I fork / update / raise a PR on
bitbucket.org
, the buildkite agent was unable to checkout the changes. Here is an example of from the logs:Looking into this, turns out this is because unlike with github.com,
bitbucket.org
's refspecs & branches for pull requests are internal only. To the best of my knowledge there are 3 options:git clone --mirror
😨If you are interested in the 3rd option, I written a possible solution and would be more than happy to raise a PR.
Cheers, Ryan