-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement TOFU for package downloads #3890
Conversation
@swift-ci please smoke test |
9f14b98
to
16dd8d8
Compare
@swift-ci please smoke test |
private let jsonDecoder: JSONDecoder | ||
|
||
public init(configuration: RegistryConfiguration, | ||
identityResolver: IdentityResolver, | ||
customArchiverProvider: ((FileSystem) -> Archiver)? = nil, | ||
customHTTPClient: HTTPClient? = nil, | ||
authorizationProvider: HTTPClientAuthorizationProvider? = nil) | ||
authorizationProvider: HTTPClientAuthorizationProvider? = nil, | ||
fingerprintStorage: PackageFingerprintStorage? = nil) |
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.
should authorizationProvider
and fingerprintStorage
be non-optional? they feel like they should be required (ie they are not customization like customHTTPClient
which is optional). If this was made optional for unit tests, we can create extensions in the test module to make it easier to construct while keeping the main constructor "correct"
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.
The only reason fingerprintStorage
is optional is because sharedCacheDirectory
is optional. What should we default storage path to in that case?
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.
fingerprintStorage
is non-optional 036385b
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.
this is great. some suggestions / questions inline
cc @andyp-apple and @robertlacroix |
very nice 👍 |
guard revision.identifier == fingerprint.value else { | ||
throw StringError("Source control fingerprint \(revision.identifier) for \(self.package) version=\(version) does not match previously recorded value \(fingerprint.value)") | ||
} | ||
} | ||
|
||
/// Returns revision for the given tag. |
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.
can this new private now?
@swift-ci please smoke test |
@swift-ci please smoke test |
} | ||
|
||
// The revision (i.e., hash) must match that in fingerprint storage otherwise the integrity check fails | ||
if revision.identifier != fingerprint.value { |
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.
should this check move to L169 (inside the first case basically)?
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.
It could be, but then any error thrown would get caught in the catch
block (if you recall the code was checking for StringError
specifically) and the code wouldn't be as clean.
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!
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.
@swift-ci please smoke test |
This is a continuation of #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.
strictFingerprintChecking
) to ignore TOFU failures (i.e., error -> warning).swiftpm/security/fingerprints/