Skip to content

Cache the location of the remote repository when running cosign initialize #1315

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

Merged
merged 5 commits into from
Jan 21, 2022

Conversation

asraa
Copy link
Contributor

@asraa asraa commented Jan 13, 2022

Signed-off-by: Asra Ali [email protected]

Summary

Caches the remote repository location so that updates will pull from the cached remote instead of defaulting to the sigstore GCS bucket. This allows clients to automatically pull updates from their custom root when their root is expired and avoids a local/remote mismatch.

Ticket Link

This fixes #1289 per @rgerganov and #1293

Release Note


Signed-off-by: Asra Ali <[email protected]>

Signed-off-by: Asra Ali <[email protected]>
asraa added 3 commits January 14, 2022 15:24
Signed-off-by: Asra Ali <[email protected]>
Signed-off-by: Asra Ali <[email protected]>
@asraa
Copy link
Contributor Author

asraa commented Jan 20, 2022

addressed the JSON comment and added a test! @haydentherapper

Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! The tests look fantastic!

// RemoteCache contains information to cache on the location of the remote
// repository.
type remoteCache struct {
Mirror string `json:"mirror"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid exporting, should we use lowercase mirror? Since remoteCache isn't exported, we shouldn't need to export the struct variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not exported json won't serialize it :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's unfortunate, oh well

updateTufRepo(t, td, r, "foo1")

// Force expiration on the first timestamp.
expCleanup = forceExpirationVersion(1, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, why do we need to force the expiration again for version 1, after it's been done on line 180?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two places where we're forcing verification to fail -- once in cosign when we check specifically for the timestamp, and once internally in go-tuf. The first call disables both so that internal go-tuf actually fails when calling Update() (otherwise NewFromEnv will enventually pass -- fails on our check, then passes with the Update).

In the second call, we want to make cosign think it needs to fetch an update because the timestamp v1 is expired, but let Update fetch all the latest data from remote without forcing failure.

AS I WRITE THIS: I realize I should just split this up to to only cleanup the internal go-tuf force failure. Thanks :)

Signed-off-by: Asra Ali <[email protected]>
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dlorenc dlorenc merged commit 9acdf64 into sigstore:main Jan 21, 2022
@github-actions github-actions bot added this to the v1.5.0 milestone Jan 21, 2022
mlieberman85 pushed a commit to mlieberman85/cosign that referenced this pull request May 6, 2022
…alize (sigstore#1315)

* store remote

Signed-off-by: Asra Ali <[email protected]>

Signed-off-by: Asra Ali <[email protected]>

* add test

Signed-off-by: Asra Ali <[email protected]>

* use json struct for cached remote info

Signed-off-by: Asra Ali <[email protected]>

* update lint

Signed-off-by: Asra Ali <[email protected]>

* update

Signed-off-by: Asra Ali <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TUF: Support option to reference mirror during verification/signing
3 participants