Skip to content

Package fingerprint storage #3879

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 3 commits into from
Nov 30, 2021
Merged

Conversation

yim-lee
Copy link
Contributor

@yim-lee yim-lee commented Nov 19, 2021

Motivation:
Provide trust-on-first-use (TOFU) security model for package dependencies. SwiftPM will record locally the "fingerprint" of a package version when it is first downloaded and ensure the fingerprint remain the same in subsequent downloads.

For package downloaded from registry, the fingerprint is the source archive checksum. For source control, it is the git revision.

This PR only adds storage APIs for writing and reading package fingerprints and an implementation that uses local file system. The integration of fingerprint storage into the download workflow(s), i.e. TOFU implementation, will come in a separate PR.

Modifications:

  • Add PackageFingerprint module.
  • Add PackageFingerprintStorage protocol that defines APIs for reading and writing fingerprints.
  • Add FilePackageFingerprintStorage which is an implementation based on file system.

@yim-lee
Copy link
Contributor Author

yim-lee commented Nov 19, 2021

@swift-ci please smoke test


init(customFileSystem: FileSystem? = nil, customDirectory: AbsolutePath? = nil) {
self.fileSystem = customFileSystem ?? localFileSystem
self.directory = customDirectory ?? self.fileSystem.dotSwiftPM.appending(component: "fingerprints")
Copy link
Contributor

@tomerd tomerd Nov 29, 2021

Choose a reason for hiding this comment

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

the default location can go into Workspace.Location / DefaultLocation which handles similar set ups

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making both required so no need to have defaults here.

Motivation:
Provide trust-on-first-use (TOFU) security model for package dependencies. SwiftPM will record locally the "fingerprint" of a package version when it is first downloaded and ensure the fingerprint remain the same in subsequent downloads.

For package downloaded from registry, the fingerprint is the source archive checksum. For source control, it is the git revision.

This PR only adds storage APIs for writing and reading package fingerprints and an implementation that uses local file system. The integration of fingerprint storage into the download workflow(s), i.e. TOFU implementation, will come in a separate PR.

Modifications:
- Add `PackageFingerprint` module.
- Add `PackageFingerprintStorage` protocol that defines APIs for reading and writing fingerprints.
- Add `FilePackageFingerprintStorage` which is an implementation based on file system.
@yim-lee yim-lee force-pushed the fingerprint-storage branch from cec0397 to dc98e7f Compare November 30, 2021 01:45
@yim-lee
Copy link
Contributor Author

yim-lee commented Nov 30, 2021

@swift-ci please smoke test

@yim-lee yim-lee merged commit f040400 into swiftlang:main Nov 30, 2021
@yim-lee yim-lee deleted the fingerprint-storage branch November 30, 2021 17:46
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Nov 30, 2021
This is a continuation of swiftlang#3879.

Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 1, 2021
This is a continuation of swiftlang#3879.

Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 1, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 2, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 2, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 3, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 9, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit that referenced this pull request Dec 9, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 9, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
yim-lee added a commit that referenced this pull request Dec 10, 2021
Wire up fingerprint storage such that it is used for integrity checks of package downloads. Fingerprint must match previously recorded value (if any) or else it would result in an error.
@compnerd
Copy link
Member

compnerd commented Dec 25, 2021

@yim-lee @tomerd - this regressed the Windows builds. Please always make sure you coordinate any new dependencies (any new libraries) with the Windows installers.

@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 25, 2021

Sorry @compnerd, is there anything I need to do to help fix the Windows builds?

@compnerd
Copy link
Member

Thanks @yim-lee. I'll rest to see if I can put up a change later (tomorrow likely). Is there any new target other than PackageFingerprint or any new dependencies?

yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Dec 26, 2021
@yim-lee
Copy link
Contributor Author

yim-lee commented Dec 26, 2021

@compnerd There are:

Does #3968 address issue caused by PackageFingerprint?

@compnerd
Copy link
Member

The problem is due to packaging, so there needs to be an associated change in apple/swift-installer-scripts to package up the additional DLL. Assuming that it is just SystemPackage and OrderedCollections that are used, I think that its just the single missing dll.

compnerd added a commit to compnerd/swift-installer-scripts that referenced this pull request Dec 26, 2021
This adds the new Swift Package Manager content from
swiftlang/swift-package-manager#3879 to the installation manifest.
@compnerd
Copy link
Member

swiftlang/swift-installer-scripts#69 should be what is needed.

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.

4 participants