From a13f6fd389658bf6c751a6d6c0dbd3f7e94c22bc Mon Sep 17 00:00:00 2001 From: Vlad-Marian MARIAN Date: Fri, 1 Nov 2024 17:18:10 +0100 Subject: [PATCH 01/17] Quality updates --- .../mimecast/robin/config/client/RequestConfig.java | 4 +--- .../robin/smtp/extension/client/ClientData.java | 9 +++++---- .../com/mimecast/robin/storage/StorageCleaner.java | 10 ++++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/mimecast/robin/config/client/RequestConfig.java b/src/main/java/com/mimecast/robin/config/client/RequestConfig.java index 8e8fe4d6..7707ee31 100644 --- a/src/main/java/com/mimecast/robin/config/client/RequestConfig.java +++ b/src/main/java/com/mimecast/robin/config/client/RequestConfig.java @@ -238,9 +238,7 @@ protected Pair getObjectMap() { public String getFile(String path) { StringBuilder stringBuilder = new StringBuilder(); - try { - LineInputStream stream = new LineInputStream(new MagicInputStream(new FileInputStream(path))); - + try (LineInputStream stream = new LineInputStream(new MagicInputStream(new FileInputStream(path)))) { byte[] bytes; while ((bytes = stream.readLine()) != null) { stringBuilder.append(Magic.magicReplace(new String(bytes), connection.getSession())); diff --git a/src/main/java/com/mimecast/robin/smtp/extension/client/ClientData.java b/src/main/java/com/mimecast/robin/smtp/extension/client/ClientData.java index 9923dffa..5b4fbb74 100644 --- a/src/main/java/com/mimecast/robin/smtp/extension/client/ClientData.java +++ b/src/main/java/com/mimecast/robin/smtp/extension/client/ClientData.java @@ -118,9 +118,7 @@ protected InputStream getStream(Connection connection, boolean bdat) throws IOEx Map headers = envelope.getHeaders(); if (!headers.isEmpty()) { List prependHeaders = new ArrayList<>(); - headers.forEach((name, value) -> { - prependHeaders.add(name + ": " + value + "\r\n"); - }); + headers.forEach((name, value) -> prependHeaders.add(name + ": " + value + "\r\n")); inputStream = new SequenceInputStream(Collections.enumeration(Arrays.asList(new ByteArrayInputStream(String.join("", prependHeaders).getBytes()), inputStream))); } } @@ -153,7 +151,10 @@ protected boolean processData(String verb, InputStream inputStream) throws IOExc if (envelope.getTerminateAfterBytes() > 0) { log.debug("Terminating after {} bytes.", envelope.getTerminateAfterBytes()); envelope.setTerminateBeforeDot(true); - inputStream = new BoundedInputStream(inputStream, envelope.getTerminateAfterBytes()); + inputStream = BoundedInputStream.builder() + .setInputStream(inputStream) + .setMaxCount(envelope.getTerminateAfterBytes()) + .get(); } connection.stream( diff --git a/src/main/java/com/mimecast/robin/storage/StorageCleaner.java b/src/main/java/com/mimecast/robin/storage/StorageCleaner.java index 4c7306a7..ca9e7518 100644 --- a/src/main/java/com/mimecast/robin/storage/StorageCleaner.java +++ b/src/main/java/com/mimecast/robin/storage/StorageCleaner.java @@ -58,8 +58,9 @@ public static void cleanDirectory(File directory, boolean remove, List } else { for (Pattern p : patterns) { if (p.matcher(file.getName()).find()) { - file.delete(); - log.trace("Removed file: {}", file.getAbsolutePath()); + if (file.delete()) { + log.trace("Removed file: {}", file.getAbsolutePath()); + } break; } } @@ -72,8 +73,9 @@ public static void cleanDirectory(File directory, boolean remove, List files = directory.listFiles(); if (remove && files != null && files.length == 0) { - directory.delete(); - log.debug("Removed folder: {}", directory.getAbsolutePath()); + if (directory.delete()) { + log.debug("Removed folder: {}", directory.getAbsolutePath()); + } } } catch (Exception e) { From 51ab58d8659a0cfd71bce278dc64b07401412994 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 00:12:15 +0000 Subject: [PATCH 02/17] Bump org.apache.maven.plugins:maven-surefire-plugin from 3.5.1 to 3.5.2 Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.5.1 to 3.5.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.5.1...surefire-3.5.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eac11eb1..c01445b4 100644 --- a/pom.xml +++ b/pom.xml @@ -186,7 +186,7 @@ maven-surefire-plugin - 3.5.1 + 3.5.2 false false From 08d6b1265638c5c2c26e32b6d9156e59acf3847f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 00:12:19 +0000 Subject: [PATCH 03/17] Bump org.junit.platform:junit-platform-launcher from 1.11.2 to 1.11.3 Bumps [org.junit.platform:junit-platform-launcher](https://github.com/junit-team/junit5) from 1.11.2 to 1.11.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/commits) --- updated-dependencies: - dependency-name: org.junit.platform:junit-platform-launcher dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eac11eb1..e4935d8e 100644 --- a/pom.xml +++ b/pom.xml @@ -141,7 +141,7 @@ org.junit.platform junit-platform-launcher - 1.11.2 + 1.11.3 test From 596f9fa8dd5c60d43fc8bf2da84b3b50b1042996 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 00:12:21 +0000 Subject: [PATCH 04/17] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.1 to 3.11.1 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.10.1 to 3.11.1. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.10.1...maven-javadoc-plugin-3.11.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eac11eb1..62c58c97 100644 --- a/pom.xml +++ b/pom.xml @@ -213,7 +213,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.10.1 + 3.11.1 ${basedir}/src/main/resources/javadoc.css private From 69ca8af8d6733c32a6aca26b463e78c0c64f9c8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 00:12:24 +0000 Subject: [PATCH 05/17] Bump org.junit.jupiter:junit-jupiter-engine from 5.11.2 to 5.11.3 Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.2 to 5.11.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.2...r5.11.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eac11eb1..4db25428 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,7 @@ org.junit.jupiter junit-jupiter-engine - 5.11.2 + 5.11.3 test From a5c8fdb32522e75fd40681c8ad3e6bde48161c14 Mon Sep 17 00:00:00 2001 From: Vlad-Marian MARIAN Date: Fri, 15 Nov 2024 15:01:57 +0100 Subject: [PATCH 06/17] Release 1.3.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eac11eb1..f69232dd 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.mimecast robin robin - 1.3.1-SNAPSHOT + 1.3.1 jar Debug and development tool for MTA architects. From 427959554f0cb6334fcc4448fbc7cc714733cb21 Mon Sep 17 00:00:00 2001 From: Vlad-Marian MARIAN Date: Fri, 15 Nov 2024 15:04:57 +0100 Subject: [PATCH 07/17] Snapshot 1.3.2-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0349463..9090dc33 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.mimecast robin robin - 1.3.1 + 1.3.2-SNAPSHOT jar Debug and development tool for MTA architects. From 70785cba51fafb71bb664fff79aa76b3a86b2e26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 00:40:24 +0000 Subject: [PATCH 08/17] Bump commons-io:commons-io from 2.17.0 to 2.18.0 Bumps commons-io:commons-io from 2.17.0 to 2.18.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9090dc33..4fc71632 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ commons-io commons-io - 2.17.0 + 2.18.0 org.reflections From 27425db9678bb4edd172479af321ec3f774c99ac Mon Sep 17 00:00:00 2001 From: Vlad-Marian MARIAN Date: Wed, 20 Nov 2024 10:44:16 +0100 Subject: [PATCH 09/17] Update maven.yml --- .github/workflows/maven.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index aeaececc..6223156c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,6 +21,3 @@ jobs: cache: maven - name: Build with Maven run: mvn -B package --file pom.xml - - - name: Update dependency graph - uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 From 1b47e61a7c993cba715c3a0233bfeb483b026fbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 00:25:24 +0000 Subject: [PATCH 10/17] Bump log4j.version from 2.24.1 to 2.24.2 Bumps `log4j.version` from 2.24.1 to 2.24.2. Updates `org.apache.logging.log4j:log4j-api` from 2.24.1 to 2.24.2 Updates `org.apache.logging.log4j:log4j-core` from 2.24.1 to 2.24.2 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.logging.log4j:log4j-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4fc71632..f9dbf4fc 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ UTF-8 1.6.2 33.3.1-jre - 2.24.1 + 2.24.2 1.37 From 50fd1235bb42b9ca5dd585583d6d12d6ce836877 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 00:18:37 +0000 Subject: [PATCH 11/17] Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.1 to 3.11.2 Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.1 to 3.11.2. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.11.1...maven-javadoc-plugin-3.11.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f9dbf4fc..3a658c2e 100644 --- a/pom.xml +++ b/pom.xml @@ -213,7 +213,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.11.1 + 3.11.2 ${basedir}/src/main/resources/javadoc.css private From 231dd9b9f01a081e36f0b2797c928510648f3e02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:08:38 +0000 Subject: [PATCH 12/17] Bump log4j.version from 2.24.2 to 2.24.3 Bumps `log4j.version` from 2.24.2 to 2.24.3. Updates `org.apache.logging.log4j:log4j-api` from 2.24.2 to 2.24.3 Updates `org.apache.logging.log4j:log4j-core` from 2.24.2 to 2.24.3 --- updated-dependencies: - dependency-name: org.apache.logging.log4j:log4j-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.logging.log4j:log4j-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f9dbf4fc..d23bbaaa 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ UTF-8 1.6.2 33.3.1-jre - 2.24.2 + 2.24.3 1.37 From a6c09d5c02693df9f3072ae0016e00e9e77f58d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 00:22:44 +0000 Subject: [PATCH 13/17] Bump org.junit.jupiter:junit-jupiter-engine from 5.11.3 to 5.11.4 Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.3 to 5.11.4. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.11.3...r5.11.4) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c18ebca7..4fd1c1ef 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,7 @@ org.junit.jupiter junit-jupiter-engine - 5.11.3 + 5.11.4 test From d4440e9ffc048b0509f36c13e50a8525452eab25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 00:22:48 +0000 Subject: [PATCH 14/17] Bump org.junit.platform:junit-platform-launcher from 1.11.3 to 1.11.4 Bumps [org.junit.platform:junit-platform-launcher](https://github.com/junit-team/junit5) from 1.11.3 to 1.11.4. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/commits) --- updated-dependencies: - dependency-name: org.junit.platform:junit-platform-launcher dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c18ebca7..f1a661f2 100644 --- a/pom.xml +++ b/pom.xml @@ -141,7 +141,7 @@ org.junit.platform junit-platform-launcher - 1.11.3 + 1.11.4 test From 5acba8d043209a10256f99bab9736583a7671d0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 00:22:52 +0000 Subject: [PATCH 15/17] Bump com.google.guava:guava from 33.3.1-jre to 33.4.0-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.3.1-jre to 33.4.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c18ebca7..b63ad4cb 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 11 UTF-8 1.6.2 - 33.3.1-jre + 33.4.0-jre 2.24.3 1.37 From 0d052de8b5ef779b9a2f9f784422cc2414c4c2c7 Mon Sep 17 00:00:00 2001 From: Vlad-Marian MARIAN Date: Wed, 18 Dec 2024 17:26:28 +0100 Subject: [PATCH 16/17] Refactor some private to protected methods and variables in Client and RequestClient for extending/reusing --- .../java/com/mimecast/robin/main/Client.java | 17 ++++++++++++----- .../com/mimecast/robin/main/RequestClient.java | 8 +++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/mimecast/robin/main/Client.java b/src/main/java/com/mimecast/robin/main/Client.java index b33a2a46..70fc1a92 100644 --- a/src/main/java/com/mimecast/robin/main/Client.java +++ b/src/main/java/com/mimecast/robin/main/Client.java @@ -21,12 +21,12 @@ public class Client extends Foundation { /** * Session instance. */ - private Session session; + protected Session session; /** * Connection instance. */ - private Connection connection; + protected Connection connection; /** * Have assertions been skipped? @@ -34,7 +34,7 @@ public class Client extends Foundation { protected Boolean skipped = false; /** - * Constructs a new RequestClient instance with given Session instance. + * Constructs a new Client instance with given Session instance. * * @param session Session instance. */ @@ -85,14 +85,21 @@ public Client send(CaseConfig caseConfig) throws AssertException { session.map(caseConfig); // Send. - EmailDelivery emailDelivery = new EmailDelivery(session).send(); - connection = emailDelivery.getConnection(); + deliver(); // Assert. assertion(connection); return this; } + /** + * Deliver email. + */ + protected void deliver() { + EmailDelivery emailDelivery = new EmailDelivery(session).send(); + connection = emailDelivery.getConnection(); + } + /** * Assert delivery successfull if any. * diff --git a/src/main/java/com/mimecast/robin/main/RequestClient.java b/src/main/java/com/mimecast/robin/main/RequestClient.java index 6d5f67b6..6d688785 100644 --- a/src/main/java/com/mimecast/robin/main/RequestClient.java +++ b/src/main/java/com/mimecast/robin/main/RequestClient.java @@ -111,7 +111,13 @@ public RequestClient request(String casePath) throws AssertException, IOExceptio return this; } - protected String getUrlHost(String url) { + /** + * Gets host from URL. + * + * @param url URL string. + * @return hostname string. + */ + public static String getUrlHost(String url) { try { return new URI(url).getHost(); } catch (URISyntaxException e) { From 35c8cd559467f88970d9db548272d25e51c84234 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 00:14:36 +0000 Subject: [PATCH 17/17] Bump org.json:json from 20240303 to 20241224 Bumps [org.json:json](https://github.com/douglascrockford/JSON-java) from 20240303 to 20241224. - [Release notes](https://github.com/douglascrockford/JSON-java/releases) - [Changelog](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md) - [Commits](https://github.com/douglascrockford/JSON-java/commits) --- updated-dependencies: - dependency-name: org.json:json dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6f18f9f4..7b79815e 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ org.json json - 20240303 + 20241224 com.googlecode.juniversalchardet