Skip to content

Expected signing entity verification #6359

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 1 commit into from
Apr 3, 2023

Conversation

neonichu
Copy link
Contributor

This allows clients to pass in a dictionary with expected signing entities that SwiftPM will check after loading the package graph. This can be used by clients to provide a priori configuration of expected signing by the user or provide a way to verify that information that was previously shown to users matches what was verified during signature verification.

Note that since this operates at the workspace level, we're verifying against the data cached during signature verification, not against the actual data.

rdar://107162424

@neonichu neonichu requested a review from abertelrud as a code owner March 31, 2023 15:59
@neonichu neonichu self-assigned this Mar 31, 2023
@neonichu neonichu requested a review from tomerd as a code owner March 31, 2023 15:59
}
} else {
// Unsure if this case is reachable in practice.
throw SigningError.expectedIdentityNotFound(package: identity)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how we get into this scenario, so this isn't covered by any tests right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this more of an invalid state error?

@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

try expectedSigningEntities.forEach { identity, expectedSigningEntity in
if let package = packageGraph.packages.first(where: { $0.identity == identity }) {
if let actualSigningEntity = package.registryMetadata?.signature?.signedBy {
if actualSigningEntity != expectedSigningEntity {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should the comparison be more limited?

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you have in mind? e.g., must be .recognized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, just posing the question

}
} else {
// Unsure if this case is reachable in practice.
throw SigningError.expectedIdentityNotFound(package: identity)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this more of an invalid state error?

This allows clients to pass in a dictionary with expected signing entities that SwiftPM will check after loading the package graph. This can be used by clients to provide a priori configuration of expected signing by the user or provide a way to verify that information that was previously shown to users matches what was verified during signature verification.

Note that since this operates at the workspace level, we're verifying against the data cached during signature verification, not against the actual data.

rdar://107162424
@neonichu neonichu force-pushed the expected-signing-entity-verification branch from 1ecbcae to 2792132 Compare March 31, 2023 17:36
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@MaxDesiatov
Copy link
Contributor

@swift-ci smoke test macos

@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@neonichu neonichu merged commit a6fde25 into main Apr 3, 2023
@neonichu neonichu deleted the expected-signing-entity-verification branch April 3, 2023 19:04
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