Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline pull request promotions security review ADR #110

Merged
merged 9 commits into from
Mar 7, 2023

Conversation

makkes
Copy link
Member

@makkes makkes commented Feb 16, 2023

@makkes makkes force-pushed the pipelines-security branch 2 times, most recently from ea00c5f to 88e2c2a Compare February 16, 2023 10:09
- We will add documentation to provide clear guidance on how to create a fine-grained token with as little scope as necessary.
- We will add documentation clarifying what we use the token for, so that folks can make informed decisions about how to create it (for example, if you say "Every Pull Request will show up as being created by the user behind the access token", folks might think "Hmmm..., I don’t think that should be my token").

### Design improvements
Copy link
Contributor

@bigkevmcd bigkevmcd Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to store PATs, then you have some other considerations...

  1. Make it clear in the frontend when the token is not longer valid "The stored token is no longer valid"
  2. Make it clear in the frontend which user the token is from

For 1, we built an endpoint that called this https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user in the background, and reported a failure if it was no longer valid.

This needs to be cached, otherwise it uses API counts each time (think several users loading the page).

For 2 we used the response to render the "gravatar_url" in the UI which helped users

"Oh, the token was created by John, he left last week, that's probably why it's failing"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

### Design improvements



Copy link
Contributor

@enekofb enekofb Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions (not in any particular order)

  • extend documentation to provide by git provider examples on how to achieve the setup that we consider the most secure
  • ensure that pipeline controller has all the checks required to avoid escaping from the right security context - for example opening pull request in a repo that is not the pipeline one, etc ...

@enekofb
Copy link
Contributor

enekofb commented Feb 22, 2023

i will come back to the ADR once covered the docs PR weaveworks/weave-gitops#3426




## Consequences
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to pair with @yiannistri and @ahsayde to understand what we could leverage from policy and secrets to enhance pipelines security


## Consequences

tbd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From @bigkevmcd , @MostafaMegahid @yiannistri @enekofb

Scenario A:
As app team that want to leverage pull request creation
automation but having full control
-> i am developer g

  • go to wg pipelines
  • my pipeline has some configuration for this pull request manual
  • there is a new version, so there is deployment happening by flux
  • there is promotion pending
  • promotion dev to test approved interactively by developer A
    via oauth access token (currently we dont have)
  • if there is a promotion going from test to prod we could
    a) cache the token (with short XXX)
    b) request another authn

Scenario B:
As app team i want to leverage pull request creation automation
with maximum security https://fluxcd.io/flux/guides/image-update/

a) assumption we have a token

  • create branch no pull request
    -> what is the security here? there is a branch so the user
    a.1) create the secret in an admin protected ns so the admin
    acts a as gatekeeper for approving, etc ...
    for pipeline-system
    • granularity -> assuming that the token can only give access
      to resource for the operation.
    • short-live -> ephimeral token -> generate

b) we dont have a token (expensive to build )
as pipeline controller i am able to generate an ephimeral token
to create a pr for a particular actions
- option a: github apps
- option b: github apps like generic -> vault backend

@enekofb enekofb marked this pull request as ready for review February 24, 2023 15:35
@enekofb enekofb changed the title initial draft of pipeline security enhancement ADR Pipeline pull request promotions security review ADR Feb 24, 2023
@enekofb enekofb requested review from bigkevmcd and a team February 24, 2023 15:36
enekofb and others added 3 commits March 3, 2023 16:45
Co-authored-by: Yiannis <8741709+yiannistri@users.noreply.github.com>
Co-authored-by: Yiannis <8741709+yiannistri@users.noreply.github.com>
Co-authored-by: Yiannis <8741709+yiannistri@users.noreply.github.com>
@enekofb enekofb requested a review from yiannistri March 3, 2023 16:53
@enekofb enekofb merged commit 2c94564 into main Mar 7, 2023
@enekofb enekofb deleted the pipelines-security branch March 7, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pipelines pull request promotion user flow review
4 participants