-
ProblemCSC is a public repository, mostly consisting of terraform files, which uses the standard github fork-and-pr workflow. This means that when a user wants to make a change, they fork the entire repository to their own github, make the changes there, then open a pull request to the finos CSC repository. When a Pull Request is opened, we have Github Actions set up to perform a few different actions. First we do a terraform formatting check, to make sure all the formatting is correct, then we do a terraform verify, which makes sure all the terraform in the folder we're looking at is valid and makes sense. Assuming these two pass, we then try to actually run the terraform against a live system to see if it works - this is where the problem lies. To access the live AWS instance we have to supply some secrets. These secrets give access to add and remove resources from the CSC AWS instance whice we are running terraform against. This means that these secrets have to remain... secret, otherwise they can be used by bad actors to perform actions like spinning up crypocurrency miners which FinOS end up paying for! If any PR raised ran with access to these secrets, anyone would be able to exfiltrate the secrets trivially, by echoing out the secret's contents as part of thier pull request, and viewing the CI run log. To prevent this, github actions doesn't allow access to secrets when a pull request has been raised from a forked repository. What we've triedWe have tried setting up github actions environments, which allows access to secrets to be gated behind a reviewer OKing the run. Unfortunately this has the same security settings, which cannot be changed, so even when access to the secrets has been allowed they still aren't supplied. We have also tested the SolutionUsing the As a form of documentation / review safeguarding for this, we should make sure any MR that modifies the github actions explicitly prevents the apply / destroy type tasks from being run, and have something reviewers have to acknowledge so they know why this has happened. If we wanted to go further with this we could block any PRs with modifications to both the actions AND the terraform files from passing CI. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
Hi @thinkl33t , Thanks for raising this issue. Can you please have a look at this: Thanks! Abdullah |
Beta Was this translation helpful? Give feedback.
-
Hi @thinkl33t ! I've shared this already, but probably got lost somewhere in the Slack chat. As you mention, this limitation is in reality a security "feature". What I did in the past for other projects was to set a condition in the GitHub action build steps, based on the GitHub username (or org) where the PR os coming from. If it's not "finos", everything but the deployment can be executed, ie the first 2 build steps you mention. Here's some github action code that shows the syntax:
By using a separate, dedicated branch, say As a result, "external" PRs will not trigger deployments (which is not necessarily a bad thing, but I'm eager to hear team's opinion), but only static validation; if and when that passes, a CSC team member will raise a new PR against the As soon as the change is deployed on WDYT? |
Beta Was this translation helpful? Give feedback.
-
Another couple of potential options for enabling CI for forks:
|
Beta Was this translation helpful? Give feedback.
-
Hi all a few extra points to throw in:
Any thoughts? |
Beta Was this translation helpful? Give feedback.
Hi @thinkl33t ! I've shared this already, but probably got lost somewhere in the Slack chat.
As you mention, this limitation is in reality a security "feature".
What I did in the past for other projects was to set a condition in the GitHub action build steps, based on the GitHub username (or org) where the PR os coming from. If it's not "finos", everything but the deployment can be executed, ie the first 2 build steps you mention. Here's some github action code that shows the syntax: