Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Added an unsafe method for loading the tuf metadata on disk #87

Merged
merged 6 commits into from
Dec 8, 2023

Conversation

kommendorkapten
Copy link
Collaborator

No description provided.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (3b7ccba) 71.65% compared to head (19d9861) 71.43%.

Files Patch % Lines
metadata/updater/updater.go 58.33% 10 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #87      +/-   ##
==========================================
- Coverage   71.65%   71.43%   -0.23%     
==========================================
  Files          10       10              
  Lines        1976     2013      +37     
==========================================
+ Hits         1416     1438      +22     
- Misses        453      463      +10     
- Partials      107      112       +5     
Flag Coverage Δ
Go-1.21 71.43% <59.45%> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rdimitrov
Copy link
Owner

@kommendorkapten - Thanks for this 💯

What would you think about:

  • Creating a setting in the updater configuration that we can toggle for allowing to work in this unsafe mode
  • Make this a private method to updater
  • Extract the current content of the Refresh into another private method
  • Upon calling Refresh, we'll decide which method to call based on the setting (default being the safe one)?

Other:

  • What is the best way to incorporate that setting with enabling Refresh to be called multiple times without failing? Perhaps we can have separate settings for each (one to work in offline mode, the other to allow for multiple calls of Refresh?) or something else?

@kommendorkapten
Copy link
Collaborator Author

Yeah, having this as a setting seems more nice.

@kommendorkapten
Copy link
Collaborator Author

@rdimitrov updated to use a parameter instead. Note that calling Refresh multiple times will still fail, I can work around that so it's not important I believe.

@kommendorkapten
Copy link
Collaborator Author

If you think this is good, I'll start to work on getting the tests updated.

Copy link
Owner

@rdimitrov rdimitrov left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

While doing the tests can you verify if this option works together with DisableLocalCache and if they affect each other, add a check that we cannot set both at the same time?

@kommendorkapten
Copy link
Collaborator Author

While doing the tests can you verify if this option works together with DisableLocalCache and if they affect each other, add a check that we cannot set both at the same time?

Is this really needed?

  • DisableLocalCache makes sure nothing is persisted to the filesystem.
  • UnsafeLocalMode makes sure nothing is fetched from the network.

I think it makes sense to allow them together, as even with UnsafeLocalMode, the provided root.json is actually written to disk.

@kommendorkapten kommendorkapten marked this pull request as ready for review December 7, 2023 14:25
@rdimitrov
Copy link
Owner

While doing the tests can you verify if this option works together with DisableLocalCache and if they affect each other, add a check that we cannot set both at the same time?

Is this really needed?

  • DisableLocalCache makes sure nothing is persisted to the filesystem.
  • UnsafeLocalMode makes sure nothing is fetched from the network.

I think it makes sense to allow them together, as even with UnsafeLocalMode, the provided root.json is actually written to disk.

Actually I did not put a lot of thought on it while I asked that, just thought to bring that up to you so if someone enables both it doesn't accidentally interfere with the behaviour of this patch 👍

@kommendorkapten kommendorkapten merged commit 195675c into rdimitrov:main Dec 8, 2023
14 checks passed
@kommendorkapten kommendorkapten deleted the preload-metadata branch December 8, 2023 08:08
kipz pushed a commit to kipz/go-tuf-metadata that referenced this pull request Jan 29, 2024
…v#87)

* Added an unsafe method for loading the tuf metadata on disk

Signed-off-by: Fredrik Skogman <[email protected]>

* Feedback from review. Added a config parameter instead of a separate method.

Signed-off-by: Fredrik Skogman <[email protected]>

* Added unit tests for unsafe local mode

Signed-off-by: Fredrik Skogman <[email protected]>

* DEBUG: remove added tests

Signed-off-by: Fredrik Skogman <[email protected]>

* comment out correct test

Signed-off-by: Fredrik Skogman <[email protected]>

* Uncommented tests cases and disabled go caching

Signed-off-by: Fredrik Skogman <[email protected]>

---------

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

Successfully merging this pull request may close these issues.

2 participants