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

Reduce errors from manifest signature validation #6325

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

yim-lee
Copy link
Contributor

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

Motivation:
Manifest signature validation works similarly as source archive signature validation, meaning user could see duplicate errors (e.g., source archive not signed).

Modifications:

  • Change most error throwing to logging diagnostics for manifest signature validation
  • Continue to prompt if that's what user has configured for unsigned packages or untrusted signers; cache responses in memory to prevent repeatedly prompting for manifest and source archive downloads for the same package version.
  • Wire up publisher TOFU for manifest signing
  • Adjust tests

@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 24, 2023

@swift-ci please smoke test

@@ -201,6 +204,88 @@ struct SignatureValidation {
}
}

private func validateSourceArchiveSignature(
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 is the same as the original validateSignature.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for this function itself not being async? Only trying to understand whether we're trying to avoid async functions completely for now or is there some boundary along within which we should keep functions callback-based?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RegistryClient (the caller of this) uses callback so async has to stop somewhere (for now at least).

@neonichu
Copy link
Contributor

In case of an error during manifest signature validation, I would expect archive validation to not even happen because we wouldn't know which archive to even download. Am I missing something?

@yim-lee yim-lee force-pushed the reduce-manifests-errors branch from 9169ece to c7975a0 Compare March 24, 2023 22:18
@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 24, 2023

@swift-ci please smoke test

@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 24, 2023

@swift-ci please test Windows platform

@@ -2259,14 +2259,29 @@ extension RegistryReleaseMetadata {
private struct RegistryClientSignatureValidationDelegate: SignatureValidation.Delegate {
let underlying: RegistryClient.Delegate?

private let onUnsignedResponseCache = ThreadSafeKeyValueStore<ResponseCacheKey, Bool>()
private let onUntrustedResponseCache = ThreadSafeKeyValueStore<ResponseCacheKey, Bool>()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added caching to avoid prompting repeatedly

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

case .success(let signingEntity):
// Always do signing entity TOFU check at the end,
// whether the manifest is signed or not.
self.signingEntityTOFU.validate(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TOFU

@@ -304,48 +412,38 @@ struct SignatureValidation {
version: version
)

// Prompt if configured, otherwise just continue (this differs
// from source archive to minimize duplicate loggings).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👀

Motivation:
Manifest signature validation works similarly as source archive signature validation, meaning user could see duplicate errors (e.g., source archive not signed).

Modifications:
- Change most error throwing to logging diagnostics for manifest signature validation
- Continue to prompt if that's what user has configured for unsigned packages or untrusted signers; cache responses in memory to prevent repeatedly prompting for manifest and source archive downloads for the same package version.
- Wire up publisher TOFU for manifest signing
- Adjust tests
@yim-lee yim-lee force-pushed the reduce-manifests-errors branch from c7975a0 to d0accdc Compare March 27, 2023 23:19
@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 27, 2023

@swift-ci please smoke test

@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 27, 2023

@swift-ci please test Windows platform

@tomerd
Copy link
Contributor

tomerd commented Mar 28, 2023

windows CI has been unstable all day. okay to merge without.

@yim-lee
Copy link
Contributor Author

yim-lee commented Mar 28, 2023

@swift-ci please test Windows platform

@yim-lee yim-lee merged commit eec67d7 into swiftlang:main Mar 28, 2023
@yim-lee yim-lee deleted the reduce-manifests-errors branch March 28, 2023 03:36
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Mar 28, 2023
Motivation:
Manifest signature validation works similarly as source archive signature validation, meaning user could see duplicate errors (e.g., source archive not signed).

Modifications:
- Change most error throwing to logging diagnostics for manifest signature validation
- Continue to prompt if that's what user has configured for unsigned packages or untrusted signers; cache responses in memory to prevent repeatedly prompting for manifest and source archive downloads for the same package version.
- Wire up publisher TOFU for manifest signing
- Adjust tests
yim-lee added a commit that referenced this pull request Mar 28, 2023
Motivation:
Manifest signature validation works similarly as source archive signature validation, meaning user could see duplicate errors (e.g., source archive not signed).

Modifications:
- Change most error throwing to logging diagnostics for manifest signature validation
- Continue to prompt if that's what user has configured for unsigned packages or untrusted signers; cache responses in memory to prevent repeatedly prompting for manifest and source archive downloads for the same package version.
- Wire up publisher TOFU for manifest signing
- Adjust tests
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