#release-engineering (2022-03)

jenkins_ci All things CI/CD. Specific emphasis on Codefresh and CodeBuild with CodePipeline.

CI/CD Discussions

Archive: https://archive.sweetops.com/release-engineering/

2022-03-01

roth.andy avatar
roth.andy

My team ~hates~ dislikes the /test all chatops that I set up in order to run GitHub Actions that require secrets from forks. (I copy/pasted CloudPosse’s slash-command-dispatch.yaml) We looked at enabling that setting that requires approvals before pipeline runs from forks, but it only requires an approval once from a given user. It’s a mitigation to prevent annoyance and frivolous pipeline runs, not to protect the repo’s secrets.

Is there any other option? I’m sure you guys have looked at this a lot.

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

For the record, I hate the /test chat ops as well, the only reason we do it is there is no other way to run the tests for PRs from forks in a safe way

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

this is why organizations like Kubernetes use chat ops

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

So it would be helpful to understand what part that needs solving

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)


It’s a mitigation to prevent annoyance and frivolous pipeline runs, not to protect the repo’s secrets.

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

in this case, require a label to be added to the PR for tests to run

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

then just have them trigger in standard PR synchronizations

roth.andy avatar
roth.andy

I’ll go look for an example of Kubernetes using chat ops, that would be helpful. Thanks

roth.andy avatar
roth.andy

Jon and I tried a few things.

  1. We confirmed that secrets are not available to PRs from forks that use the pull_request event, even if they are approved.
  2. We discovered that the pipeline run approval only happens once for a given user. If I want to do malicious things to this repo I can submit an innocent-looking PR from a fork and have its pipeline run approved, then push a commit that exfiltrates the repo’s secrets. The 2nd pipeline will run automatically without requiring an approval. The mitigation to this is to either ensure pipeline runs do not need secrets to operate or to force a manual review before each pipeline run that needs secrets by doing a chatops command.

We can talk further about it later this afternoon when we meet to discuss the GitLab vs Keycloak thing

roth.andy avatar
roth.andy

Context ^

loren avatar

can you further define “annoyance and frivolous pipeline runs”?

loren avatar

and, are you able to use filters, instead? split the workflows up, and use filters to declare when they should run…

on:
  # Run on demand
  workflow_dispatch:

  # Run pull requests against the main branch
  pull_request:
    branches: [main]
    paths:
      - 'Dockerfile.*'
      - '.github/workflows/build.yml'
      - 'package-templates/**'

  # Run when a release is created
  release:
    types: [released]
roth.andy avatar
roth.andy

This is the setting I’m referring to. From the doc that it links:
Although workflows from forks do not have access to sensitive data such as secrets, they can be an annoyance for maintainers if they are modified for abusive purposes.

loren avatar

right, but you said it was not about secrets

roth.andy avatar
roth.andy

Right, this setting isn’t about secrets. My needs are about secrets. How can we safely run github actions from forks that need secrets to run, without needing to do the chatops command? My understanding right now is, “you can’t”, but I’m looking for as much information as possible

roth.andy avatar
roth.andy

From people smart on the topic

loren avatar

ahh, it wasn’t clear that the jobs were using secrets, just that chatops was creating kinda “on-demand” runs

loren avatar

i’m not familiar with how slash-command-dispatch works… but even with a pr from a fork, jobs are still triggered even if they use secrets. it’s just the secret is empty. so, presumably, you could have a job that acts like a webhook and kicks off something else that does have access to the secrets?

jose.amengual avatar
jose.amengual

solution: fire everyone that does not like it, easy

1
roth.andy avatar
roth.andy

hah!

roth.andy avatar
roth.andy

We settled on a hybrid approach, doing as many workflows as we can that don’t require secrets, and still using chatops like we have been for the ones that do need secrets

roth.andy avatar
roth.andy

Thanks for the input everyone! It was super helpful

    keyboard_arrow_up