(james-project) branch postgresql updated: JAMES-3777 [FIX] ReadProjection was not correctly used (#1899)
This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch postgresql in repository https://gitbox.apache.org/repos/asf/james-project.git The following commit(s) were added to refs/heads/postgresql by this push: new 602faa9980 JAMES-3777 [FIX] ReadProjection was not correctly used (#1899) 602faa9980 is described below commit 602faa99808e45e032f8ef2b4d0fcbcc273271cd Author: Trần Hồng Quân <55171818+quantranhong1...@users.noreply.github.com> AuthorDate: Fri Jan 5 14:12:17 2024 +0700 JAMES-3777 [FIX] ReadProjection was not correctly used (#1899) --- .../filtering/CassandraFilteringProjection.java | 6 +++--- ...ntSourcingFilteringManagementNoProjectionTest.java | 5 + .../impl/EventSourcingFilteringManagement.java| 19 +++ .../data/jmap/PopulateFilteringProjectionTask.java| 2 +- .../PopulateFilteringProjectionRequestToTaskTest.java | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringProjection.java b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringProjection.java index 0282d7c683..05294a6fdc 100644 --- a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringProjection.java +++ b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/CassandraFilteringProjection.java @@ -29,7 +29,6 @@ import static org.apache.james.jmap.cassandra.filtering.CassandraFilteringProjec import java.util.List; import java.util.Optional; -import java.util.function.Function; import javax.inject.Inject; @@ -54,6 +53,7 @@ import com.datastax.oss.driver.api.core.cql.Row; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.google.common.collect.ImmutableList; import reactor.core.publisher.Mono; @@ -82,7 +82,7 @@ public class CassandraFilteringProjection implements EventSourcingFilteringManag .whereColumn(AGGREGATE_ID).isEqualTo(bindMarker(AGGREGATE_ID)) .build()); -objectMapper = new ObjectMapper(); +objectMapper = new ObjectMapper().registerModule(new Jdk8Module()); } @Override @@ -107,7 +107,7 @@ public class CassandraFilteringProjection implements EventSourcingFilteringManag } @Override -public Optional subscriber(Function> ruleLoader) { +public Optional subscriber() { return Optional.of(this); } diff --git a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementNoProjectionTest.java b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementNoProjectionTest.java index abe1636d3b..dbcfe0599e 100644 --- a/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementNoProjectionTest.java +++ b/server/data/data-jmap-cassandra/src/test/java/org/apache/james/jmap/cassandra/filtering/CassandraEventSourcingFilteringManagementNoProjectionTest.java @@ -20,7 +20,6 @@ package org.apache.james.jmap.cassandra.filtering; import org.apache.james.backends.cassandra.CassandraClusterExtension; -import org.apache.james.backends.cassandra.components.CassandraModule; import org.apache.james.eventsourcing.eventstore.EventStore; import org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStore; import org.apache.james.eventsourcing.eventstore.cassandra.CassandraEventStoreModule$; @@ -34,9 +33,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; class CassandraEventSourcingFilteringManagementNoProjectionTest implements FilteringManagementContract { @RegisterExtension -static CassandraClusterExtension eventStoreExtension = new CassandraClusterExtension(CassandraModule.aggregateModules( -CassandraEventStoreModule$.MODULE$.MODULE(), -CassandraFilteringProjectionModule.MODULE)); +static CassandraClusterExtension eventStoreExtension = new CassandraClusterExtension(CassandraEventStoreModule$.MODULE$.MODULE()); private EventStore eventStore; diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java index 08ac0d372f..ff7d6caf43 100644 --- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/impl/EventSourcingFilteringManagement.java +++
Re: [PR] JAMES-3777 [FIX] ReadProjection was not correctly used [james-project]
chibenwa merged PR #1899: URL: https://github.com/apache/james-project/pull/1899 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
(james-project) branch postgresql updated: JAMES-2586 Adopt Postgres 16.1 (#1897)
This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch postgresql in repository https://gitbox.apache.org/repos/asf/james-project.git The following commit(s) were added to refs/heads/postgresql by this push: new e6ff72c754 JAMES-2586 Adopt Postgres 16.1 (#1897) e6ff72c754 is described below commit e6ff72c7546d6c8d3de9f02b91540ac3e874e22a Author: Benoit TELLIER AuthorDate: Fri Jan 5 08:12:01 2024 +0100 JAMES-2586 Adopt Postgres 16.1 (#1897) --- .../test/java/org/apache/james/backends/postgres/PostgresFixture.java | 2 +- server/apps/postgres-app/docker-compose-distributed.yml | 2 +- server/apps/postgres-app/docker-compose.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresFixture.java b/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresFixture.java index 6c003f7ad9..897943a75c 100644 --- a/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresFixture.java +++ b/backends-common/postgres/src/test/java/org/apache/james/backends/postgres/PostgresFixture.java @@ -88,7 +88,7 @@ public interface PostgresFixture { } } -String IMAGE = "postgres:16"; +String IMAGE = "postgres:16.1"; Integer PORT = POSTGRESQL_PORT; Supplier> PG_CONTAINER = () -> new PostgreSQLContainer<>(IMAGE) .withDatabaseName(DEFAULT_DATABASE.dbName()) diff --git a/server/apps/postgres-app/docker-compose-distributed.yml b/server/apps/postgres-app/docker-compose-distributed.yml index 95bc9b0390..ddf5d3cc94 100644 --- a/server/apps/postgres-app/docker-compose-distributed.yml +++ b/server/apps/postgres-app/docker-compose-distributed.yml @@ -49,7 +49,7 @@ services: - james postgres: -image: postgres:16.0 +image: postgres:16.1 container_name: postgres ports: - "5432:5432" diff --git a/server/apps/postgres-app/docker-compose.yml b/server/apps/postgres-app/docker-compose.yml index c8d5f8f995..50440253bd 100644 --- a/server/apps/postgres-app/docker-compose.yml +++ b/server/apps/postgres-app/docker-compose.yml @@ -23,7 +23,7 @@ services: - ./sample-configuration-single/search.properties:/root/conf/search.properties postgres: -image: postgres:16.0 +image: postgres:16.1 ports: - "5432:5432" environment: - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES-2586 Adopt Postgres 16.1 [james-project]
chibenwa merged PR #1897: URL: https://github.com/apache/james-project/pull/1897 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES 3897: CrowdsecImapConnectionCheck [james-project]
vttranlina commented on code in PR #1824: URL: https://github.com/apache/james-project/pull/1824#discussion_r1442497393 ## server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IpConnectionCheck.java: ## @@ -0,0 +1,47 @@ +/ + * 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. * + / + +package org.apache.james.imapserver.netty; + +import java.net.InetSocketAddress; +import java.util.Set; + +import org.apache.james.imap.api.ConnectionCheck; +import org.reactivestreams.Publisher; + +import reactor.core.publisher.Mono; + +public class IpConnectionCheck implements ConnectionCheck { +private Set bannedIps = Set.of(); + +@Override +public Publisher validate(InetSocketAddress remoteAddress) { +String ip = remoteAddress.getAddress().getHostAddress(); +// check against bannedIps +if (bannedIps.stream().anyMatch(bannedIp -> bannedIp.equals(ip))) { +return Mono.error(() -> new RuntimeException("Banned")); +} else { +return Mono.empty(); +} +} + +public void setBannedIps(Set bannedIps) { Review Comment: If it is a method for testing 1. you can add annotation it by @VisibleForTesting 2. the `bannedIps` is always empty on prod -> the class `IpConnectionCheck` does not make sense -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES 3897: CrowdsecImapConnectionCheck [james-project]
thanhbv200585 commented on code in PR #1824: URL: https://github.com/apache/james-project/pull/1824#discussion_r1442489035 ## server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IpConnectionCheck.java: ## @@ -0,0 +1,47 @@ +/ + * 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. * + / + +package org.apache.james.imapserver.netty; + +import java.net.InetSocketAddress; +import java.util.Set; + +import org.apache.james.imap.api.ConnectionCheck; +import org.reactivestreams.Publisher; + +import reactor.core.publisher.Mono; + +public class IpConnectionCheck implements ConnectionCheck { +private Set bannedIps = Set.of(); + +@Override +public Publisher validate(InetSocketAddress remoteAddress) { +String ip = remoteAddress.getAddress().getHostAddress(); +// check against bannedIps +if (bannedIps.stream().anyMatch(bannedIp -> bannedIp.equals(ip))) { +return Mono.error(() -> new RuntimeException("Banned")); +} else { +return Mono.empty(); +} +} + +public void setBannedIps(Set bannedIps) { Review Comment: Because I need to add bannedIps for testing ``` private void addBannedIps(String clientIp) { imapServer.getConnectionChecks().stream() .filter(check -> check instanceof IpConnectionCheck) .map(check -> (IpConnectionCheck) check) .forEach(ipCheck -> ipCheck.setBannedIps(Set.of(clientIp))); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES 3897: CrowdsecImapConnectionCheck [james-project]
vttranlina commented on code in PR #1824: URL: https://github.com/apache/james-project/pull/1824#discussion_r1442485772 ## third-party/crowdsec/src/main/java/org/apache/james/CrowdsecImapConnectionCheck.java: ## @@ -0,0 +1,80 @@ +/ + * 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. * + / + +package org.apache.james; + +import static org.apache.james.model.CrowdsecClientConfiguration.DEFAULT_TIMEOUT; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeoutException; + +import javax.inject.Inject; + +import org.apache.commons.net.util.SubnetUtils; +import org.apache.james.exception.CrowdsecException; +import org.apache.james.imap.api.ConnectionCheck; +import org.apache.james.model.CrowdsecClientConfiguration; +import org.apache.james.model.CrowdsecDecision; +import org.apache.james.model.CrowdsecHttpClient; +import org.reactivestreams.Publisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import reactor.core.publisher.Mono; + +public class CrowdsecImapConnectionCheck implements ConnectionCheck { +private static final Logger LOGGER = LoggerFactory.getLogger(CrowdsecImapConnectionCheck.class); + +private final CrowdsecHttpClient client; + +@Inject +public CrowdsecImapConnectionCheck(CrowdsecClientConfiguration crowdsecClientConfiguration) { +this.client = new CrowdsecHttpClient(crowdsecClientConfiguration); +} + +@Override +public Publisher validate(InetSocketAddress remoteAddress) { +String ip = remoteAddress.getAddress().getHostAddress(); + +return client.getCrowdsecDecisions() Review Comment: @thanhbv200585 if we don't cache it, can you check the http api of Crowdsec support is reactive or not? if yes, the `client.getCrowdsecDecisions()` return `Flux` is better than `Mono>` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
(james-project) 03/03: [ENHANCEMENT] DataLineJamesMessageHookHandler: method extraction
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch 3.7.x in repository https://gitbox.apache.org/repos/asf/james-project.git commit 47a520f263018aa8349119a19dafc3184362c701 Author: Benoit TELLIER AuthorDate: Tue Jan 2 09:54:44 2024 +0100 [ENHANCEMENT] DataLineJamesMessageHookHandler: method extraction --- .../smtpserver/DataLineJamesMessageHookHandler.java | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java index 35a1b94bf4..332e727d0c 100644 --- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java +++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java @@ -88,7 +88,6 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib @Override public Response onLine(SMTPSession session, ByteBuffer lineByteBuffer, LineHandler next) { - byte[] line = new byte[lineByteBuffer.remaining()]; lineByteBuffer.get(line, 0, line.length); @@ -107,14 +106,7 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib out.flush(); out.close(); -List recipientCollection = session.getAttachment(SMTPSession.RCPT_LIST, State.Transaction).orElse(ImmutableList.of()); -MaybeSender sender = session.getAttachment(SMTPSession.SENDER, State.Transaction).orElse(MaybeSender.nullSender()); - -MailImpl mail = MailImpl.builder() -.name(mailName) -.sender(sender) -.addRecipients(recipientCollection) -.build(); +MailImpl mail = createMail(session, mailName); // store mail in the session so we can be sure it get disposed later session.setAttachment(SMTPConstants.MAIL, mail, State.Transaction); @@ -166,6 +158,17 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib return null; } +private static MailImpl createMail(SMTPSession session, String mailName) { +List recipientCollection = session.getAttachment(SMTPSession.RCPT_LIST, State.Transaction).orElse(ImmutableList.of()); +MaybeSender sender = session.getAttachment(SMTPSession.SENDER, State.Transaction).orElse(MaybeSender.nullSender()); + +return MailImpl.builder() +.name(mailName) +.sender(sender) +.addRecipients(recipientCollection) +.build(); +} + protected Response processExtensions(SMTPSession session, Mail mail) { if (mail != null && messageHandlers != null) { try { - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
(james-project) branch 3.7.x updated (ec277b6b87 -> 47a520f263)
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a change to branch 3.7.x in repository https://gitbox.apache.org/repos/asf/james-project.git from ec277b6b87 [FIX] JMX password auto-detection (#1894) new 1a5b87767c [FIX] Close connection after DATA errors new 9aeca5e37c [FIX] Ignore commands after closed connection new 47a520f263 [ENHANCEMENT] DataLineJamesMessageHookHandler: method extraction The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../protocols/api/AbstractProtocolTransport.java | 11 +- .../DataLineJamesMessageHookHandler.java | 25 ++ 2 files changed, 26 insertions(+), 10 deletions(-) - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
(james-project) 02/03: [FIX] Ignore commands after closed connection
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch 3.7.x in repository https://gitbox.apache.org/repos/asf/james-project.git commit 9aeca5e37cb9cbe255f74fd8f02e444c2fb2d8d9 Author: Benoit TELLIER AuthorDate: Tue Jan 2 09:52:59 2024 +0100 [FIX] Ignore commands after closed connection --- .../apache/james/protocols/api/AbstractProtocolTransport.java | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java b/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java index 661de6f3ad..a3ef7eb8f4 100644 --- a/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java +++ b/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java @@ -23,14 +23,18 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Abstract base class for {@link ProtocolTransport} implementation which already takes care of all the complex * stuff when handling {@link Response}'s. */ public abstract class AbstractProtocolTransport implements ProtocolTransport { +private static final Logger LOGGER = LoggerFactory.getLogger(AbstractProtocolTransport.class); private static final String CRLF = "\r\n"; - + @Override public final void writeResponse(Response response, ProtocolSession session) { if (response != null) { @@ -57,6 +61,11 @@ public abstract class AbstractProtocolTransport implements ProtocolTransport { } if (response.isEndSession()) { +// We can close the channel only after the client +session.pushLineHandler((session1, buffer) -> { +LOGGER.info("Received a command after close, discarding it."); +return null; +}); // close the channel if needed after the message was written out close(); } - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
(james-project) 01/03: [FIX] Close connection after DATA errors
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch 3.7.x in repository https://gitbox.apache.org/repos/asf/james-project.git commit 1a5b87767c032bd9156848e998429d3fb3de2979 Author: Benoit TELLIER AuthorDate: Tue Jan 2 09:52:38 2024 +0100 [FIX] Close connection after DATA errors --- .../org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java | 4 1 file changed, 4 insertions(+) diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java index 44d15b2fbc..35a1b94bf4 100644 --- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java +++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java @@ -150,11 +150,15 @@ public class DataLineJamesMessageHookHandler implements DataLineFilter, Extensib } catch (IOException e) { LifecycleUtil.dispose(mmiss); SMTPResponse response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.UNDEFINED_STATUS) + " Error processing message: " + e.getMessage()); +response.setEndSession(true); +session.popLineHandler(); LOGGER.error("Unknown error occurred while processing DATA.", e); return response; } catch (CommandInjectionDetectedException e) { LifecycleUtil.dispose(mmiss); SMTPResponse response = new SMTPResponse(SMTPRetCode.SYNTAX_ERROR_COMMAND_UNRECOGNIZED, DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.UNDEFINED_STATUS) + " line delimiter must be CRLF"); +response.setEndSession(true); +session.popLineHandler(); LOGGER.info("Use of CRLF, which might indicate SMTP smuggling attempt"); return response; - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] [FIX] Close connection after DATA errors [james-project]
Arsnael merged PR #1888: URL: https://github.com/apache/james-project/pull/1888 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES-2586 Implement BlobReferenceSource(s) for postgres-app [james-project]
chibenwa commented on PR #1900: URL: https://github.com/apache/james-project/pull/1900#issuecomment-1876888292 Please write integration tests for bob deletion using the deduplicating blob store. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[PR] JAMES-2586 Implement BlobReferenceSource(s) for postgres-app [james-project]
hungphan227 opened a new pull request, #1900: URL: https://github.com/apache/james-project/pull/1900 (no comment) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[PR] JAMES-3777 [FIX] ReadProjection was not correctly used [james-project]
quantranhong1999 opened a new pull request, #1899: URL: https://github.com/apache/james-project/pull/1899 (no comment) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[PR] JAMES-3777 [FIX] ReadProjection was not correctly used [james-project]
quantranhong1999 opened a new pull request, #1898: URL: https://github.com/apache/james-project/pull/1898 (no comment) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] Crowdsec Integration for POP3 server [james-project]
vttranlina commented on PR #1887: URL: https://github.com/apache/james-project/pull/1887#issuecomment-1876701037 The picture looks like Guice binding error But when I tried to run `CrowdsecPOP3IntegrationTest` locally, I got another error: ```java [INFO] Running org.apache.james.CrowdsecPOP3IntegrationTest [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 12.47 s <<< FAILURE! -- in org.apache.james.CrowdsecPOP3IntegrationTest [ERROR] org.apache.james.CrowdsecPOP3IntegrationTest.ipShouldBeBannedByCrowdSecWhenFailingToImapLoginThreeTimes -- Time elapsed: 2.916 s <<< ERROR! org.apache.commons.configuration2.ex.ConfigurationRuntimeException: Passed in key must select exactly one node (found 0): handlerchain at org.apache.commons.configuration2.BaseHierarchicalConfiguration.createIndependentSubConfiguration(BaseHierarchicalConfiguration.java:284) at org.apache.commons.configuration2.BaseHierarchicalConfiguration.configurationAt(BaseHierarchicalConfiguration.java:190) at org.apache.commons.configuration2.BaseHierarchicalConfiguration.configurationAt(BaseHierarchicalConfiguration.java:332) at org.apache.james.protocols.lib.netty.AbstractProtocolAsyncServer.preInit(AbstractProtocolAsyncServer.java:51) at org.apache.james.pop3server.netty.POP3Server.preInit(POP3Server.java:78) at org.apache.james.protocols.lib.netty.AbstractConfigurableAsyncServer.init(AbstractConfigurableAsyncServer.java:243) at org.apache.james.CrowdsecPOP3IntegrationTest.initPOP3Server(CrowdsecPOP3IntegrationTest.java:127) at org.apache.james.CrowdsecPOP3IntegrationTest.finishSetUp(CrowdsecPOP3IntegrationTest.java:137) at org.apache.james.CrowdsecPOP3IntegrationTest.ipShouldBeBannedByCrowdSecWhenFailingToImapLoginThreeTimes(CrowdsecPOP3IntegrationTest.java:114) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[PR] JAMES-2586 Adopt Postgres 16.1 [james-project]
chibenwa opened a new pull request, #1897: URL: https://github.com/apache/james-project/pull/1897 Fixes several CVEs -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES 3897: CrowdsecImapConnectionCheck [james-project]
chibenwa commented on code in PR #1824: URL: https://github.com/apache/james-project/pull/1824#discussion_r1441458529 ## third-party/crowdsec/src/main/java/org/apache/james/CrowdsecImapConnectionCheck.java: ## @@ -0,0 +1,80 @@ +/ + * 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. * + / + +package org.apache.james; + +import static org.apache.james.model.CrowdsecClientConfiguration.DEFAULT_TIMEOUT; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeoutException; + +import javax.inject.Inject; + +import org.apache.commons.net.util.SubnetUtils; +import org.apache.james.exception.CrowdsecException; +import org.apache.james.imap.api.ConnectionCheck; +import org.apache.james.model.CrowdsecClientConfiguration; +import org.apache.james.model.CrowdsecDecision; +import org.apache.james.model.CrowdsecHttpClient; +import org.reactivestreams.Publisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import reactor.core.publisher.Mono; + +public class CrowdsecImapConnectionCheck implements ConnectionCheck { +private static final Logger LOGGER = LoggerFactory.getLogger(CrowdsecImapConnectionCheck.class); + +private final CrowdsecHttpClient client; + +@Inject +public CrowdsecImapConnectionCheck(CrowdsecClientConfiguration crowdsecClientConfiguration) { +this.client = new CrowdsecHttpClient(crowdsecClientConfiguration); +} + +@Override +public Publisher validate(InetSocketAddress remoteAddress) { +String ip = remoteAddress.getAddress().getHostAddress(); + +return client.getCrowdsecDecisions() Review Comment: IMO caching is overkill. Connection churn rate is very low for IMAP and SMTP so I expect no noticeable effect on performance. Caching brings possible inconsistencies and do not seem like strictly needed. However I would agree agressively lowering the timeout to say 500ms. If crowdsec do not answer in the given time then it would be ok to me to bypass it. Even better: make the timeout configurable. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES 3897: CrowdsecImapConnectionCheck [james-project]
vttranlina commented on code in PR #1824: URL: https://github.com/apache/james-project/pull/1824#discussion_r1441450598 ## third-party/crowdsec/src/main/java/org/apache/james/CrowdsecImapConnectionCheck.java: ## @@ -0,0 +1,80 @@ +/ + * 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. * + / + +package org.apache.james; + +import static org.apache.james.model.CrowdsecClientConfiguration.DEFAULT_TIMEOUT; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeoutException; + +import javax.inject.Inject; + +import org.apache.commons.net.util.SubnetUtils; +import org.apache.james.exception.CrowdsecException; +import org.apache.james.imap.api.ConnectionCheck; +import org.apache.james.model.CrowdsecClientConfiguration; +import org.apache.james.model.CrowdsecDecision; +import org.apache.james.model.CrowdsecHttpClient; +import org.reactivestreams.Publisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import reactor.core.publisher.Mono; + +public class CrowdsecImapConnectionCheck implements ConnectionCheck { +private static final Logger LOGGER = LoggerFactory.getLogger(CrowdsecImapConnectionCheck.class); + +private final CrowdsecHttpClient client; + +@Inject +public CrowdsecImapConnectionCheck(CrowdsecClientConfiguration crowdsecClientConfiguration) { +this.client = new CrowdsecHttpClient(crowdsecClientConfiguration); +} + +@Override +public Publisher validate(InetSocketAddress remoteAddress) { +String ip = remoteAddress.getAddress().getHostAddress(); + +return client.getCrowdsecDecisions() Review Comment: Cache example: https://github.com/apache/james-project/blob/eff08aed533af2cb79035a05d81e5d698de48979/server/container/guice/configuration/src/main/java/org/apache/james/utils/PropertiesProvider.java#L83 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
Re: [PR] JAMES 3897: CrowdsecImapConnectionCheck [james-project]
vttranlina commented on code in PR #1824: URL: https://github.com/apache/james-project/pull/1824#discussion_r1441410197 ## server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IpConnectionCheck.java: ## @@ -0,0 +1,47 @@ +/ + * 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. * + / + +package org.apache.james.imapserver.netty; + +import java.net.InetSocketAddress; +import java.util.Set; + +import org.apache.james.imap.api.ConnectionCheck; +import org.reactivestreams.Publisher; + +import reactor.core.publisher.Mono; + +public class IpConnectionCheck implements ConnectionCheck { +private Set bannedIps = Set.of(); + +@Override +public Publisher validate(InetSocketAddress remoteAddress) { +String ip = remoteAddress.getAddress().getHostAddress(); +// check against bannedIps +if (bannedIps.stream().anyMatch(bannedIp -> bannedIp.equals(ip))) { +return Mono.error(() -> new RuntimeException("Banned")); +} else { +return Mono.empty(); +} +} + +public void setBannedIps(Set bannedIps) { Review Comment: Not sure understand what logic but it looks a bit weird, The `bannedIps` should be immutable? ## server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServerFactory.java: ## @@ -36,37 +39,45 @@ import org.apache.james.protocols.lib.netty.AbstractServerFactory; import com.github.fge.lambdas.functions.ThrowingFunction; +import com.google.common.collect.ImmutableSet; public class IMAPServerFactory extends AbstractServerFactory { protected final FileSystem fileSystem; protected final ThrowingFunction, ImapSuite> imapSuiteProvider; protected final ImapMetrics imapMetrics; protected final GaugeRegistry gaugeRegistry; +protected final ConnectionCheckFactory connectionCheckFactory; @Inject @Deprecated public IMAPServerFactory(FileSystem fileSystem, ImapDecoder decoder, ImapEncoder encoder, ImapProcessor processor, - MetricFactory metricFactory, GaugeRegistry gaugeRegistry) { + MetricFactory metricFactory, GaugeRegistry gaugeRegistry, ConnectionCheckFactory connectionCheckFactory) { this.fileSystem = fileSystem; +this.connectionCheckFactory = connectionCheckFactory; this.imapSuiteProvider = any -> new ImapSuite(decoder, encoder, processor); this.imapMetrics = new ImapMetrics(metricFactory); this.gaugeRegistry = gaugeRegistry; } public IMAPServerFactory(FileSystem fileSystem, ThrowingFunction, ImapSuite> imapSuiteProvider, - MetricFactory metricFactory, GaugeRegistry gaugeRegistry) { + MetricFactory metricFactory, GaugeRegistry gaugeRegistry, ConnectionCheckFactory connectionCheckFactory) { this.fileSystem = fileSystem; this.imapSuiteProvider = imapSuiteProvider; this.imapMetrics = new ImapMetrics(metricFactory); this.gaugeRegistry = gaugeRegistry; +this.connectionCheckFactory = connectionCheckFactory; } protected IMAPServer createServer(HierarchicalConfiguration config) { ImapSuite imapSuite = imapSuiteProvider.apply(config); -return new IMAPServer(imapSuite.getDecoder(), imapSuite.getEncoder(), imapSuite.getProcessor(), imapMetrics, gaugeRegistry); +ImmutableSet connectionChecks = Arrays.stream(config.getStringArray("additionalConnectionChecks")).collect(ImmutableSet.toImmutableSet()); + +return new IMAPServer(imapSuite.getDecoder(), imapSuite.getEncoder(), imapSuite.getProcessor(), imapMetrics, gaugeRegistry, connectionCheckFactory.create(ImapConfiguration.builder() Review Comment: IMO ```