Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Description
The following pull request extends the current functionality of the drone-vault extension. In particular a new filter type was added. In addition to
X-Drone-ReposandX-Drone-Events,X-Drone-Branchescan now be specified. When a pipeline is triggered, the target branch will be used for filtering. This pull request also extends the test suite to ensure proper functionality of this newly added filter type.Use Case
Lets assume we have a simple CD process:
masterbranch, build docker image and push to a private production docker registry.developmentbranch, build docker image and push to a private development docker registry.masterbranch to allow only trusted people to push to it.The above assumes that we store the production docker images separate from all other ones because they either might contain production grade information or we do not want anyone with push privileges to the development branch to override an image. An example could be an SSL cert baked into the docker image. Our goal is not to let people who have push privileges to the development branch be able to push their image to the production private registry.
Assume that the following information is stored within Vault:
Consider the the following Drone configuration:
With the current setup, a malicious actor with push privileges to development branch, has access to the production credentials.
How To Fix This Issue
With this new filter we can eliminate this security risk. Let us now assume that the following information is stored within Vault:
This solves the issue because now when the
Developmentpipeline is triggered, it does not have access to the production registry secrets.Possible Implications
I could not think of any possible negative implications that these changes might cause. If you choose not to use this new filter, then everything works as it did before.
Additional Information
When filtering, the target branch name is considered. That means that if the event does not have metadata about the target branch (i.e. when event is 'tag'), then permission is not given.
For testing purposes an image with this filter implemented can be pulled from
jetrails/drone-vault:latest. It will be available for the lifetime of this pull request.