tektoncd / tektoncd/chains

[bug] Currently `verifier.go` uses an empty config.Opts when calling `storage/*` `Retrieve*` method -> ShortKey is not defined -> no object found

Open
#1,030 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug
Dominant language
Go
Stars
277
Forks
164
Avg merge
2d 3h
Merged PRs (30d)
61

Description

In looking through the verifer.go logic I see that RetrieveSignatures and RetrievePayloads is called with an empty config.StorageOpts:

https://github.com/tektoncd/chains/blob/main/pkg/chains/verifier.go#L76

signatures, err := b.RetrieveSignatures(ctx, trObj, config.StorageOpts{})

config.StorageOpts{} contains fields including ShortKey which is used in ~3 storage options retrieve calls:

aprindle@aprindle-ssd ~/chains/pkg/chains/storage  [fix-985]ack ShortKey
docdb/docdb.go
72:		Name:      opts.ShortKey,
122:	d := SignedDocument{Name: opts.ShortKey}

gcs/gcs.go
74:			key:    opts.ShortKey,
95:			key:    opts.ShortKey,
211:	return fmt.Sprintf(SignatureNameFormatTaskRun, tr.Namespace, tr.Name, opts.ShortKey)
216:	return fmt.Sprintf(PayloadNameFormatTaskRun, tr.Namespace, tr.Name, opts.ShortKey)
221:	return fmt.Sprintf(SignatureNameFormatPipelineRun, pr.Namespace, pr.Name, opts.ShortKey)
226:	return fmt.Sprintf(PayloadNameFormatPipelineRun, pr.Namespace, pr.Name, opts.ShortKey)

tekton/tekton.go
60:		key:    opts.ShortKey,
142:	return fmt.Sprintf(SignatureAnnotationFormat, opts.ShortKey)
146:	return fmt.Sprintf(PayloadAnnotationFormat, opts.ShortKey)

In contrast for example, in signing.go these values are set:
https://github.com/tektoncd/chains/blob/main/pkg/chains/signing.go#L183

				b := o.Backends[backend]
				storageOpts := config.StorageOpts{
					ShortKey:      signableType.ShortKey(obj),
					FullKey:       signableType.FullKey(obj),
					Cert:          signer.Cert(),
					Chain:         signer.Chain(),
					PayloadFormat: payloadFormat,
				}
				if err := b.StorePayload(ctx, tektonObj, rawPayload, string(signature), storageOpts); err != nil {
					logger.Error(err)
					merr = multierror.Append(merr, err)
				}

IIUC, this means that retrieving objects from these storage types will not work as the keys to lookup will not be correct - ShortKey won't be set (will be "") which leads to the key used for lookup to be incorrect

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at pkg/chains/verifier.go around line 76 and inspect how RetrieveSignatures and RetrievePayloads receive config.StorageOpts{}. Compare this with the StorageOpts construction in pkg/chains/signing.go around line 183, then trace the ShortKey uses in pkg/chains/storage/docdb/docdb.go, gcs/gcs.go, and tekton/tekton.go. Done means retrieval uses the correct lookup key rather than an empty ShortKey across the affected storage types.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.