Repository navigation
Description
What are you trying to do?
At the moment, we can mark things as sensitive ONLY from environment variables that exist before the Dagger client is created.
We do this with: client.host().envVariable("X").secret()
In a mono-repository environment, or any environment where more than a single secrets backend is used - this can be rather difficult to orchestrate. Do we blanket make every secret available before we run, or can we do this smarter?
I've tried two approaches.
- Container Based Fetch
- Host Based Fetch
Container Based Fetch
This was my first approach. Dagger can run containers really well, so let's run a Doppler container that can fetch secrets dynamically. We provide a single ENV on the host, the DOPPLER_TOKEN, and we provide a helper function that can getSecrets("project", "environment");
This works very well, but unfortunately there's no API with Dagger to mark a value as sensitive. We can mark a file from a container as sensitive, but in this particularly use-case that file is actually a collection of secrets that are used independently (I run JSON.parse on the value) meaning we lose the sensitivity of each unique secret when used in isolation.
Desire an API to dynamically mark individual values as sensitive would be ideal for this use-case.
Host Based Fetch
After discussions with the Dagger team, it was actually determined that we shouldn't fetch these secrets within a container - as it leaves stuff around in the build cache. We should leverage Dagger's native-code abilities to run commands on the host and then push secrets into Dagger.
I agree this is the preferred approach and is what I do now. It works great .. until it doesn't.
Challenge
When Dagger crashes, it currently dumps the world into STDOUT/STDERR. This has printed by GCP's credentials to GitHub Actions MANY times now.
With either approach, it's become very apparent that we need the ability to client.makeSecret like we could with the CUE API.
Reference Dagger code: https://github.com/RawkodeAcademy/RawkodeAcademy. See:
Why is this important to you?
I don't want to rotate my credentials every time Dagger pipeline crashes when run on GitHub Actions
How are you currently working around this?
Only running Dagger locally on my machine
Activity
shykes commentedon Jan 9, 2023
Shouldn't we discuss how to fix that? So far I'm seeing much discussion of rushing to a new API because of a security defect in the current one. It seems to me that we should first explore the possibility of making it safe to create a secret from a container - thus fixing your problem AND removing a defect in our current API.
cc @jlongtine @aluzzardi @sipsma
rawkode commentedon Jan 9, 2023
I'm not sure, actually. Especially as remote caching becomes more of a thing later - there's a lot of security posture-benefits that come from controlling the execution of the Dagger pipeline and pushing more sensitive stuff there, while leaning on the container workloads for the grunt-work.
I think this pattern leverages the benefits of Dagger's new native code possibilities. Sure, I can run a container that speaks to Vault or Doppler, but I think this is cleaner. If I control the local execution I can restrict API access to secrets with a static IP of the runner, but still offload all the boring work to build farms.
I agree that you shouldn't rush into a new API, but I do think it should be possible (in any situation) to mark a value as sensitive and make it available to container based workloads.
rawkode commentedon Jan 9, 2023
If it helps, my pipelines with earthly.dev work in a pretty nice fashion. Perhaps some inspiration could come from there?
This
--secret "studio__FIREBASE_TOKEN" gets sent to a local credential helper that I write myself which splits the string on "studio__FIREBASE_TOKEN" and runs, locally,doppler secrets get --project studio --plain FIREBASE_TOKENand then mounts it into the container with--mount=type=secret` etcThe API I'm suggesting would be to allow:
Dagger ALREADY provides these APIS:
But we don't have the ability to mark things as sensitive, and I think that's important.
[-]✨ Dynamic Secrets API[/-][+]Dagger prints my secrets when it crashes[/+]shykes commentedon Jan 19, 2023
@rawkode I took the liberty of editing your issue's title, to reflect the gist of your feedback / complaint. I hope you don't mind. This is to help organize and navigate our growing collection of issue-related issues.
mircubed commentedon Feb 6, 2023
@samalba will review this issue to ensure that it is solved with the solutions from #4413
mircubed commentedon Feb 25, 2023
@samalba @dolanor can you review this one to see if #4413 solves it? If so, can you close this one?
samalba commentedon Feb 27, 2023
Given that part of the original issue is related to dynamic secret support, let's keep this open until #4426 is closed.
mircubed commentedon Mar 28, 2023
@dolanor since #4426 is closed, can we close this one as well?
dolanor commentedon Mar 30, 2023
Yes, I think this has been fixed.
If it's still doesn't meet your requirement, @rawkode , don't hesitate to reopen and tell us why :)