You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2021/03/14 19:55:14 UTC

[maven] branch MNG-7118 created (now 0482052)

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

hboutemy pushed a change to branch MNG-7118
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at 0482052  [MNG-7118] block HTTP repositories by default

This branch includes the following new commits:

     new aad23f5  use Maven Resolver 1.6.2-SNAPSHOT
     new 5c5e716  [MNG-7116] add support for mirrorOf external:http:*
     new 591e9f1  [MNG-7117] add support for blocked mirror
     new 0482052  [MNG-7118] block HTTP repositories by default

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven] 04/04: [MNG-7118] block HTTP repositories by default

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MNG-7118
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 04820522589ae7741a3371570287f77c853ec65a
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Mar 13 19:03:43 2021 +0100

    [MNG-7118] block HTTP repositories by default
---
 apache-maven/src/assembly/maven/conf/settings.xml | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/apache-maven/src/assembly/maven/conf/settings.xml b/apache-maven/src/assembly/maven/conf/settings.xml
index b5a5a03..2f18af3 100644
--- a/apache-maven/src/assembly/maven/conf/settings.xml
+++ b/apache-maven/src/assembly/maven/conf/settings.xml
@@ -43,9 +43,9 @@ under the License.
  | values (values used when the setting is not specified) are provided.
  |
  |-->
-<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
+<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 https://maven.apache.org/xsd/settings-1.1.0.xsd">
+          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
   <!-- localRepository
    | The path to the local repository maven will use to store artifacts.
    |
@@ -156,6 +156,13 @@ under the License.
       <url>http://my.repository.com/repo/path</url>
     </mirror>
     -->
+    <mirror>
+      <id>maven-default-http-blocker</id>
+      <mirrorOf>external:http:*</mirrorOf>
+      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
+      <url>http://0.0.0.0/</url>
+      <blocked>true</blocked>
+    </mirror>
   </mirrors>
 
   <!-- profiles


[maven] 02/04: [MNG-7116] add support for mirrorOf external:http:*

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MNG-7118
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 5c5e71693978e2de7f4d1825d5eae7a4c09c0196
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Mar 13 18:40:48 2021 +0100

    [MNG-7116] add support for mirrorOf external:http:*
---
 .../maven/repository/DefaultMirrorSelector.java    | 41 ++++++++++++++++++++--
 .../apache/maven/bridge/MavenRepositorySystem.java | 39 ++++++++++++++++++--
 2 files changed, 75 insertions(+), 5 deletions(-)

diff --git a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java b/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
index 1135c07..5c176e6 100644
--- a/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
+++ b/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorSelector.java
@@ -41,6 +41,8 @@ public class DefaultMirrorSelector
 
     private static final String EXTERNAL_WILDCARD = "external:*";
 
+    private static final String EXTERNAL_HTTP_WILDCARD = "external:http:*";
+
     public Mirror getMirror( ArtifactRepository repository, List<Mirror> mirrors )
     {
         String repoId = repository.getId();
@@ -72,6 +74,7 @@ public class DefaultMirrorSelector
      * <ul>
      * <li>{@code *} = everything,</li>
      * <li>{@code external:*} = everything not on the localhost and not file based,</li>
+     * <li>{@code external:http:*} = any repository not on the localhost using HTTP,</li>
      * <li>{@code repo,repo1} = {@code repo} or {@code repo1},</li>
      * <li>{@code *,!repo1} = everything except {@code repo1}.</li>
      * </ul>
@@ -119,6 +122,12 @@ public class DefaultMirrorSelector
                     result = true;
                     // don't stop processing in case a future segment explicitly excludes this repo
                 }
+                // check for external:http:*
+                else if ( EXTERNAL_HTTP_WILDCARD.equals( repo ) && isExternalHttpRepo( originalRepository ) )
+                {
+                    result = true;
+                    // don't stop processing in case a future segment explicitly excludes this repo
+                }
                 else if ( WILDCARD.equals( repo ) )
                 {
                     result = true;
@@ -140,8 +149,34 @@ public class DefaultMirrorSelector
         try
         {
             URL url = new URL( originalRepository.getUrl() );
-            return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" )
-                            || url.getProtocol().equals( "file" ) );
+            return !( isLocal( url.getHost() ) || url.getProtocol().equals( "file" ) );
+        }
+        catch ( MalformedURLException e )
+        {
+            // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it
+            return false;
+        }
+    }
+
+    private static boolean isLocal( String host )
+    {
+        return "localhost".equals( host ) || "127.0.0.1".equals( host );
+    }
+
+    /**
+     * Checks the URL to see if this repository refers to a non-localhost repository using HTTP.
+     *
+     * @param originalRepository
+     * @return true if external.
+     */
+    static boolean isExternalHttpRepo( ArtifactRepository originalRepository )
+    {
+        try
+        {
+            URL url = new URL( originalRepository.getUrl() );
+            return ( "http".equalsIgnoreCase( url.getProtocol() ) || "dav".equalsIgnoreCase( url.getProtocol() )
+                || "dav:http".equalsIgnoreCase( url.getProtocol() )
+                || "dav+http".equalsIgnoreCase( url.getProtocol() ) ) && !isLocal( url.getHost() );
         }
         catch ( MalformedURLException e )
         {
@@ -150,7 +185,7 @@ public class DefaultMirrorSelector
         }
     }
 
-    static boolean matchesLayout( ArtifactRepository repository, Mirror mirror )
+   static boolean matchesLayout( ArtifactRepository repository, Mirror mirror )
     {
         return matchesLayout( RepositoryUtils.getLayout( repository ), mirror.getMirrorOfLayouts() );
     }
diff --git a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
index b37a0ec..e37db04 100644
--- a/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
+++ b/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java
@@ -713,6 +713,8 @@ public class MavenRepositorySystem
 
     private static final String EXTERNAL_WILDCARD = "external:*";
 
+    private static final String EXTERNAL_HTTP_WILDCARD = "external:http:*";
+
     public static Mirror getMirror( ArtifactRepository repository, List<Mirror> mirrors )
     {
         String repoId = repository.getId();
@@ -744,6 +746,7 @@ public class MavenRepositorySystem
      * <ul>
      * <li>{@code *} = everything,</li>
      * <li>{@code external:*} = everything not on the localhost and not file based,</li>
+     * <li>{@code external:http:*} = any repository not on the localhost using HTTP,</li>
      * <li>{@code repo,repo1} = {@code repo} or {@code repo1},</li>
      * <li>{@code *,!repo1} = everything except {@code repo1}.</li>
      * </ul>
@@ -790,6 +793,12 @@ public class MavenRepositorySystem
                     result = true;
                     // don't stop processing in case a future segment explicitly excludes this repo
                 }
+                // check for external:http:*
+                else if ( EXTERNAL_HTTP_WILDCARD.equals( repo ) && isExternalHttpRepo( originalRepository ) )
+                {
+                    result = true;
+                    // don't stop processing in case a future segment explicitly excludes this repo
+                }
                 else if ( WILDCARD.equals( repo ) )
                 {
                     result = true;
@@ -811,8 +820,34 @@ public class MavenRepositorySystem
         try
         {
             URL url = new URL( originalRepository.getUrl() );
-            return !( url.getHost().equals( "localhost" ) || url.getHost().equals( "127.0.0.1" )
-                            || url.getProtocol().equals( "file" ) );
+            return !( isLocal( url.getHost() ) || url.getProtocol().equals( "file" ) );
+        }
+        catch ( MalformedURLException e )
+        {
+            // bad url just skip it here. It should have been validated already, but the wagon lookup will deal with it
+            return false;
+        }
+    }
+
+    private static boolean isLocal( String host )
+    {
+        return "localhost".equals( host ) || "127.0.0.1".equals( host );
+    }
+
+    /**
+     * Checks the URL to see if this repository refers to a non-localhost repository using HTTP.
+     *
+     * @param originalRepository
+     * @return true if external.
+     */
+    static boolean isExternalHttpRepo( ArtifactRepository originalRepository )
+    {
+        try
+        {
+            URL url = new URL( originalRepository.getUrl() );
+            return ( "http".equalsIgnoreCase( url.getProtocol() ) || "dav".equalsIgnoreCase( url.getProtocol() )
+                || "dav:http".equalsIgnoreCase( url.getProtocol() )
+                || "dav+http".equalsIgnoreCase( url.getProtocol() ) ) && !isLocal( url.getHost() );
         }
         catch ( MalformedURLException e )
         {


[maven] 03/04: [MNG-7117] add support for blocked mirror

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MNG-7118
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 591e9f19fac81c028b70ad0cdb40a4bd8cfd5efd
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Mar 13 18:00:59 2021 +0100

    [MNG-7117] add support for blocked mirror
---
 .../aether/DefaultRepositorySystemSessionFactory.java       |  4 ++--
 maven-settings/pom.xml                                      |  2 +-
 maven-settings/src/main/mdo/settings.mdo                    | 13 +++++++++++++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
index 86cb551..bbefc61 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
@@ -188,8 +188,8 @@ public class DefaultRepositorySystemSessionFactory
         DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
         for ( Mirror mirror : request.getMirrors() )
         {
-            mirrorSelector.add( mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
-                                mirror.getMirrorOfLayouts() );
+            mirrorSelector.add( mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.isBlocked(),
+                                mirror.getMirrorOf(), mirror.getMirrorOfLayouts() );
         }
         session.setMirrorSelector( mirrorSelector );
 
diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml
index 83288e5..4405e5c 100644
--- a/maven-settings/pom.xml
+++ b/maven-settings/pom.xml
@@ -46,7 +46,7 @@ under the License.
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
         <configuration>
-          <version>1.1.0</version>
+          <version>1.2.0</version>
           <models>
             <model>src/main/mdo/settings.mdo</model>
           </models>
diff --git a/maven-settings/src/main/mdo/settings.mdo b/maven-settings/src/main/mdo/settings.mdo
index 333d8bd..003abe6 100644
--- a/maven-settings/src/main/mdo/settings.mdo
+++ b/maven-settings/src/main/mdo/settings.mdo
@@ -633,6 +633,15 @@
             of the mirror to repositories with a matching layout (apart from a matching id). Since Maven 3.
           </description>
         </field>
+        <field>
+          <name>blocked</name>
+          <version>1.2.0+</version>
+          <type>boolean</type>
+          <defaultValue>false</defaultValue>
+          <description>
+            Whether this mirror should block any download request and fail the download process, explaining why.
+          </description>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>
@@ -648,6 +657,10 @@
         sb.append( ",mirrorOf=" ).append( mirrorOf );
         sb.append( ",url=" ).append( this.url );
         sb.append( ",name=" ).append( this.name );
+        if ( isBlocked() )
+        {
+            sb.append( ",blocked" );
+        }
         sb.append( "]" );
         return sb.toString();
     }


[maven] 01/04: use Maven Resolver 1.6.2-SNAPSHOT

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MNG-7118
in repository https://gitbox.apache.org/repos/asf/maven.git

commit aad23f520bcc198275e19e67bb4e7f9a2211c790
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sun Mar 14 20:52:42 2021 +0100

    use Maven Resolver 1.6.2-SNAPSHOT
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 655557b..7b32565 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,7 @@ under the License.
     <cipherVersion>1.8</cipherVersion>
     <modelloVersion>1.11</modelloVersion>
     <jxpathVersion>1.3</jxpathVersion>
-    <resolverVersion>1.6.1</resolverVersion>
+    <resolverVersion>1.6.2-SNAPSHOT</resolverVersion>
     <slf4jVersion>1.7.30</slf4jVersion>
     <xmlunitVersion>2.6.4</xmlunitVersion>
     <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>