Skip to content
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

Package manifest checksum TOFU #6322

Merged
merged 2 commits into from
Mar 28, 2023
Merged

Conversation

yim-lee
Copy link
Contributor

@yim-lee yim-lee commented Mar 24, 2023

Motivation:
Currently fingerprints are for source archive (checksum from registry) and source repo (git hash from SCM) only. Additional content types need to be supported if SwiftPM were to do TOFU for manifest files too.

Modifications:

  • Modify fingerprint storage structure to store fingerprint by content type
  • Modfiy fingerprint storage API to allow retrieving fingerprints by content type

@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 24, 2023

@swift-ci please smoke test

{ result in queue.async { closure(result) } }
}
}

private enum StorageModel {
struct Container: Codable {
let versionFingerprints: [String: [String: StoredFingerprint]]
// version -> fingerprint kind -> fingerprint content type
let versionFingerprints: [String: [String: [String: StoredFingerprint.V2]]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note the storage model changes

) {
let contentType = Fingerprint.ContentType.manifest(toolsVersion)

self.readFromStorage(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unlike source archives, registry doesn't provide expected checksum for manifests, so here we do true TOFU I suppose, and that is if checksum not found in storage we save it (whereas for source archive we have registry as an other source).

@@ -67,7 +68,8 @@ public final class RegistryClient: Cancellable {
authorizationProvider: AuthorizationProvider? = .none,
customHTTPClient: LegacyHTTPClient? = .none,
customArchiverProvider: ((FileSystem) -> Archiver)? = .none,
delegate: Delegate?
delegate: Delegate?,
checksumAlgorithm: HashAlgorithm
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This moves passing of checksumAlgorithm from downloadSourceArchive to "global"

yim-lee added 2 commits March 27, 2023 23:15
Motivation:
SwiftPM should do checksum TOFU for package manifests.

Modifications:
- Modify fingerprint storage structure to store fingerprint by content type
- Modfiy fingerprint storage API to allow retrieving fingerprints by content type
- Add API to `ChecksumTOFU` for manifests
- Wire up manifest TOFU in `RegistryClient`
@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 28, 2023

@swift-ci please smoke test

@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 28, 2023

@swift-ci please test Windows platform

@yim-lee yim-lee merged commit 7e972e1 into swiftlang:main Mar 28, 2023
@yim-lee yim-lee deleted the manifest-tofu branch March 28, 2023 18:10
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Mar 28, 2023
* Package manifest checksum TOFU

Motivation:
SwiftPM should do checksum TOFU for package manifests.

Modifications:
- Modify fingerprint storage structure to store fingerprint by content type
- Modfiy fingerprint storage API to allow retrieving fingerprints by content type
- Add API to `ChecksumTOFU` for manifests
- Wire up manifest TOFU in `RegistryClient`

* address review feedback
yim-lee added a commit that referenced this pull request Mar 29, 2023
* Package manifest checksum TOFU

Motivation:
SwiftPM should do checksum TOFU for package manifests.

Modifications:
- Modify fingerprint storage structure to store fingerprint by content type
- Modfiy fingerprint storage API to allow retrieving fingerprints by content type
- Add API to `ChecksumTOFU` for manifests
- Wire up manifest TOFU in `RegistryClient`

* address review feedback
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