Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying pre-receive hooks on Bitbucket Cloud

We have Bitbucket Cloud not Bitbucket Server. Is there a way to modify the "pre-receive" functions on Bitbucket? Goal is to audit pushes to make sure there's no obvious vulnerabilities before the code is available on Bitbucket. Git-hooks might work but there's not really a way to get them into version control in the same repo - the only way I can think of doing that would be to ssh into a Bitbucket server and modify the remote repo but I don't think you can do that?

My only guess is there might be a way to keep the pre-receive hooks in source control by putting the hook somewhere like this in the repo:

.bitbucket/pre-receive

But it's hard to find any info on this online.

like image 950
Alexander Mills Avatar asked May 13 '19 04:05

Alexander Mills


People also ask

How do I update pre-commit hook?

You can update your hooks to the latest version automatically by running pre-commit autoupdate . By default, this will bring the hooks to the latest tag on the default branch.

How do I update a bitbucket hook?

Unfortunately, Bitbucket Server doesn't provide an API or UI to install an update hook. It only supports pre-receive and post-receive hooks on that level. However, since Bitbucket Server uses a generic git at the backend, it is indeed possible to install any of the standard git hooks.

How do I enable pre received hooks?

Adding a pre-receive hook file to a GitHub repositoryIn the web client, log on to Change and Configuration Management. For example, go to https://host_name:9443/ccm/web. On the CCM project page, click Source Control > Work with Git. Click Browse Registered Git Repositories.


1 Answers

Unfortunately, this isn't possible.

The GitHub documentation is talking about GitHub Enterprise Server, a product you would install on your own infrastructure. GitHub as in github.com does not support creating pre-receive hooks at all. This is pretty much the norm amongst the popular cloud git hosting providers - no cloud provider will let you write your own arbitrary code and run it on the same infrastructure that holds your git repo, there's too much danger of you breaking out into other data on the same physical storage.

Until someone develops a safe/sandboxed implementation of server-side hooks, you'll need to find another way.

Full disclosure: I work for Atlassian (though I don't work on Bitbucket Cloud)

like image 117
daveruinseverything Avatar answered Oct 02 '22 18:10

daveruinseverything