You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2016/05/27 11:11:55 UTC

[1/4] maven-scm git commit: #resolves SCM-811 by masking command output in ScmResult class used by all SCM operations

Repository: maven-scm
Updated Branches:
  refs/heads/master 860a2eeae -> 1fd6136ed


#resolves SCM-811 by masking command output in ScmResult class used by all SCM operations


Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/8785b85e
Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/8785b85e
Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/8785b85e

Branch: refs/heads/master
Commit: 8785b85e0d6273f88e7bd173c5d59d0e2c1148c2
Parents: 5c303e4
Author: EDWARD WEBB <ED...@LibertyMutual.com>
Authored: Sat Feb 6 09:58:36 2016 -0500
Committer: EDWARD WEBB <ED...@LibertyMutual.com>
Committed: Sat Feb 6 09:58:36 2016 -0500

----------------------------------------------------------------------
 .../java/org/apache/maven/scm/ScmResult.java    | 30 ++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-scm/blob/8785b85e/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
----------------------------------------------------------------------
diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
index 61c77d4..ace98d9 100644
--- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
+++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
@@ -20,6 +20,8 @@ package org.apache.maven.scm;
  */
 
 import java.io.Serializable;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -38,6 +40,12 @@ public class ScmResult
 
     private final String commandLine;
 
+
+    public static final String PASSWORD_PLACE_HOLDER = "********";
+
+    //works for SVN and git
+    private Pattern patternForUserColonPasswordAtHost = Pattern.compile( "^.*:(.*)@.*$" );
+
     /**
      * Copy constructor.
      * <p/>
@@ -52,11 +60,12 @@ public class ScmResult
 
         this.providerMessage = scmResult.providerMessage;
 
-        this.commandOutput = scmResult.commandOutput;
+        this.commandOutput = masked( scmResult.commandOutput );
 
         this.success = scmResult.success;
     }
 
+
     /**
      * ScmResult contructor.
      *
@@ -71,7 +80,7 @@ public class ScmResult
 
         this.providerMessage = providerMessage;
 
-        this.commandOutput = commandOutput;
+        this.commandOutput = masked( commandOutput );
 
         this.success = success;
     }
@@ -109,4 +118,21 @@ public class ScmResult
     {
         return commandLine;
     }
+
+
+    private String masked( String commandOutput )
+    {
+        if ( null != commandOutput )
+        {
+            final Matcher passwordMatcher = patternForUserColonPasswordAtHost.matcher( commandOutput );
+            if ( passwordMatcher.find() )
+            {
+                // clear password
+                final String clearPassword = passwordMatcher.group( 1 );
+                // to be replaced in output by stars
+                commandOutput = commandOutput.replace( clearPassword, PASSWORD_PLACE_HOLDER );
+            }
+        }
+        return commandOutput;
+    }
 }


[2/4] maven-scm git commit: Simple test for SCM-811 ensures ouptut is masked

Posted by ol...@apache.org.
Simple test for SCM-811 ensures ouptut is masked


Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/9d009e8f
Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/9d009e8f
Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/9d009e8f

Branch: refs/heads/master
Commit: 9d009e8f14c0dff99c377b8991bdd59b519f0d33
Parents: 8785b85
Author: EDWARD WEBB <ED...@LibertyMutual.com>
Authored: Sat Feb 6 10:15:41 2016 -0500
Committer: EDWARD WEBB <ED...@LibertyMutual.com>
Committed: Sat Feb 6 10:15:41 2016 -0500

----------------------------------------------------------------------
 .../org/apache/maven/scm/ScmResultTest.java     | 47 ++++++++++++++++++++
 1 file changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-scm/blob/9d009e8f/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
----------------------------------------------------------------------
diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
new file mode 100644
index 0000000..d27fc62
--- /dev/null
+++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
@@ -0,0 +1,47 @@
+package org.apache.maven.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.scm.provider.ScmUrlUtils;
+
+/**
+ * @author <a href="mailto:dennisl@apache.org">Dennis Lundberg</a>
+ *
+ */
+public class ScmResultTest
+    extends TestCase
+{
+
+    private static final String PASSWORD = "secr$t";
+
+    private static final String SCM_URL_GIT_COLON = "scm:git:https://username:" + PASSWORD + "@github.com/username/repo.git";
+
+    private static final String MOCK_ERROR_OUTPUT = "fatal repository " + SCM_URL_GIT_COLON + "does not exist";
+
+    public void testPasswordsAreMaskedInOutput()
+        throws Exception
+    {
+        ScmResult result = new ScmResult( "git push", "git-push failed", MOCK_ERROR_OUTPUT, false );
+        assertNotSame( "Command Output contains password", MOCK_ERROR_OUTPUT, result.getCommandOutput() );
+        assertTrue( "Command Output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER ) );
+    }
+
+}


[3/4] maven-scm git commit: Removed invalid author tag from new test class

Posted by ol...@apache.org.
Removed invalid author tag from new test class


Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/59cd5d3b
Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/59cd5d3b
Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/59cd5d3b

Branch: refs/heads/master
Commit: 59cd5d3bde42d4b877e1721d72e22b1bdae96dde
Parents: 9d009e8
Author: EDWARD WEBB <ED...@LibertyMutual.com>
Authored: Fri May 27 06:47:21 2016 -0400
Committer: EDWARD WEBB <ED...@LibertyMutual.com>
Committed: Fri May 27 06:47:21 2016 -0400

----------------------------------------------------------------------
 .../src/test/java/org/apache/maven/scm/ScmResultTest.java        | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-scm/blob/59cd5d3b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
----------------------------------------------------------------------
diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
index d27fc62..7db262e 100644
--- a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
+++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
@@ -22,10 +22,6 @@ package org.apache.maven.scm;
 import junit.framework.TestCase;
 import org.apache.maven.scm.provider.ScmUrlUtils;
 
-/**
- * @author <a href="mailto:dennisl@apache.org">Dennis Lundberg</a>
- *
- */
 public class ScmResultTest
     extends TestCase
 {


[4/4] maven-scm git commit: Merge branch 'SCM-811' to master

Posted by ol...@apache.org.
Merge branch 'SCM-811' to master


Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/1fd6136e
Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/1fd6136e
Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/1fd6136e

Branch: refs/heads/master
Commit: 1fd6136ed3cce4b633d08227482f387d1669465b
Parents: 860a2ee 59cd5d3
Author: olivier lamy <ol...@apache.org>
Authored: Fri May 27 21:11:01 2016 +1000
Committer: olivier lamy <ol...@apache.org>
Committed: Fri May 27 21:11:01 2016 +1000

----------------------------------------------------------------------
 .../java/org/apache/maven/scm/ScmResult.java    | 30 +++++++++++++-
 .../org/apache/maven/scm/ScmResultTest.java     | 43 ++++++++++++++++++++
 2 files changed, 71 insertions(+), 2 deletions(-)
----------------------------------------------------------------------