You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/02/15 06:24:09 UTC
[camel] branch camel-2.23.x updated: CAMEL-13191: Fix Regex Pattern
to hide passwords in URI
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch camel-2.23.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.23.x by this push:
new 704db0a CAMEL-13191: Fix Regex Pattern to hide passwords in URI
704db0a is described below
commit 704db0a75ee5357c9ebebe8e2696cd47b95be145
Author: Christian Pieczewski <ch...@gmail.com>
AuthorDate: Thu Feb 14 13:12:32 2019 +0100
CAMEL-13191: Fix Regex Pattern to hide passwords in URI
Backport from 3.x to 2.23.x
Conflicts:
camel-core/src/main/java/org/apache/camel/util/URISupport.java
---
.../src/main/java/org/apache/camel/util/URISupport.java | 4 ++--
.../test/java/org/apache/camel/util/URISupportTest.java | 14 ++++++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/camel-core/src/main/java/org/apache/camel/util/URISupport.java b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
index 1b13164..c7ecd71 100644
--- a/camel-core/src/main/java/org/apache/camel/util/URISupport.java
+++ b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
@@ -46,11 +46,11 @@ public final class URISupport {
// Match the user password in the URI as second capture group
// (applies to URI with authority component and userinfo token in the form "user:password").
- private static final Pattern USERINFO_PASSWORD = Pattern.compile("(.*://.*:)(.*)(@)");
+ private static final Pattern USERINFO_PASSWORD = Pattern.compile("(.*://.*?:)(.*)(@)");
// Match the user password in the URI path as second capture group
// (applies to URI path with authority component and userinfo token in the form "user:password").
- private static final Pattern PATH_USERINFO_PASSWORD = Pattern.compile("(.*:)(.*)(@)");
+ private static final Pattern PATH_USERINFO_PASSWORD = Pattern.compile("(.*?:)(.*)(@)");
private static final String CHARSET = "UTF-8";
diff --git a/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java b/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
index 11bf67f..74bf603 100644
--- a/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
@@ -240,6 +240,13 @@ public class URISupportTest extends ContextTestSupport {
String expected = "jt400://GEORGE:xxxxxx@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.DTAQ";
assertEquals(expected, URISupport.sanitizeUri(uri));
}
+
+ @Test
+ public void testSanitizeUriWithUserInfoAndColonPassword() {
+ String uri = "sftp://USERNAME:HARRISON:COLON@sftp.server.test";
+ String expected = "sftp://USERNAME:xxxxxx@sftp.server.test";
+ assertEquals(expected, URISupport.sanitizeUri(uri));
+ }
@Test
public void testSanitizePathWithUserInfo() {
@@ -247,6 +254,13 @@ public class URISupportTest extends ContextTestSupport {
String expected = "GEORGE:xxxxxx@LIVERPOOL/QSYS.LIB/BEATLES.LIB/PENNYLANE.PGM";
assertEquals(expected, URISupport.sanitizePath(path));
}
+
+ @Test
+ public void testSanitizePathWithUserInfoAndColonPassword() {
+ String path = "USERNAME:HARRISON:COLON@sftp.server.test";
+ String expected = "USERNAME:xxxxxx@sftp.server.test";
+ assertEquals(expected, URISupport.sanitizePath(path));
+ }
@Test
public void testSanitizePathWithoutSensitiveInfoIsUnchanged() {