Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#806 Part 2: Cleanup KeyStore Implementations #808

Closed
wants to merge 2 commits into from

Conversation

endophage
Copy link
Contributor

@endophage endophage commented Jun 29, 2016

Depends on #807 (the actual diff after merging that PR will be about +1400 -1800)

There are a lot of changes here, my apologies for the size of the commit but a good chunk of it is 1:1 changes that just deal with imports that moved around.

Main items:

  • /tuf/store/* moved to storage/
  • trustmanager.KeyFileStore and trustmanager.KeyMemoryStore merged into trustmanager.GenericKeyStore. They had identical functionality with different underlying storage.
    • said storage now encapsulated, not embedded, for greater clarity around who is providing what interface.
  • trustmanager.SimpleFileStore unified with tuf.store.FilesystemStore and now lives at storage.FilesystemStore.
    • All trustmanager.SimpleFileStore tests have been preserved in storage/filestore_test.go and point at FilesystemStore.
  • trustmanager.MemoryStore unified with tuf.store.MemoryStore and now lives at storage.MemoryStore.
    • trustmanager.MemoryStore had no tests.
  • Every time we tried a significant refactor we got bitten by tuf.utils having a dependency (an import) on trustmanager. The trustmanager/x509utils.go code it was depending on for the utils.CanonicalKeyID was standalone (it had dependencies only on golang std lib packages) and has been moved into tuf.utils

General Cleanup:

  • Removed some dead code: LocalStorage, GetTarget (legacy from original flynn/go-tuf storage interface, notary does not provide a way to get targets).
  • Some httpstore tests were doing verification of signatures. Where possible those tests have been moved into tuf.signed. In other places the verification has been replaced with a simple equality tests that more directly tests httpstore behaviour.
  • Unified tuf/utils/util.go and tuf/utils/utils.go into a single file of the latter name. Similarly unified test files.
  • Renamed some files in trustmanager to better reflect their contents.

@endophage endophage changed the title Cleanup keystore WIP #806 Part 2: Cleanup KeyStore Jun 29, 2016
@endophage endophage changed the title WIP #806 Part 2: Cleanup KeyStore WIP #806 Part 2: Cleanup KeyStore Implementations Jun 29, 2016
@endophage endophage force-pushed the cleanup_keystore branch 6 times, most recently from 890112a to 0771aa3 Compare July 6, 2016 04:29
@endophage endophage changed the title WIP #806 Part 2: Cleanup KeyStore Implementations #806 Part 2: Cleanup KeyStore Implementations Jul 6, 2016
@endophage endophage force-pushed the cleanup_keystore branch 2 times, most recently from bfc90c9 to 1ff0f8c Compare July 6, 2016 04:52
@@ -682,7 +682,7 @@ func (r *NotaryRepository) bootstrapRepo() error {
logrus.Debugf("Loading trusted collection.")

for _, role := range data.BaseRoles {
jsonBytes, err := r.fileStore.GetMeta(role, store.NoSizeLimit)
jsonBytes, err := r.fileStore.GetSized(role, store.NoSizeLimit)
Copy link
Contributor

Choose a reason for hiding this comment

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

we can do this in a separate PR, but should we phase out store.NoSizeLimit and change these calls to Get() instead of GetSized()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I figured we'd do that in a different PR. There's already so much in here and that's an important change with meaningful TUF security implications if we change it somewhere we shouldn't, so a smaller PR with just that seems more sensible.

@@ -26,14 +158,14 @@ func TestAddFile(t *testing.T) {
expectedFilePath := filepath.Join(tempBaseDir, testName+testExt)

// Create our SimpleFileStore
Copy link
Contributor

@riyazdf riyazdf Jul 8, 2016

Choose a reason for hiding this comment

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

nit: out of date comments for SimpleFileStore (161, 193, 229)

endophage and others added 2 commits July 11, 2016 15:29
Signed-off-by: David Lawrence <dclwrnc@gmail.com> (github: endophage)
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
}

// Error implements error interface
func (e ErrWrongHash) Error() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think all these errors can also be removed, since I can't seem to find anywhere they're being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in #825

@cyli
Copy link
Contributor

cyli commented Jul 11, 2016

LGTM! I think there are some minor cleanups that can happen in a future PR, but this an awesome improvement and simplification of the keystore code!

@riyazdf
Copy link
Contributor

riyazdf commented Jul 12, 2016

this is great, parts 1&2 LGTM

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants