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

[#112] Enable GPG checks of channel artifacts #268

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

spyrkob
Copy link
Contributor

@spyrkob spyrkob commented Jun 18, 2024

Fixes #112

  • Initial SignatureValidator API
  • Pass GPG setting to dependant channels
  • Update validator signatur
  • Add SignatureValidator implementation
  • Use return status instead of exceptions
  • Report validation errors
  • Add keyserver support to the validator
  • Create channel version 2.1.0

@spyrkob spyrkob marked this pull request as ready for review August 8, 2024 12:25
@spyrkob
Copy link
Contributor Author

spyrkob commented Aug 8, 2024

@jmesnil could you review this please? It's a large one, if it makes it easy I can split it up into spec/API changes and implementation PRs.

}

@JsonIgnore
public boolean requiresGpgCheck() {
Copy link
Member

Choose a reason for hiding this comment

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

do we need this method as it kind of duplicates isGpgCheck?

Copy link
Contributor Author

@spyrkob spyrkob Aug 12, 2024

Choose a reason for hiding this comment

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

I added it to avoid having to check isGpgCheck() for null every time, but I think it just made it more confusing, I'm happy to remove it.

Copy link
Member

Choose a reason for hiding this comment

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

+1, let's store the field as a boolean and deal only once with the nullability of the Boolean param in the constructor.

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 ended up keeping the field as a Boolean to allow channels without gpg-check fields to be deserialized & serialized without changes. The public getter deals with the null check

@JsonProperty(value = "resolve-if-no-stream") NoStreamStrategy noStreamStrategy) {
@JsonProperty(value = "resolve-if-no-stream") NoStreamStrategy noStreamStrategy,
@JsonProperty(value = "gpg-check") Boolean gpgCheck,
@JsonProperty(value = "gpg-keys") List<String> gpgUrls) {
Copy link
Member

Choose a reason for hiding this comment

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

there is a mismatch between the json property gpg-keys and the java field gpgUrls.
What are the String representing? keys or URLs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fields contains URLs where the keys can be downloaded from. Originally I called the field gpg-urls, later renamed it to gpg-keys to follow YUM naming, but I suppose that's not really required.

doc/spec.adoc Outdated
@@ -76,6 +77,8 @@ A channel is composed of several fields:
** `maven-latest` - a version marked as `latest` in the Maven metadata
** `maven-release` - a version marked as `release` in the Maven metadata
** `none` - do not attempt to resolve versions of artifact not listed in the `streams` collection. Default value if no strategy is provided.
* Optional `gpg-check` boolean indicating if the artifacts resolved from this channel have to have a valid GPG signature.
Copy link
Member

Choose a reason for hiding this comment

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

s/have to have/must be checked with ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this sound better?

"Optional gpg-check boolean indicating that during artifact resolution, this channel will verify a signature of every artifact. If the artifact signature cannot be found, or cannot be validated, the artifact will not be resolved from the channel. The channel repositories must contain a detached GPG signature paired with the artifact as described below."

doc/spec.adoc Outdated
@@ -76,6 +77,8 @@ A channel is composed of several fields:
** `maven-latest` - a version marked as `latest` in the Maven metadata
** `maven-release` - a version marked as `release` in the Maven metadata
** `none` - do not attempt to resolve versions of artifact not listed in the `streams` collection. Default value if no strategy is provided.
* Optional `gpg-check` boolean indicating if the artifacts resolved from this channel have to have a valid GPG signature.
* Optional `gpg-key` a list of URLs that the public GPG keys used to validate artifact signatures are resolved from.
Copy link
Member

Choose a reason for hiding this comment

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

s/gpg-key/gpg-keys

Optional `gpg-keys` a list of URLs corresponding to the public GPG keys used to validate artifact signatures.

If gpg-check is true, gpg-keys must be set too, right?

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 necessary. The client using wildfly-channels may have a local keystore that's used to resolve the required public keys, or they can use public keyservers.

The gpg-keys field was meant to be an optional way to provide the channel definition with a way to pass information were the key may be found.

### Changelog

### Version 2.1.0

* Adding ability to verify artifact signatures
Copy link
Member

Choose a reason for hiding this comment

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

could you please also add the fields added in this version?

pom.xml Outdated
@@ -31,10 +31,12 @@
<version.org.jboss.logging>3.6.0.Final</version.org.jboss.logging>
<version.org.apache.commons.commons-lang3>3.14.0</version.org.apache.commons.commons-lang3>
<version.org.apache.httpcomponents.httpclient>4.5.14</version.org.apache.httpcomponents.httpclient>
<version.org.bouncycastle>1.76</version.org.bouncycastle>
Copy link
Member

Choose a reason for hiding this comment

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

Are the versions of the added dependencies aligned with WildFly Core (or WildFly)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like I'm a bit behind with the WildFly Core, updated now

<version>${version.org.assertj}</version>
</dependency>
<dependency>
<groupId>org.pgpainless</groupId>
Copy link
Member

Choose a reason for hiding this comment

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

is that a new dependency in the WildFly ecosystem? (it's the first I hear from it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it's a new dependency. I used it for writing tests only as it makes GPG key operations much easier. If that's a problem I can re-write the tests to remove it

* The order of returned URLs is the same as order of coordinates.
*
* @param coords - list of ChannelMetadataCoordinate.
* @param optional - if artifact is optional, the method will return an empty collection if no versions are found
Copy link
Member

Choose a reason for hiding this comment

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

it's not clear to me what "if artifact is optional" means? When would an artifact be optional?

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 about blocklist. According to the spec, if no blocklist can be resolved at specified coordinates, the channel should ignore this blocklist:

If no blocklist artifact can be resolved with supplied Maven coordinates, the channel treats it as an empty blocklist.

The idea behind it was to allow for a channel definition that would later add a blocklist.

Either way, this should probably be its own issue and PR, I'll create one

@spyrkob
Copy link
Contributor Author

spyrkob commented Sep 13, 2024

@jmesnil this should be ready for re-review, sorry about the delay. Again if it's easier I can break this down into smaller PRs (e.g. API/Spec changes vs implementation)

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.

Verify the integrity of components coming from channels
2 participants