You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/03/15 08:04:48 UTC

[maven-resolver] 17/19: Be clear about leading dots and validate input

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch MRESOLVER-241
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit 22c14f00c7880b4d5d8c91ce00e08a2aaf02d9a9
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Mon Mar 14 11:48:52 2022 +0100

    Be clear about leading dots and validate input
---
 .../aether/internal/impl/Maven2RepositoryLayoutFactory.java | 13 +++++++++++++
 src/site/markdown/configuration.md                          |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java
index 860bc21..8398591 100644
--- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java
+++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/Maven2RepositoryLayoutFactory.java
@@ -116,6 +116,7 @@ public final class Maven2RepositoryLayoutFactory
                 .split( "," )
         ).filter( s -> s != null && !s.trim().isEmpty() ).collect( Collectors.toCollection( LinkedHashSet::new ) );
 
+        // validation: this loop implicitly validates the list above: selector will throw on unknown algorithm
         List<ChecksumAlgorithmFactory> checksumsAlgorithms = new ArrayList<>( checksumsAlgorithmNames.size() );
         for ( String checksumsAlgorithmName : checksumsAlgorithmNames )
         {
@@ -128,6 +129,18 @@ public final class Maven2RepositoryLayoutFactory
                 .split( "," )
         ).filter( s -> s != null && !s.trim().isEmpty() ).collect( Collectors.toSet() );
 
+        // validation: enforce that all strings in this set are having leading dot
+        if ( omitChecksumsForExtensions.stream().anyMatch( s -> !s.startsWith( "." ) ) )
+        {
+            throw new IllegalArgumentException(
+                    String.format(
+                            "The configuration %s contains illegal values: %s (all entries must start with '.' (dot)",
+                            CONFIG_PROP_OMIT_CHECKSUMS_FOR_EXTENSIONS,
+                            omitChecksumsForExtensions
+                    )
+            );
+        }
+
         return new Maven2RepositoryLayout(
                 checksumsAlgorithms,
                 omitChecksumsForExtensions
diff --git a/src/site/markdown/configuration.md b/src/site/markdown/configuration.md
index adfa9a8..926b688 100644
--- a/src/site/markdown/configuration.md
+++ b/src/site/markdown/configuration.md
@@ -21,7 +21,7 @@ under the License.
 Option | Type | Description | Default Value | Supports Repo ID Suffix
 --- | --- | --- | --- | ---
 `aether.artifactResolver.snapshotNormalization` | boolean | It replaces the timestamped snapshot file name with a filename containing the `SNAPSHOT` qualifier only. This only affects resolving/retrieving artifacts but not uploading those. | `true` | no
-`aether.checksums.omitChecksumsForExtensions` | String | Comma separated list of extensions (`.asc`) that should have checksums omitted. Note: to achieve 1.7.x `aether.checksums.forSignature=true` behaviour, pass empty string as value for this property. | `.asc` | no
+`aether.checksums.omitChecksumsForExtensions` | String | Comma separated list of extensions with leading dot (example `.asc`) that should have checksums omitted. These are applied to sub-artifacts only. Note: to achieve 1.7.x `aether.checksums.forSignature=true` behaviour, pass empty string as value for this property. | `.asc` | no
 `aether.checksums.algorithms` | String | Comma separated list of checksum algorithms with which checksums are validated (downloaded) and generated (uploaded). Resolver by default supports following algorithms: `MD5`, `SHA-1`, `SHA-256` and `SHA-512`. New algorithms can be added by implementing `ChecksumAlgorithmFactory` component. | `"SHA-1,MD5"` | no
 `aether.conflictResolver.verbose` | boolean | Flag controlling the conflict resolver's verbose mode. | `false` | no
 `aether.connector.basic.threads` or `maven.artifact.threads` | int | Number of threads to use for uploading/downloading. | `5` | no