Skip to content

Commit 9ea626a

Browse files
Merge pull request #76 from drone-runners/CI-15733
fix: [CI-15903]: Fixed secret masking issue with drone docker runner
2 parents bb7abc3 + 3834867 commit 9ea626a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

engine/compiler/compiler.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,28 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
390390
removeCloneDeps(spec)
391391
}
392392

393+
// Creating an object to store a secret data which which will be injected across all steps for masking.
394+
var secretData [][]byte
393395
for _, step := range spec.Steps {
394396
for _, s := range step.Secrets {
395397
secret, ok := c.findSecret(ctx, args, s.Name)
396398
if ok {
397399
s.Data = []byte(secret)
400+
secretData = append(secretData, []byte(secret))
398401
}
399402
}
400403
}
401404

405+
for _, value := range secretData {
406+
for _, step := range spec.Steps {
407+
e := &engine.Secret{
408+
Data: value,
409+
Mask: true,
410+
}
411+
step.Secrets = append(step.Secrets, e)
412+
}
413+
}
414+
402415
// get registry credentials from registry plugins
403416
creds, err := c.Registry.List(ctx, &registry.Request{
404417
Repo: args.Repo,
@@ -525,7 +538,6 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
525538
}
526539
spec.Volumes = append(spec.Volumes, src)
527540
}
528-
529541
return spec
530542
}
531543

engine/convert.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ func toConfig(spec *Spec, step *Step) *container.Config {
3232
config.Env = toEnv(step.Envs)
3333
}
3434
for _, sec := range step.Secrets {
35-
config.Env = append(config.Env, sec.Env+"="+string(sec.Data))
35+
if sec.Env != "" {
36+
config.Env = append(config.Env, sec.Env+"="+string(sec.Data))
37+
}
3638
}
3739

3840
if len(step.Entrypoint) != 0 {

0 commit comments

Comments
 (0)