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

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

Open
aaron-prindle opened this issue Jan 10, 2024 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@aaron-prindle
Copy link
Contributor

aaron-prindle commented Jan 10, 2024

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

@aaron-prindle aaron-prindle added the kind/bug Categorizes issue or PR as related to a bug. label Jan 10, 2024
@aaron-prindle aaron-prindle changed the title [bug] Currently verifier.go to storage/ Retrieve* use an empty config.Opts -> ShortKey is not defined -> no object found [bug] Currently verifier.go uses an empty config.Opts when calling storage/* Retrieve* method -> ShortKey is not defined -> no object found Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant