From 54bc5e0df998eb84c095bc911bdac9922776d170 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:57:17 -0300 Subject: [PATCH 01/32] added tests for new host verification scenarios --- pom.xml | 2 +- src/test/docker/tls/Dockerfile | 4 ++-- src/test/munit/activemq-over-ssl-test-case.xml | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 1f464a55..a0bc5edf 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ Mule connector lets you easily send and receive messages to queues and topics for any message service which implements the JMS specification - 5.14.5 + 5.15.16 2.25.0 2.0.1 2.11.0 diff --git a/src/test/docker/tls/Dockerfile b/src/test/docker/tls/Dockerfile index 637e1f26..4b305815 100644 --- a/src/test/docker/tls/Dockerfile +++ b/src/test/docker/tls/Dockerfile @@ -1,9 +1,9 @@ FROM openjdk:8-jre -ENV ACTIVEMQ_VERSION 5.15.9 +ENV ACTIVEMQ_VERSION 5.15.16 ENV ACTIVEMQ apache-activemq-$ACTIVEMQ_VERSION ENV ACTIVEMQ_TCP=61616 ACTIVEMQ_AMQP=5672 ACTIVEMQ_STOMP=61613 ACTIVEMQ_MQTT=1883 ACTIVEMQ_WS=61614 ACTIVEMQ_UI=8161 -ENV SHA512_VAL=35cae4258e38e47f9f81e785f547afc457fc331d2177bfc2391277ce24123be1196f10c670b61e30b43b7ab0db0628f3ff33f08660f235b7796d59ba922d444f +ENV SHA512_VAL=5aaa73047b3f80f1a79984fe1a4b84645bd1d31ae2de3b41b774616d8290e5ff9647a0e38fd4a753e472c56efba42025be67561ac9f652442e7b226aa62236af ENV ACTIVEMQ_HOME /opt/activemq ENV ACTIVEMQ_SSL_OPTS=-Djavax.net.ssl.keyStore=/opt/activemq/certs/ActiveMq/broker.ks -Djavax.net.ssl.keyStorePassword=racing diff --git a/src/test/munit/activemq-over-ssl-test-case.xml b/src/test/munit/activemq-over-ssl-test-case.xml index 0d03ec43..6036a801 100644 --- a/src/test/munit/activemq-over-ssl-test-case.xml +++ b/src/test/munit/activemq-over-ssl-test-case.xml @@ -13,7 +13,20 @@ http://www.mulesoft.org/schema/mule/java http://www.mulesoft.org/schema/mule/java/current/mule-java.xsd http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd"> - + + + + + + + + + + + + + + @@ -23,7 +36,7 @@ - + From 14459d4ca27e8e7b171ca215db5f83f0f8046578 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:59:53 -0300 Subject: [PATCH 02/32] some tests --- pom.xml | 2 +- src/test/docker/tls/Dockerfile | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index a0bc5edf..1f464a55 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ Mule connector lets you easily send and receive messages to queues and topics for any message service which implements the JMS specification - 5.15.16 + 5.14.5 2.25.0 2.0.1 2.11.0 diff --git a/src/test/docker/tls/Dockerfile b/src/test/docker/tls/Dockerfile index 4b305815..8f677645 100644 --- a/src/test/docker/tls/Dockerfile +++ b/src/test/docker/tls/Dockerfile @@ -1,10 +1,9 @@ FROM openjdk:8-jre -ENV ACTIVEMQ_VERSION 5.15.16 +ENV ACTIVEMQ_VERSION 5.15.9 ENV ACTIVEMQ apache-activemq-$ACTIVEMQ_VERSION ENV ACTIVEMQ_TCP=61616 ACTIVEMQ_AMQP=5672 ACTIVEMQ_STOMP=61613 ACTIVEMQ_MQTT=1883 ACTIVEMQ_WS=61614 ACTIVEMQ_UI=8161 -ENV SHA512_VAL=5aaa73047b3f80f1a79984fe1a4b84645bd1d31ae2de3b41b774616d8290e5ff9647a0e38fd4a753e472c56efba42025be67561ac9f652442e7b226aa62236af - +ENV SHA512_VAL=35cae4258e38e47f9f81e785f547afc457fc331d2177bfc2391277ce24123be1196f10c670b61e30b43b7ab0db0628f3ff33f08660f235b7796d59ba922d444f ENV ACTIVEMQ_HOME /opt/activemq ENV ACTIVEMQ_SSL_OPTS=-Djavax.net.ssl.keyStore=/opt/activemq/certs/ActiveMq/broker.ks -Djavax.net.ssl.keyStorePassword=racing From 1e160058a670107f36ce9d0f53d791388647bd34 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:47:10 -0300 Subject: [PATCH 03/32] Adding verifyHostName property to the brokerURL --- pom.xml | 2 +- ...ctiveMQConnectionFactoryConfiguration.java | 17 ++++++++ .../ActiveMQConnectionFactoryProvider.java | 39 +++++++++++++++++-- .../munit/activemq-over-ssl-test-case.xml | 2 + 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 1f464a55..a0bc5edf 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ Mule connector lets you easily send and receive messages to queues and topics for any message service which implements the JMS specification - 5.14.5 + 5.15.16 2.25.0 2.0.1 2.11.0 diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 5a55d00c..f5d92309 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -106,6 +106,15 @@ public class ActiveMQConnectionFactoryConfiguration { @ExcludeFromConnectivitySchema private boolean trustAllPackages; + @Parameter + @Optional(defaultValue = "false") + @Summary("Indicates whether an ssl connection socket must verify the broker URL hostname matches the CN value in " + + "the TSL certificate. \n Setting this value to false is unsafe and will be changed to true by default in " + + "the upcoming minor version.") + @Expression(NOT_SUPPORTED) + @ExcludeFromConnectivitySchema + private boolean verifyHostName; + public int getMaxRedelivery() { return maxRedelivery; } @@ -170,6 +179,14 @@ public void setTrustAllPackages(boolean trustAllPackages) { this.trustAllPackages = trustAllPackages; } + public boolean getVerifyHostName() { + return verifyHostName; + } + + public void setVerifyHostName(boolean verifyHostName) { + this.verifyHostName = verifyHostName; + } + @Override public boolean equals(Object o) { if (this == o) diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index 6f74a977..76fab609 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -10,6 +10,7 @@ import static org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED; import static org.mule.runtime.core.api.util.ClassUtils.instantiateClass; +import org.apache.activemq.util.URISupport; import org.mule.extensions.jms.api.connection.factory.activemq.ActiveMQConnectionFactoryConfiguration; import org.mule.extensions.jms.api.exception.JmsMissingLibraryException; import org.mule.extensions.jms.internal.connection.exception.ActiveMQException; @@ -22,7 +23,11 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.jms.ConnectionFactory; @@ -83,9 +88,11 @@ ConnectionFactory createDefaultConnectionFactory(boolean useSsl) throws ActiveMQ if (LOGGER.isDebugEnabled()) { LOGGER.debug(format("Creating new [%s]", factoryClass)); } - - this.connectionFactory = (ConnectionFactory) instantiateClass(factoryClass, factoryConfiguration.getBrokerUrl()); + this.connectionFactory = + (ConnectionFactory) instantiateClass(factoryClass, setPropertiesInURL(factoryConfiguration.getBrokerUrl(), factoryClass, + factoryConfiguration)); applyVendorSpecificConnectionFactoryProperties(connectionFactory); + return connectionFactory; } catch (ClassNotFoundException e) { String message = @@ -112,12 +119,38 @@ private void applyVendorSpecificConnectionFactoryProperties(ConnectionFactory co setRedeliveryDelay(redeliveryPolicy); setTrustedPackages(connectionFactory); setTrustAllPackages(connectionFactory); - } catch (Exception e) { LOGGER.error("Failed to set custom ConnectionFactoryProperties for ActiveMQ RedeliveryPolicy: " + e.getMessage(), e); } } + private String setPropertiesInURL(String brokerURL, String factoryClass, + ActiveMQConnectionFactoryConfiguration factoryConfiguration) + throws URISyntaxException { + if (factoryClass == ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS + || factoryClass == ACTIVEMQ_SSL_CONNECTION_FACTORY_CLASS) { + URI brokerURI = createURI(brokerURL); + Map map; + if (brokerURI.getQuery() != null) { + map = URISupport.parseQuery(brokerURI.getQuery()); + } else { + map = new HashMap<>(); + } + map.put("socket.verifyHostName", String.valueOf(factoryConfiguration.getVerifyHostName())); + brokerURI = URISupport.createRemainingURI(brokerURI, map); + return brokerURI.toString(); + } + return brokerURL; + } + + private static URI createURI(String url) { + try { + return new URI(url); + } catch (URISyntaxException var2) { + throw (IllegalArgumentException) (new IllegalArgumentException("Invalid broker URI: " + url)).initCause(var2); + } + } + private void setMaximumRedeliveries(Object redeliveryPolicy) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Method setMaximumRedeliveriesMethod = redeliveryPolicy.getClass().getMethod("setMaximumRedeliveries", Integer.TYPE); diff --git a/src/test/munit/activemq-over-ssl-test-case.xml b/src/test/munit/activemq-over-ssl-test-case.xml index 6036a801..f4970a84 100644 --- a/src/test/munit/activemq-over-ssl-test-case.xml +++ b/src/test/munit/activemq-over-ssl-test-case.xml @@ -17,11 +17,13 @@ + + From 495f0e5f53d8339586c772649e2a883ba08cf382 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:29:28 -0300 Subject: [PATCH 04/32] created default value to fix vulnerability --- .../ActiveMQConnectionFactoryConfiguration.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index f5d92309..5f3d1b00 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -106,14 +106,6 @@ public class ActiveMQConnectionFactoryConfiguration { @ExcludeFromConnectivitySchema private boolean trustAllPackages; - @Parameter - @Optional(defaultValue = "false") - @Summary("Indicates whether an ssl connection socket must verify the broker URL hostname matches the CN value in " + - "the TSL certificate. \n Setting this value to false is unsafe and will be changed to true by default in " + - "the upcoming minor version.") - @Expression(NOT_SUPPORTED) - @ExcludeFromConnectivitySchema - private boolean verifyHostName; public int getMaxRedelivery() { return maxRedelivery; @@ -180,12 +172,11 @@ public void setTrustAllPackages(boolean trustAllPackages) { } public boolean getVerifyHostName() { - return verifyHostName; + //TODO: change the default value to a parameter. This default is required to support a security fix and avoid + // breaking backwards compatibility (GUS ticket: W-14487260) + return false; } - public void setVerifyHostName(boolean verifyHostName) { - this.verifyHostName = verifyHostName; - } @Override public boolean equals(Object o) { From 16d3d80c342eef1e543d95fdba531b1afd1c4b25 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:08:23 -0300 Subject: [PATCH 05/32] refactored code --- .../ActiveMQConnectionFactoryProvider.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index 76fab609..0887d751 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -52,8 +52,10 @@ public class ActiveMQConnectionFactoryProvider { private static final String ACTIVEMQ_SSL_CONNECTION_FACTORY_CLASS = "org.apache.activemq.ActiveMQSslConnectionFactory"; private static final String ACTIVEMQ_XA_CONNECTION_FACTORY_CLASS = "org.apache.activemq.ActiveMQXAConnectionFactory"; private static final String ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS = "org.apache.activemq.ActiveMQXASslConnectionFactory"; + private static final int REDELIVERY_IGNORE = -1; + private static final String VERIFY_HOSTNAME="socket.verifyHostName"; /** * Parameters required to configure a default {@link ActiveMQConnectionFactory} */ @@ -127,27 +129,26 @@ private void applyVendorSpecificConnectionFactoryProperties(ConnectionFactory co private String setPropertiesInURL(String brokerURL, String factoryClass, ActiveMQConnectionFactoryConfiguration factoryConfiguration) throws URISyntaxException { - if (factoryClass == ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS - || factoryClass == ACTIVEMQ_SSL_CONNECTION_FACTORY_CLASS) { + if (isSslFactoryClass(factoryClass)) { URI brokerURI = createURI(brokerURL); - Map map; - if (brokerURI.getQuery() != null) { - map = URISupport.parseQuery(brokerURI.getQuery()); - } else { - map = new HashMap<>(); - } - map.put("socket.verifyHostName", String.valueOf(factoryConfiguration.getVerifyHostName())); + Map map = (brokerURI.getQuery() != null) ? URISupport.parseQuery(brokerURI.getQuery()) : new HashMap<>(); + map.put(VERIFY_HOSTNAME, String.valueOf(factoryConfiguration.getVerifyHostName())); brokerURI = URISupport.createRemainingURI(brokerURI, map); return brokerURI.toString(); } return brokerURL; } + private boolean isSslFactoryClass(String factoryClass) { + return factoryClass == ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS + || factoryClass == ACTIVEMQ_SSL_CONNECTION_FACTORY_CLASS; + } + private static URI createURI(String url) { try { return new URI(url); - } catch (URISyntaxException var2) { - throw (IllegalArgumentException) (new IllegalArgumentException("Invalid broker URI: " + url)).initCause(var2); + } catch (URISyntaxException e) { + throw new RuntimeException("Invalid broker URI: " + url, e); } } From 4ee3b6020460e1f6bf6c41c4f092bf24cc44116a Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:25:56 -0300 Subject: [PATCH 06/32] applied format --- .../provider/activemq/ActiveMQConnectionFactoryProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index 0887d751..b6d82463 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -55,7 +55,7 @@ public class ActiveMQConnectionFactoryProvider { private static final int REDELIVERY_IGNORE = -1; - private static final String VERIFY_HOSTNAME="socket.verifyHostName"; + private static final String VERIFY_HOSTNAME = "socket.verifyHostName"; /** * Parameters required to configure a default {@link ActiveMQConnectionFactory} */ @@ -141,7 +141,7 @@ private String setPropertiesInURL(String brokerURL, String factoryClass, private boolean isSslFactoryClass(String factoryClass) { return factoryClass == ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS - || factoryClass == ACTIVEMQ_SSL_CONNECTION_FACTORY_CLASS; + || factoryClass == ACTIVEMQ_SSL_CONNECTION_FACTORY_CLASS; } private static URI createURI(String url) { From b3b360ac77c506e0f8e89fb66047916add36e1d4 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:28:41 -0300 Subject: [PATCH 07/32] removed duplicate mule sdk version --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index a0bc5edf..6de23da6 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,6 @@ formatter.xml 1.14.0-SNAPSHOT - 0.3.0 1.7.3 From cd7234f0147ad177e8195da631ab80a0a328d0a0 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:35:20 -0300 Subject: [PATCH 08/32] forced spring core library to let activeMq client version work as expected --- pom.xml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6de23da6..ec0f16b8 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,11 @@ mule-jms-client ${muleJmsClientVersion} + + org.springframework + spring-core + 4.3.8.RELEASE + commons-io commons-io @@ -93,7 +98,7 @@ org.apache.activemq - activemq-client + activemq-all ${activemq.version} provided @@ -112,7 +117,7 @@ org.apache.activemq - activemq-all + activemq-client ${activemq.version} test @@ -159,6 +164,12 @@ ${muleSpringModuleVersion} mule-plugin test + + + org.springframework + spring-core + + org.mule.tests From 058025c2b368f28507f7e8e7ef4fc4e5bd1d53a2 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:45:08 -0300 Subject: [PATCH 09/32] removed explicit spring version --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index ec0f16b8..f7507cc7 100644 --- a/pom.xml +++ b/pom.xml @@ -67,11 +67,11 @@ mule-jms-client ${muleJmsClientVersion} - - org.springframework - spring-core - 4.3.8.RELEASE - + + + + + commons-io commons-io From 974b3e621da6bd73669a222ddb3d1eb7755c6a36 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Sun, 26 Nov 2023 12:35:33 -0300 Subject: [PATCH 10/32] forced dependencies --- pom.xml | 25 ++++++++++++++----- ...ctiveMQConnectionFactoryConfiguration.java | 18 ++++++++++--- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index f7507cc7..84d2d167 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ Mule connector lets you easily send and receive messages to queues and topics for any message service which implements the JMS specification - 5.15.16 + 5.16.4 2.25.0 2.0.1 2.11.0 @@ -66,12 +66,19 @@ org.mule.connectors mule-jms-client ${muleJmsClientVersion} + + + org.springframework + spring-jms + + + + + org.springframework + spring-core + 5.3.31 + test - - - - - commons-io commons-io @@ -94,6 +101,12 @@ ${javaxJmsApiVersion} provided + + org.springframework + spring-jms + 5.3.31 + test + diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 5f3d1b00..248857d6 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -106,6 +106,14 @@ public class ActiveMQConnectionFactoryConfiguration { @ExcludeFromConnectivitySchema private boolean trustAllPackages; + @Parameter + @Optional(defaultValue = "false") + @Summary("Indicates whether an ssl connection socket must verify the broker URL hostname matches the CN value in " + + "the TSL certificate. \n We recommend setting this value to true.") + @Expression(NOT_SUPPORTED) + @ExcludeFromConnectivitySchema + private boolean verifyHostName; + public int getMaxRedelivery() { return maxRedelivery; @@ -172,11 +180,12 @@ public void setTrustAllPackages(boolean trustAllPackages) { } public boolean getVerifyHostName() { - //TODO: change the default value to a parameter. This default is required to support a security fix and avoid - // breaking backwards compatibility (GUS ticket: W-14487260) - return false; + return verifyHostName; } + public void setVerifyHostName(boolean verifyHostName) { + this.verifyHostName = verifyHostName; + } @Override public boolean equals(Object o) { @@ -190,6 +199,7 @@ public boolean equals(Object o) { redeliveryDelay == that.redeliveryDelay && maxRedelivery == that.maxRedelivery && trustAllPackages == that.trustAllPackages && + verifyHostName == that.verifyHostName && Objects.equals(brokerUrl, that.brokerUrl) && Objects.equals(trustedPackages, that.trustedPackages); } @@ -197,6 +207,6 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash(brokerUrl, enableXA, initialRedeliveryDelay, redeliveryDelay, maxRedelivery, trustedPackages, - trustAllPackages); + trustAllPackages, verifyHostName); } } From 9832400d1b81e88eb2b4d825de2061412d4e2992 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Mon, 27 Nov 2023 09:17:02 -0300 Subject: [PATCH 11/32] added new spring core and spring jms versions --- pom.xml | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 84d2d167..a9d20c29 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,8 @@ 1.11 1.1 1.3.7 + 5.3.31 + 5.3.31 formatter.xml 1.14.0-SNAPSHOT @@ -66,18 +68,6 @@ org.mule.connectors mule-jms-client ${muleJmsClientVersion} - - - org.springframework - spring-jms - - - - - org.springframework - spring-core - 5.3.31 - test commons-io @@ -101,12 +91,6 @@ ${javaxJmsApiVersion} provided - - org.springframework - spring-jms - 5.3.31 - test - @@ -164,6 +148,18 @@ ${artemisVersion} test + + org.springframework + spring-core + ${spring.core.version} + test + + + org.springframework + spring-jms + ${spring.jms.version} + test + org.mule.tests.plugin mule-tests-component-plugin From dc854219171884fca28011529bea784e3637ebdf Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:51:57 -0300 Subject: [PATCH 12/32] restored proper order of dependencies --- pom.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index a9d20c29..a2af5d4b 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.apache.activemq - activemq-all + activemq-client ${activemq.version} provided @@ -114,7 +114,7 @@ org.apache.activemq - activemq-client + activemq-all ${activemq.version} test @@ -152,13 +152,11 @@ org.springframework spring-core ${spring.core.version} - test org.springframework spring-jms ${spring.jms.version} - test org.mule.tests.plugin From 7c5cee31eb0f7aa65bab912f7a50bdab52640520 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Tue, 28 Nov 2023 19:18:36 -0300 Subject: [PATCH 13/32] W-14487260 set xaAckMode --- pom.xml | 25 ++++++++----------- ...ctiveMQConnectionFactoryConfiguration.java | 15 +++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index a2af5d4b..fc41b4b6 100644 --- a/pom.xml +++ b/pom.xml @@ -31,12 +31,12 @@ 1.11 1.1 1.3.7 - 5.3.31 - 5.3.31 formatter.xml 1.14.0-SNAPSHOT 1.7.3 + + 4.3.30.RELEASE src/test/munit @@ -48,7 +48,7 @@ 0.41.0 3.3.0 ${skipTests} - + 1.0.0-SNAPSHOT 1.0.0-SNAPSHOT @@ -148,15 +148,16 @@ ${artemisVersion} test + + + + + org.springframework spring-core ${spring.core.version} - - - org.springframework - spring-jms - ${spring.jms.version} + provided org.mule.tests.plugin @@ -171,12 +172,6 @@ ${muleSpringModuleVersion} mule-plugin test - - - org.springframework - spring-core - - org.mule.tests @@ -573,4 +568,4 @@ https://repository.mulesoft.org/nexus/content/repositories/public/ - + \ No newline at end of file diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 248857d6..b43f17bb 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -114,6 +114,13 @@ public class ActiveMQConnectionFactoryConfiguration { @ExcludeFromConnectivitySchema private boolean verifyHostName; + @Parameter + @Optional(defaultValue = "1") + @Summary(" ") + @Expression(NOT_SUPPORTED) + @ExcludeFromConnectivitySchema + private int xaAckMode; + public int getMaxRedelivery() { return maxRedelivery; @@ -187,6 +194,14 @@ public void setVerifyHostName(boolean verifyHostName) { this.verifyHostName = verifyHostName; } + public int getXaAckMode() { + return xaAckMode; + } + + public void setXaAckMode(int xaAckMode) { + this.xaAckMode = xaAckMode; + } + @Override public boolean equals(Object o) { if (this == o) From 37d24bf748256d16543ccf0b1967e52bb90413ff Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Tue, 28 Nov 2023 19:19:44 -0300 Subject: [PATCH 14/32] W-14487260 set xaAckMode --- .../ActiveMQConnectionFactoryProvider.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index b6d82463..ddae81ea 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -94,7 +94,7 @@ ConnectionFactory createDefaultConnectionFactory(boolean useSsl) throws ActiveMQ (ConnectionFactory) instantiateClass(factoryClass, setPropertiesInURL(factoryConfiguration.getBrokerUrl(), factoryClass, factoryConfiguration)); applyVendorSpecificConnectionFactoryProperties(connectionFactory); - + setXAAckMode(factoryClass, connectionFactory, factoryConfiguration.getXaAckMode()); return connectionFactory; } catch (ClassNotFoundException e) { String message = @@ -126,6 +126,18 @@ private void applyVendorSpecificConnectionFactoryProperties(ConnectionFactory co } } + private void setXAAckMode(String factoryClass, + ConnectionFactory factory, + int xaAckMode) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException { + if (factoryClass == ACTIVEMQ_XA_CONNECTION_FACTORY_CLASS || + factoryClass == ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS) { + Class[] parameters = new Class[1]; + parameters[0] = int.class; + factory.getClass().getMethod("setXaAckMode", parameters).invoke(factory, xaAckMode); + } + } + private String setPropertiesInURL(String brokerURL, String factoryClass, ActiveMQConnectionFactoryConfiguration factoryConfiguration) throws URISyntaxException { From 17f1d4c8384c06a9b9581eca75227a7b10126a37 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:42:13 -0300 Subject: [PATCH 15/32] removed spring-jms dependency --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index fc41b4b6..8caf2f48 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,6 @@ formatter.xml 1.14.0-SNAPSHOT 1.7.3 - 4.3.30.RELEASE @@ -148,11 +147,6 @@ ${artemisVersion} test - - - - - org.springframework spring-core From 3b34bcff84b200f21a3a64d7435c4385a6b519b4 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:00:58 -0300 Subject: [PATCH 16/32] Added XA ack mode enum --- .../extensions/jms/api/ack/XaAckMode.java | 35 +++++++++++++++++++ ...ctiveMQConnectionFactoryConfiguration.java | 33 ++++++++++++----- .../ActiveMQConnectionFactoryProvider.java | 17 +++++---- 3 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 src/main/java/org/mule/extensions/jms/api/ack/XaAckMode.java diff --git a/src/main/java/org/mule/extensions/jms/api/ack/XaAckMode.java b/src/main/java/org/mule/extensions/jms/api/ack/XaAckMode.java new file mode 100644 index 00000000..22a9defc --- /dev/null +++ b/src/main/java/org/mule/extensions/jms/api/ack/XaAckMode.java @@ -0,0 +1,35 @@ +/* + * Copyright 2023 Salesforce, Inc. All rights reserved. + * The software in this package is published under the terms of the CPAL v1.0 + * license, a copy of which has been included with this distribution in the + * LICENSE.txt file. + */ +package org.mule.extensions.jms.api.ack; + +import org.mule.jms.commons.internal.config.InternalAckMode; + +import javax.jms.Session; + +import static org.mule.runtime.extension.api.values.ValueBuilder.newValue; + +import java.util.Set; + +public enum XaAckMode { + + SESSION_TRANSACTED(Session.SESSION_TRANSACTED), AUTO_ACKNOWLEDGE(Session.AUTO_ACKNOWLEDGE), CLIENT_ACKNOWLEDGE( + Session.CLIENT_ACKNOWLEDGE), DUPS_OK_ACKNOWLEDGE(Session.DUPS_OK_ACKNOWLEDGE); + + private int ackMode; + + XaAckMode(int ackMode) { + this.ackMode = ackMode; + } + + public int getAckMode() { + return ackMode; + } + + public void setAckMode(int ackMode) { + this.ackMode = ackMode; + } +} diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index b43f17bb..dbe0149e 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -7,12 +7,16 @@ package org.mule.extensions.jms.api.connection.factory.activemq; import static org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED; + +import org.mule.extensions.jms.api.ack.XaAckMode; import org.mule.runtime.extension.api.annotation.Alias; import org.mule.runtime.extension.api.annotation.Expression; import org.mule.runtime.extension.api.annotation.param.Optional; import org.mule.runtime.extension.api.annotation.param.Parameter; +import org.mule.runtime.extension.api.annotation.param.display.DisplayName; import org.mule.runtime.extension.api.annotation.param.display.Example; import org.mule.runtime.extension.api.annotation.param.display.Summary; +import org.mule.runtime.extension.api.annotation.values.OfValues; import org.mule.sdk.api.annotation.semantics.connectivity.ExcludeFromConnectivitySchema; import org.mule.sdk.api.annotation.semantics.connectivity.Url; @@ -52,6 +56,17 @@ public class ActiveMQConnectionFactoryConfiguration { @Expression(NOT_SUPPORTED) private boolean enableXA; + /** + * + */ + @DisplayName("XA ack mode") + @Parameter + @Optional(defaultValue = "AUTO_ACKNOWLEDGE") + @Summary(" ") + @Expression(NOT_SUPPORTED) + @ExcludeFromConnectivitySchema + private XaAckMode xaAckMode; + /** * Used to configure the {@link RedeliveryPolicy#getInitialRedeliveryDelay()} */ @@ -106,20 +121,20 @@ public class ActiveMQConnectionFactoryConfiguration { @ExcludeFromConnectivitySchema private boolean trustAllPackages; + /** + * Indicates whether an SSL connection socket must verify the broker URL hostname matches the CN value in the + * TSL certificate. + * Starting with version 5.15.6 ActiveMQ requires you to explicitly set this value. + */ @Parameter @Optional(defaultValue = "false") - @Summary("Indicates whether an ssl connection socket must verify the broker URL hostname matches the CN value in " + + @Summary("Indicates whether an SSL connection socket must verify the broker URL hostname matches the CN value in " + "the TSL certificate. \n We recommend setting this value to true.") @Expression(NOT_SUPPORTED) @ExcludeFromConnectivitySchema + @DisplayName("Verify hostname") private boolean verifyHostName; - @Parameter - @Optional(defaultValue = "1") - @Summary(" ") - @Expression(NOT_SUPPORTED) - @ExcludeFromConnectivitySchema - private int xaAckMode; public int getMaxRedelivery() { @@ -194,11 +209,11 @@ public void setVerifyHostName(boolean verifyHostName) { this.verifyHostName = verifyHostName; } - public int getXaAckMode() { + public XaAckMode getXaAckMode() { return xaAckMode; } - public void setXaAckMode(int xaAckMode) { + public void setXaAckMode(XaAckMode xaAckMode) { this.xaAckMode = xaAckMode; } diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index ddae81ea..7b58d281 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -8,6 +8,7 @@ import static java.lang.String.format; import static org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED; +import static org.mule.runtime.core.api.util.ClassUtils.findImplementedInterfaces; import static org.mule.runtime.core.api.util.ClassUtils.instantiateClass; import org.apache.activemq.util.URISupport; @@ -94,7 +95,6 @@ ConnectionFactory createDefaultConnectionFactory(boolean useSsl) throws ActiveMQ (ConnectionFactory) instantiateClass(factoryClass, setPropertiesInURL(factoryConfiguration.getBrokerUrl(), factoryClass, factoryConfiguration)); applyVendorSpecificConnectionFactoryProperties(connectionFactory); - setXAAckMode(factoryClass, connectionFactory, factoryConfiguration.getXaAckMode()); return connectionFactory; } catch (ClassNotFoundException e) { String message = @@ -121,23 +121,28 @@ private void applyVendorSpecificConnectionFactoryProperties(ConnectionFactory co setRedeliveryDelay(redeliveryPolicy); setTrustedPackages(connectionFactory); setTrustAllPackages(connectionFactory); + setXAAckMode(connectionFactory, factoryConfiguration.getXaAckMode().getAckMode()); } catch (Exception e) { LOGGER.error("Failed to set custom ConnectionFactoryProperties for ActiveMQ RedeliveryPolicy: " + e.getMessage(), e); } } - private void setXAAckMode(String factoryClass, - ConnectionFactory factory, + private void setXAAckMode(ConnectionFactory factory, int xaAckMode) - throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException { - if (factoryClass == ACTIVEMQ_XA_CONNECTION_FACTORY_CLASS || - factoryClass == ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS) { + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + String factoryClassName = factory.getClass().getCanonicalName(); + if (isActiveMqXaFactory(factoryClassName)) { Class[] parameters = new Class[1]; parameters[0] = int.class; factory.getClass().getMethod("setXaAckMode", parameters).invoke(factory, xaAckMode); } } + private boolean isActiveMqXaFactory(String factoryClassName) { + return factoryClassName == ACTIVEMQ_XA_CONNECTION_FACTORY_CLASS || + factoryClassName == ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS; + } + private String setPropertiesInURL(String brokerURL, String factoryClass, ActiveMQConnectionFactoryConfiguration factoryConfiguration) throws URISyntaxException { From 35308e1f24af7a89c59daf42719577f6434414f4 Mon Sep 17 00:00:00 2001 From: sabecasismulesoft <105439827+sabecasismulesoft@users.noreply.github.com> Date: Tue, 28 Nov 2023 21:46:03 -0300 Subject: [PATCH 17/32] [W-14544171] send-message-through-SSL test fix after activemq version bump to 5.15.16 to fix W-14496786 (#523) * added tests for new host verification scenarios * some tests * Adding verifyHostName property to the brokerURL * created default value to fix vulnerability * refactored code * applied format * removed duplicate mule sdk version * forced spring core library to let activeMq client version work as expected * removed explicit spring version * forced spring version * bumped forced spring version * added specific spring-jms dependency * replaced version numbers with properties * moved spring-core to test * restored order of activemq-all and activemq-client * moved spring-jms and spring-core to compile scope * changed the order in dependencies. Removed forced versions * restored test jms dependency * removed comments * removed unused property * Changed recommended ActiveMQ version in Conenction provider * changed dependencies scope * reverted changes * changed the scope instead of the name * changed activemq-client dependency back to provided scope * added spring core dependency * set spring-core version in property * removed spring-jms dependency --- .../activemq/ActiveMQConnectionFactoryConfiguration.java | 1 - .../provider/activemq/ActiveMQConnectionFactoryProvider.java | 1 + .../provider/activemq/ActiveMQConnectionProvider.java | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index dbe0149e..8c3388e4 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -136,7 +136,6 @@ public class ActiveMQConnectionFactoryConfiguration { private boolean verifyHostName; - public int getMaxRedelivery() { return maxRedelivery; } diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index 7b58d281..e4a97e42 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -95,6 +95,7 @@ ConnectionFactory createDefaultConnectionFactory(boolean useSsl) throws ActiveMQ (ConnectionFactory) instantiateClass(factoryClass, setPropertiesInURL(factoryConfiguration.getBrokerUrl(), factoryClass, factoryConfiguration)); applyVendorSpecificConnectionFactoryProperties(connectionFactory); + return connectionFactory; } catch (ClassNotFoundException e) { String message = diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionProvider.java index 73fb8334..7f14f113 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionProvider.java @@ -82,7 +82,7 @@ public class ActiveMQConnectionProvider extends BaseConnectionProvider implement static final String CONNECTION_FACTORY_CLASS = "org.apache.activemq.ActiveMQConnectionFactory"; static final String BROKER_CLASS = "org.apache.activemq.broker.Broker"; static final String KAHA_DB_STORE_CLASS = "org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter"; - static final String ACTIVEMQ_VERSION = "5.15.4"; + static final String ACTIVEMQ_VERSION = "5.15.16"; static final String BROKER_GA = "org.apache.activemq:activemq-broker"; static final String KAHA_DB_GA = "org.apache.activemq:activemq-kahadb-store"; From b2191f0906edf2e01f7c4757bd9b6e70eecb9617 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Thu, 16 Nov 2023 16:57:17 -0300 Subject: [PATCH 18/32] added tests for new host verification scenarios --- src/test/docker/tls/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/docker/tls/Dockerfile b/src/test/docker/tls/Dockerfile index 8f677645..136a004a 100644 --- a/src/test/docker/tls/Dockerfile +++ b/src/test/docker/tls/Dockerfile @@ -1,9 +1,9 @@ FROM openjdk:8-jre -ENV ACTIVEMQ_VERSION 5.15.9 +ENV ACTIVEMQ_VERSION 5.15.16 ENV ACTIVEMQ apache-activemq-$ACTIVEMQ_VERSION ENV ACTIVEMQ_TCP=61616 ACTIVEMQ_AMQP=5672 ACTIVEMQ_STOMP=61613 ACTIVEMQ_MQTT=1883 ACTIVEMQ_WS=61614 ACTIVEMQ_UI=8161 -ENV SHA512_VAL=35cae4258e38e47f9f81e785f547afc457fc331d2177bfc2391277ce24123be1196f10c670b61e30b43b7ab0db0628f3ff33f08660f235b7796d59ba922d444f +ENV SHA512_VAL=5aaa73047b3f80f1a79984fe1a4b84645bd1d31ae2de3b41b774616d8290e5ff9647a0e38fd4a753e472c56efba42025be67561ac9f652442e7b226aa62236af ENV ACTIVEMQ_HOME /opt/activemq ENV ACTIVEMQ_SSL_OPTS=-Djavax.net.ssl.keyStore=/opt/activemq/certs/ActiveMq/broker.ks -Djavax.net.ssl.keyStorePassword=racing From 9f84ab0dc4f667dce11ba7e983eeed15c8966147 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:59:53 -0300 Subject: [PATCH 19/32] some tests --- src/test/docker/tls/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/docker/tls/Dockerfile b/src/test/docker/tls/Dockerfile index 136a004a..8f677645 100644 --- a/src/test/docker/tls/Dockerfile +++ b/src/test/docker/tls/Dockerfile @@ -1,9 +1,9 @@ FROM openjdk:8-jre -ENV ACTIVEMQ_VERSION 5.15.16 +ENV ACTIVEMQ_VERSION 5.15.9 ENV ACTIVEMQ apache-activemq-$ACTIVEMQ_VERSION ENV ACTIVEMQ_TCP=61616 ACTIVEMQ_AMQP=5672 ACTIVEMQ_STOMP=61613 ACTIVEMQ_MQTT=1883 ACTIVEMQ_WS=61614 ACTIVEMQ_UI=8161 -ENV SHA512_VAL=5aaa73047b3f80f1a79984fe1a4b84645bd1d31ae2de3b41b774616d8290e5ff9647a0e38fd4a753e472c56efba42025be67561ac9f652442e7b226aa62236af +ENV SHA512_VAL=35cae4258e38e47f9f81e785f547afc457fc331d2177bfc2391277ce24123be1196f10c670b61e30b43b7ab0db0628f3ff33f08660f235b7796d59ba922d444f ENV ACTIVEMQ_HOME /opt/activemq ENV ACTIVEMQ_SSL_OPTS=-Djavax.net.ssl.keyStore=/opt/activemq/certs/ActiveMq/broker.ks -Djavax.net.ssl.keyStorePassword=racing From b8197123e46f8974e7472eb97461709ee325dc92 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:47:10 -0300 Subject: [PATCH 20/32] Adding verifyHostName property to the brokerURL --- .../activemq/ActiveMQConnectionFactoryConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 8c3388e4..17572335 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -133,6 +133,7 @@ public class ActiveMQConnectionFactoryConfiguration { @Expression(NOT_SUPPORTED) @ExcludeFromConnectivitySchema @DisplayName("Verify hostname") + private boolean verifyHostName; @@ -207,7 +208,6 @@ public boolean getVerifyHostName() { public void setVerifyHostName(boolean verifyHostName) { this.verifyHostName = verifyHostName; } - public XaAckMode getXaAckMode() { return xaAckMode; } From 3ad5c578c064a668c693e070f27813de379a03ba Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 22 Nov 2023 11:29:28 -0300 Subject: [PATCH 21/32] created default value to fix vulnerability --- .../activemq/ActiveMQConnectionFactoryConfiguration.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 17572335..5818c6a7 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -202,7 +202,9 @@ public void setTrustAllPackages(boolean trustAllPackages) { } public boolean getVerifyHostName() { - return verifyHostName; + //TODO: change the default value to a parameter. This default is required to support a security fix and avoid + // breaking backwards compatibility (GUS ticket: W-14487260) + return false; } public void setVerifyHostName(boolean verifyHostName) { From 9d3f1dca8c1078429a486d0aba27428d23947d47 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:08:23 -0300 Subject: [PATCH 22/32] refactored code --- .../provider/activemq/ActiveMQConnectionFactoryProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index e4a97e42..f8ca377d 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -55,8 +55,8 @@ public class ActiveMQConnectionFactoryProvider { private static final String ACTIVEMQ_XA_SSL_CONNECTION_FACTORY_CLASS = "org.apache.activemq.ActiveMQXASslConnectionFactory"; private static final int REDELIVERY_IGNORE = -1; - private static final String VERIFY_HOSTNAME = "socket.verifyHostName"; + /** * Parameters required to configure a default {@link ActiveMQConnectionFactory} */ From 39dc00ec679c9e04abf61db9947a1deaf1b8053e Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:25:56 -0300 Subject: [PATCH 23/32] applied format --- .../provider/activemq/ActiveMQConnectionFactoryProvider.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index f8ca377d..2386be2b 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -56,7 +56,6 @@ public class ActiveMQConnectionFactoryProvider { private static final int REDELIVERY_IGNORE = -1; private static final String VERIFY_HOSTNAME = "socket.verifyHostName"; - /** * Parameters required to configure a default {@link ActiveMQConnectionFactory} */ From 1d3674a2453ddc4c2882aae7c6c75caf28ef3a09 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Sun, 26 Nov 2023 12:35:33 -0300 Subject: [PATCH 24/32] forced dependencies --- pom.xml | 18 ++++++++++++++++++ ...ActiveMQConnectionFactoryConfiguration.java | 7 ++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 8caf2f48..9b3aa9b5 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,18 @@ org.mule.connectors mule-jms-client ${muleJmsClientVersion} + + + org.springframework + spring-jms + + + + + org.springframework + spring-core + 5.3.31 + test commons-io @@ -90,6 +102,12 @@ ${javaxJmsApiVersion} provided + + org.springframework + spring-jms + 5.3.31 + test + diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 5818c6a7..860c399e 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -137,6 +137,7 @@ public class ActiveMQConnectionFactoryConfiguration { private boolean verifyHostName; + public int getMaxRedelivery() { return maxRedelivery; } @@ -202,14 +203,13 @@ public void setTrustAllPackages(boolean trustAllPackages) { } public boolean getVerifyHostName() { - //TODO: change the default value to a parameter. This default is required to support a security fix and avoid - // breaking backwards compatibility (GUS ticket: W-14487260) - return false; + return verifyHostName; } public void setVerifyHostName(boolean verifyHostName) { this.verifyHostName = verifyHostName; } + public XaAckMode getXaAckMode() { return xaAckMode; } @@ -218,6 +218,7 @@ public void setXaAckMode(XaAckMode xaAckMode) { this.xaAckMode = xaAckMode; } + @Override public boolean equals(Object o) { if (this == o) From 6946cff32534620dc1f630896cd130e37b80637b Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Mon, 27 Nov 2023 09:17:02 -0300 Subject: [PATCH 25/32] added new spring core and spring jms versions --- pom.xml | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 9b3aa9b5..f3b8faa8 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,8 @@ 1.11 1.1 1.3.7 + 5.3.31 + 5.3.31 formatter.xml 1.14.0-SNAPSHOT @@ -67,18 +69,6 @@ org.mule.connectors mule-jms-client ${muleJmsClientVersion} - - - org.springframework - spring-jms - - - - - org.springframework - spring-core - 5.3.31 - test commons-io @@ -102,12 +92,6 @@ ${javaxJmsApiVersion} provided - - org.springframework - spring-jms - 5.3.31 - test - From 2c46c3986e18bfd34114905d89472f83901c2b74 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Tue, 28 Nov 2023 19:18:36 -0300 Subject: [PATCH 26/32] W-14487260 set xaAckMode --- pom.xml | 7 +++++-- .../activemq/ActiveMQConnectionFactoryConfiguration.java | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f3b8faa8..d3e84a92 100644 --- a/pom.xml +++ b/pom.xml @@ -31,8 +31,6 @@ 1.11 1.1 1.3.7 - 5.3.31 - 5.3.31 formatter.xml 1.14.0-SNAPSHOT @@ -149,6 +147,11 @@ ${artemisVersion} test + + + + + org.springframework spring-core diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 860c399e..bb69ee53 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -136,6 +136,13 @@ public class ActiveMQConnectionFactoryConfiguration { private boolean verifyHostName; + @Parameter + @Optional(defaultValue = "1") + @Summary(" ") + @Expression(NOT_SUPPORTED) + @ExcludeFromConnectivitySchema + private int xaAckMode; + public int getMaxRedelivery() { From 1e75ba729f7d7913f112ba7eaaa7b20f2f4a3926 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:42:13 -0300 Subject: [PATCH 27/32] removed spring-jms dependency --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index d3e84a92..8caf2f48 100644 --- a/pom.xml +++ b/pom.xml @@ -147,11 +147,6 @@ ${artemisVersion} test - - - - - org.springframework spring-core From 8f930ab908f04708df6cd33c9d0b3ae094c1e093 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:00:58 -0300 Subject: [PATCH 28/32] Added XA ack mode enum --- .../activemq/ActiveMQConnectionFactoryConfiguration.java | 7 ------- .../activemq/ActiveMQConnectionFactoryProvider.java | 1 - 2 files changed, 8 deletions(-) diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index bb69ee53..132f6194 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -133,15 +133,8 @@ public class ActiveMQConnectionFactoryConfiguration { @Expression(NOT_SUPPORTED) @ExcludeFromConnectivitySchema @DisplayName("Verify hostname") - private boolean verifyHostName; - @Parameter - @Optional(defaultValue = "1") - @Summary(" ") - @Expression(NOT_SUPPORTED) - @ExcludeFromConnectivitySchema - private int xaAckMode; diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index 2386be2b..647adf94 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -94,7 +94,6 @@ ConnectionFactory createDefaultConnectionFactory(boolean useSsl) throws ActiveMQ (ConnectionFactory) instantiateClass(factoryClass, setPropertiesInURL(factoryConfiguration.getBrokerUrl(), factoryClass, factoryConfiguration)); applyVendorSpecificConnectionFactoryProperties(connectionFactory); - return connectionFactory; } catch (ClassNotFoundException e) { String message = From d2717c1ba25e90e7c1c5d58fe292945eb3a4c914 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:29:04 -0300 Subject: [PATCH 29/32] formatted code --- .../activemq/ActiveMQConnectionFactoryConfiguration.java | 1 - .../provider/activemq/ActiveMQConnectionFactoryProvider.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index 6f43a857..f31cb165 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -16,7 +16,6 @@ import org.mule.runtime.extension.api.annotation.param.display.DisplayName; import org.mule.runtime.extension.api.annotation.param.display.Example; import org.mule.runtime.extension.api.annotation.param.display.Summary; -import org.mule.runtime.extension.api.annotation.values.OfValues; import org.mule.sdk.api.annotation.semantics.connectivity.ExcludeFromConnectivitySchema; import org.mule.sdk.api.annotation.semantics.connectivity.Url; diff --git a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java index a44edfa6..f0894d5d 100644 --- a/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java +++ b/src/main/java/org/mule/extensions/jms/internal/connection/provider/activemq/ActiveMQConnectionFactoryProvider.java @@ -8,7 +8,6 @@ import static java.lang.String.format; import static org.mule.runtime.api.meta.ExpressionSupport.NOT_SUPPORTED; -import static org.mule.runtime.core.api.util.ClassUtils.findImplementedInterfaces; import static org.mule.runtime.core.api.util.ClassUtils.instantiateClass; import org.apache.activemq.util.URISupport; @@ -56,7 +55,7 @@ public class ActiveMQConnectionFactoryProvider { private static final int REDELIVERY_IGNORE = -1; private static final String VERIFY_HOSTNAME = "socket.verifyHostName"; - + /** * Parameters required to configure a default {@link ActiveMQConnectionFactory} */ From 314407597e4ac24f70e740da01c436daf9f1e250 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:39:58 -0300 Subject: [PATCH 30/32] added documentation and description --- .../ActiveMQConnectionFactoryConfiguration.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java index f31cb165..6a399b81 100644 --- a/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java +++ b/src/main/java/org/mule/extensions/jms/api/connection/factory/activemq/ActiveMQConnectionFactoryConfiguration.java @@ -56,12 +56,14 @@ public class ActiveMQConnectionFactoryConfiguration { private boolean enableXA; /** - * + * Indicates how ACK is going to be handled in an XA Session. + * Since ActiveMQ version 5.16.0 this value is mandatory for XA sessions without an XA transaction associated. + * The possible value is one of the fields available in {@link "https://docs.oracle.com/javaee/6/api/javax/jms/Session.html?is-external=true#AUTO_ACKNOWLEDGE"} */ @DisplayName("XA ack mode") @Parameter @Optional(defaultValue = "AUTO_ACKNOWLEDGE") - @Summary(" ") + @Summary("Indicates how ACK is going to be handled in an XA Session.") @Expression(NOT_SUPPORTED) @ExcludeFromConnectivitySchema private XaAckMode xaAckMode; @@ -190,9 +192,6 @@ public boolean isTrustAllPackages() { return trustAllPackages; } - public boolean getTrustAllPackages() { - return trustAllPackages; - } public void setTrustAllPackages(boolean trustAllPackages) { this.trustAllPackages = trustAllPackages; @@ -228,6 +227,7 @@ public boolean equals(Object o) { maxRedelivery == that.maxRedelivery && trustAllPackages == that.trustAllPackages && verifyHostName == that.verifyHostName && + xaAckMode == that.xaAckMode && Objects.equals(brokerUrl, that.brokerUrl) && Objects.equals(trustedPackages, that.trustedPackages); } @@ -235,6 +235,6 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash(brokerUrl, enableXA, initialRedeliveryDelay, redeliveryDelay, maxRedelivery, trustedPackages, - trustAllPackages, verifyHostName); + trustAllPackages, verifyHostName, xaAckMode); } } From 9e3b4460553345e011471321946ef090f13ae52f Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:49:12 -0300 Subject: [PATCH 31/32] added verifyHostName=false to tests --- .../munit/activemq-over-ssl-test-case.xml | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/test/munit/activemq-over-ssl-test-case.xml b/src/test/munit/activemq-over-ssl-test-case.xml index f4970a84..b6dbf9e7 100644 --- a/src/test/munit/activemq-over-ssl-test-case.xml +++ b/src/test/munit/activemq-over-ssl-test-case.xml @@ -15,16 +15,32 @@ - + + - + + + + + + + + + + + + + + + + @@ -32,13 +48,23 @@ - + + + + + + + + + + + - + @@ -61,12 +87,12 @@ - + #[vars.message] - + From 75e5181be7561374e2091f6ffdf55cc8d287bdd0 Mon Sep 17 00:00:00 2001 From: Sabrina Abecasis <105439827+sabecasismulesoft@users.noreply.github.com> Date: Thu, 30 Nov 2023 06:28:49 -0300 Subject: [PATCH 32/32] Added verifyHostName=true test scenario --- ...er-ssl-verify-host-name-true-test-case.xml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/test/munit/activemq-over-ssl-verify-host-name-true-test-case.xml diff --git a/src/test/munit/activemq-over-ssl-verify-host-name-true-test-case.xml b/src/test/munit/activemq-over-ssl-verify-host-name-true-test-case.xml new file mode 100644 index 00000000..08e0f75b --- /dev/null +++ b/src/test/munit/activemq-over-ssl-verify-host-name-true-test-case.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + #[{ port : p('activemq.port') }] + + + + + + + + + + + + + + + + + + + #[vars.message] + + + + + + + + + +