-
Notifications
You must be signed in to change notification settings - Fork 4
Sync TUF cache used for sigstore bundle verification #166
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
Conversation
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, suggested minor change.
pkg/tuf/repo.go
Outdated
) | ||
|
||
// GetTrustedRoot returns the trusted root for the TUF repository. | ||
func GetTrustedRoot() (*root.TrustedRoot, error) { | ||
once.Do(func() { | ||
now := time.Now().UTC() | ||
if timestamp.IsZero() || timestamp.Before(now.Add(-24*time.Hour)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Before(now.Add(-24*Hour)
doesn't quite roll off the tongue. What about,
is now 24hrs after the last time we checked?
now.After(timestamp.Add(24*time.Hour))
(assuming I didn't mess up the math, time math is notoriously tricky)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems easier to understand to me
Signed-off-by: Meredith Lancaster <malancas@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, looks good!
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
* sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Cody Soyland <codysoyland@github.com> Sync TUF cache used for sigstore bundle verification (#166) * sync tuf cache used for sigstore bundle verification Signed-off-by: Meredith Lancaster <malancas@github.com> * remove singleton err Signed-off-by: Meredith Lancaster <malancas@github.com> * start adding lock Signed-off-by: Meredith Lancaster <malancas@github.com> * Use RWMutex Signed-off-by: Meredith Lancaster <malancas@github.com> * pr feedback Signed-off-by: Meredith Lancaster <malancas@github.com> --------- Signed-off-by: Meredith Lancaster <malancas@github.com> Fix shadowed trustedroot (#178) * Fix shadowed variable bug This code caused the singleton `trustedRoot` to be returned as nil on subsequent calls. The singleton was shadowed when the variable was redeclared in the `if` block. Signed-off-by: Cody Soyland <codysoyland@github.com> * Remove unused singleton `singletonRootError` was never returned without being overwritten, so it was essentially unused. I think it's wise to always retry the TUF call on future invocations in case of network errors. Signed-off-by: Cody Soyland <codysoyland@github.com> --------- Signed-off-by: Cody Soyland <codysoyland@github.com> Update go.mod Signed-off-by: Cody Soyland <codysoyland@github.com>
Part of https://github.com/github/package-security/issues/1732
Update
GetTrustedRoot
to sync the TUF cache every 24 hours. I will look into threading the newtrustroot-resync-period
flag down to this function to the resync period is no longer hardcoded in a follow up.