Repository navigation
Closed
Description
What is the issue?
When I use an env variable as a secret, I would like to re-execute the pipeline if I update the env var.
Log output
First execution
DBGTHE: {"query":"query{host{envVariable(name:\"MY_SECRET_ID\"){secret{id}}}}","operationName":""}
DBGTHE: {"query":"query{container{from(address:\"alpine:latest\"){withSecretVariable(name:\"MY_SECRET_ID\", secret:\"eyJob3N0X2VudiI6Ik1ZX1NFQ1JFVF9JRCJ9\"){withExec(args:[\"sh\",\"-c\",\"echo super secret: $MY_SECRET_ID; date;\"]){stdout}}}}}","operationName":""}
#1 resolve image config for docker.io/library/alpine:latest
#1 DONE 0.8s
#2
#2 DONE 0.0s
#3 from alpine:latest
#3 resolve docker.io/library/alpine:latest
2023/02/15 17:59:38 LOGSTDOUT: super secret: my secret value
Wed Feb 15 16:56:13 UTC 2023
second execution after changing var
DBGTHE: {"query":"query{host{envVariable(name:\"MY_SECRET_ID\"){secret{id}}}}","operationName":""}
DBGTHE: {"query":"query{container{from(address:\"alpine:latest\"){withSecretVariable(name:\"MY_SECRET_ID\", secret:\"eyJob3N0X2VudiI6Ik1ZX1NFQ1JFVF9JRCJ9\"){withExec(args:[\"sh\",\"-c\",\"echo super secret: $MY_SECRET_ID; date;\"]){stdout}}}}}","operationName":""}
#1 resolve image config for docker.io/library/alpine:latest
#1 DONE 0.4s
#2 importing cache manifest from dagger:10686922502337221602
#2 DONE 0.0s
#3
#3 DONE 0.0s
#4 from alpine:latest
#4 resolve docker.io/library/alpine:latest
2023/02/15 18:00:30 LOGSTDOUT: super secret: my secret value
Wed Feb 15 16:56:13 UTC 2023
In the query, we can see the withSecretVariable.secret has the same value, so some caching is not basing itself on the value, but more on the name.
Steps to reproduce
package main
import (
"context"
"log"
"os"
"dagger.io/dagger"
)
func main() {
// Change this value and reexecute.
err := os.Setenv("MY_SECRET_ID", "my secret value ")
if err != nil {
panic(err)
}
ctx := context.Background()
c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stdout))
secret := c.Host().EnvVariable("MY_SECRET_ID").Secret()
stdout, err := c.Container().
From("alpine:latest").
//WithEnvVariable("CACHEBUSTER", time.Now().String()).
WithSecretVariable("MY_SECRET_ID", secret).
WithExec([]string{"sh", "-c", "echo super secret: $MY_SECRET_ID; date;"}).
Stdout(ctx)
log.Println("LOGSTDOUT:", stdout)
}SDK version
Go SDK v0.4.5
OS version
Ubuntu 20.04
Metadata
Metadata
Assignees
Labels
No labels
Activity
elebeaup commentedon Feb 15, 2023
I think this is relevant moby/buildkit#2547. Invalidate the cache when the value changes would be an information leak
dolanor commentedon Mar 8, 2023
This should be solved with the new implementation.
We can re-assess once it's in.
dolanor commentedon Apr 18, 2023
With the implementation in #4971, it shouldn't invalidate the cache and therefore respect moby/buildkit#2547 which is better for security.