[GitHub] [james-project] Arsnael commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
Arsnael commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260543792 ## server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java: ## @@ -254,13 +279,21 @@ public ActionDTO getAction() { } public Rule toRule() { -return Rule.builder() +Rule.Builder ruleBuilder = Rule.builder() .id(Rule.Id.of(id)) .name(name) -.condition(conditionDTO.toCondition()) -.name(name) -.action(actionDTO.toAction()) -.build(); +.action(actionDTO.toAction()); + +if (conditionDTO != null) { +ruleBuilder.conditions(Arrays.asList(conditionDTO.toCondition())); +} else { + ruleBuilder.conditions(conditionDTOs.stream().map(ConditionDTO::toCondition).collect(Collectors.toList())); +} + +if (conditionCombiner != null) ruleBuilder.conditionCombiner(conditionCombiner); +else ruleBuilder.conditionCombiner(Rule.ConditionCombiner.AND); Review Comment: I think we could have kept the initial layout? Could extract the if else conditions to functions -- 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
[GitHub] [james-project] Arsnael commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
Arsnael commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260543247 ## server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java: ## @@ -254,13 +279,21 @@ public ActionDTO getAction() { } public Rule toRule() { -return Rule.builder() +Rule.Builder ruleBuilder = Rule.builder() .id(Rule.Id.of(id)) .name(name) -.condition(conditionDTO.toCondition()) -.name(name) -.action(actionDTO.toAction()) -.build(); +.action(actionDTO.toAction()); + +if (conditionDTO != null) { +ruleBuilder.conditions(Arrays.asList(conditionDTO.toCondition())); +} else { + ruleBuilder.conditions(conditionDTOs.stream().map(ConditionDTO::toCondition).collect(Collectors.toList())); +} + +if (conditionCombiner != null) ruleBuilder.conditionCombiner(conditionCombiner); +else ruleBuilder.conditionCombiner(Rule.ConditionCombiner.AND); Review Comment: No if else blocks like this, should be: ``` if (condition) { code } else { code } ``` better readability ## server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/mailet/filter/MailMatcher.java: ## @@ -51,27 +87,28 @@ private HeaderMatcher(ContentMatcher contentMatcher, String ruleValue, this.headerExtractor = headerExtractor; } -@Override -public boolean match(Mail mail) { -try { -Stream headerLines = headerExtractor.apply(mail); -return contentMatcher.match(headerLines, ruleValue); -} catch (Exception e) { -LOGGER.error("error while extracting mail header", e); -return false; -} +public ContentMatcher getContentMatcher() { +return contentMatcher; +} + +public String getRuleValue() { +return ruleValue; +} + +public HeaderExtractor getHeaderExtractor() { +return headerExtractor; } } static MailMatcher from(Rule rule) { -Condition ruleCondition = rule.getCondition(); -Optional maybeContentMatcher = ContentMatcher.asContentMatcher(ruleCondition.getField(), ruleCondition.getComparator()); -Optional maybeHeaderExtractor = HeaderExtractor.asHeaderExtractor(ruleCondition.getField()); - -return new HeaderMatcher( -maybeContentMatcher.orElseThrow(() -> new RuntimeException("No content matcher associated with field " + ruleCondition.getField())), -rule.getCondition().getValue(), -maybeHeaderExtractor.orElseThrow(() -> new RuntimeException("No content matcher associated with comparator " + ruleCondition.getComparator(; +return new HeaderMatcher(rule.getConditions().stream() +.map(ruleCondition -> new MailMatchingCondition( +ContentMatcher.asContentMatcher(ruleCondition.getField(), ruleCondition.getComparator()). Review Comment: the `.` at the end should be on the below line with `orEleseThrow` ## server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java: ## @@ -254,13 +279,21 @@ public ActionDTO getAction() { } public Rule toRule() { -return Rule.builder() +Rule.Builder ruleBuilder = Rule.builder() .id(Rule.Id.of(id)) .name(name) -.condition(conditionDTO.toCondition()) -.name(name) -.action(actionDTO.toAction()) -.build(); +.action(actionDTO.toAction()); + +if (conditionDTO != null) { +ruleBuilder.conditions(Arrays.asList(conditionDTO.toCondition())); +} else { + ruleBuilder.conditions(conditionDTOs.stream().map(ConditionDTO::toCondition).collect(Collectors.toList())); +} + +if (conditionCombiner != null) ruleBuilder.conditionCombiner(conditionCombiner); +else ruleBuilder.conditionCombiner(Rule.ConditionCombiner.AND); Review Comment: I think we could have kept the initial layout? Could extract the if else condition to functions ## server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java: ## @@ -215,22 +217,45 @@ public static ImmutableList from(List rules) { public static RuleDTO from(Rule rule) { return new RuleDTO(rule.getId().asString(), rule.getName(), -ConditionDTO.from(rule.getCondition()), + rule.getConditions().stream().map(ConditionDTO::from).collect(Collectors.toList()), +rule.getConditionCombiner(), ActionDTO.from(rule.getAction())); } private final String id; private final String
[GitHub] [james-project] chibenwa commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
chibenwa commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260535197 ## server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java: ## @@ -52,6 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat; Review Comment: No test with several conditions in here? -- 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
[GitHub] [james-project] chibenwa commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
chibenwa commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260534749 ## server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringExtension.java: ## @@ -112,7 +112,7 @@ public void defineRulesForRecipient1(List conditions) { .map(condition -> Rule.builder() .id(Rule.Id.of(String.valueOf(counter.incrementAndGet( .name(String.valueOf(counter.incrementAndGet())) -.condition(condition) +.conditions(Arrays.asList(condition)) Review Comment: `Arrays.asList` => `ImmutableList.of()` Guava is your friend, immutable collections is the good. -- 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
[GitHub] [james-project] chibenwa commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
chibenwa commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260534397 ## server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java: ## @@ -725,19 +726,19 @@ void mailDirectiveShouldSetLastMatchedRuleWhenMultipleRules(JMAPFilteringTestSys Rule.builder() .id(Rule.Id.of("1")) .name("rule 1") -.condition(Rule.Condition.of(SUBJECT, CONTAINS, UNSCRAMBLED_SUBJECT)) +.conditions(Arrays.asList(Rule.Condition.of(SUBJECT, CONTAINS, UNSCRAMBLED_SUBJECT))) Review Comment: We can keep a convenience method to build a rule with a single condition and avoid boiler plate. -- 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
[GitHub] [james-project] chibenwa commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
chibenwa commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260533746 ## server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/mailet/filter/MailMatcher.java: ## @@ -30,18 +33,51 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; public interface MailMatcher { class HeaderMatcher implements MailMatcher { private static final Logger LOGGER = LoggerFactory.getLogger(HeaderMatcher.class); +private List mailMatchingConditions; +private final Rule.ConditionCombiner conditionCombiner; + +private HeaderMatcher(List mailMatchingConditions, Rule.ConditionCombiner conditionCombiner) { +this.mailMatchingConditions = mailMatchingConditions; +this.conditionCombiner = conditionCombiner; +} + +@Override +public boolean match(Mail mail) { +try { +Predicate predicate = (MailMatchingCondition mailMatchingCondition) -> { +Stream headerLines = mailMatchingCondition.getHeaderExtractor().apply(mail); +return mailMatchingCondition.getContentMatcher().match(headerLines, mailMatchingCondition.getRuleValue()); +}; + +switch (conditionCombiner) { +case AND: +return mailMatchingConditions.stream().allMatch(predicate); +case OR: +return mailMatchingConditions.stream().anyMatch(predicate); +default: +return false; Review Comment: Explicitly throw on unmanaged cases? -- 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
[GitHub] [james-project] chibenwa commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
chibenwa commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260533417 ## server/data/data-jmap/src/main/java/org/apache/james/jmap/api/filtering/Rule.java: ## @@ -344,15 +350,22 @@ public static Builder builder() { return new Builder(); } +public enum ConditionCombiner { +AND, +OR +} + private final Id id; private final String name; -private final Condition condition; +private final List conditions; +private final ConditionCombiner conditionCombiner; private final Action action; -private Rule(Id id, String name, Condition condition, Action action) { +private Rule(Id id, String name, List conditions, ConditionCombiner conditionCombiner, Action action) { Review Comment: I would wrap conditions and combiner into its own distinct POJO: ``` class Conditions { ConditionCombiner conditionCombiner; List conditions; } ``` -- 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
[GitHub] [james-project] chibenwa commented on a diff in pull request #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
chibenwa commented on code in PR #1643: URL: https://github.com/apache/james-project/pull/1643#discussion_r1260532458 ## server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/filtering/RuleDTO.java: ## @@ -215,22 +217,45 @@ public static ImmutableList from(List rules) { public static RuleDTO from(Rule rule) { return new RuleDTO(rule.getId().asString(), rule.getName(), -ConditionDTO.from(rule.getCondition()), + rule.getConditions().stream().map(ConditionDTO::from).collect(Collectors.toList()), +rule.getConditionCombiner(), ActionDTO.from(rule.getAction())); } private final String id; private final String name; private final ConditionDTO conditionDTO; +private final List conditionDTOs; +private final Rule.ConditionCombiner conditionCombiner; private final ActionDTO actionDTO; +@JsonCreator +public RuleDTO(@JsonProperty("id") String id, + @JsonProperty("name") String name, + @JsonProperty("conditions") List conditionDTOs, + @JsonProperty("conditionCombiner") Rule.ConditionCombiner conditionCombiner, + @JsonProperty("action") ActionDTO actionDTO) { +this.name = name; +this.conditionDTO = null; +this.conditionDTOs = conditionDTOs; +this.conditionCombiner = conditionCombiner; +this.actionDTO = actionDTO; +Preconditions.checkNotNull(id); Review Comment: preconditions should go first -- 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 master updated (5a5db5f138 -> ec09fd59fd)
This is an automated email from the ASF dual-hosted git repository. rcordier pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git from 5a5db5f138 JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed add 1219894998 [EXAMPLE] Fix Thunderbird well-known auto-config file path add 4d32b79049 [EXAMPLE] Setup for Outlook auto-configuration add ec09fd59fd [EXAMPLE] Add Outlook auto configuration Demo and sample auto configuration file in the Docker image No new revisions were added by this update. Summary of changes: examples/imap-autoconf/README.adoc | 60 - .../{ => autoconfig}/mail/config-v1.1.xml | 0 .../content/autodiscover/autodiscover.xml | 30 +++ examples/imap-autoconf/outlook_enjoyAutoConfig.jpg | Bin 0 -> 31899 bytes .../imap-autoconf/outlook_enterMailAddress.jpg | Bin 0 -> 34666 bytes examples/imap-autoconf/outlook_enterPassword.jpg | Bin 0 -> 26802 bytes 6 files changed, 89 insertions(+), 1 deletion(-) rename examples/imap-autoconf/content/.well-known/{ => autoconfig}/mail/config-v1.1.xml (100%) create mode 100644 examples/imap-autoconf/content/autodiscover/autodiscover.xml create mode 100644 examples/imap-autoconf/outlook_enjoyAutoConfig.jpg create mode 100644 examples/imap-autoconf/outlook_enterMailAddress.jpg create mode 100644 examples/imap-autoconf/outlook_enterPassword.jpg - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[GitHub] [james-project] Arsnael merged pull request #1641: [EXAMPLE] Fix Thunderbird well-known auto-config file path
Arsnael merged PR #1641: URL: https://github.com/apache/james-project/pull/1641 -- 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
[GitHub] [james-project] hungphan227 opened a new pull request, #1643: DRAFT JAMES-4811 implement JMAP filtering: combine rule conditions
hungphan227 opened a new pull request, #1643: URL: https://github.com/apache/james-project/pull/1643 (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
[GitHub] [james-project] chibenwa opened a new pull request, #1642: JAMES-3920 backport on 3.8.x
chibenwa opened a new pull request, #1642: URL: https://github.com/apache/james-project/pull/1642 CF https://github.com/apache/james-project/pull/1627 -- 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: JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed
This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 5a5db5f138a3b22c4833d860e8017e6ac7af4c43 Author: Benoit Tellier AuthorDate: Tue Jul 4 00:29:53 2023 +0700 JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed --- .../test/java/org/apache/james/mailets/SPFIntegrationTests.java | 2 +- .../src/main/java/org/apache/james/transport/mailets/SPF.java| 9 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java index 3f1d71ff44..ebfdb0a2a5 100644 --- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java +++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java @@ -101,7 +101,7 @@ class SPFIntegrationTests { .addMailet(MailetConfiguration.builder() .matcher(All.class) .mailet(SPF.class) -.addProperty("checkLocalIps", "true")) +.addProperty("ignoreLocalIps", "false")) .addMailet(MailetConfiguration.builder() .matcher(HasMailAttributeWithValue.class) .matcherCondition("org.apache.james.transport.mailets.spf.result, softfail") diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java index d215a73591..a6d9e4e5c9 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java @@ -75,7 +75,7 @@ public class SPF extends GenericMailet { private boolean debug = false; private boolean addHeader = false; -private boolean ignoreLocalIps = false; +private boolean ignoreLocalIps = true; private org.apache.james.jspf.impl.SPF spf; public static final AttributeName EXPLANATION_ATTRIBUTE = AttributeName.of("org.apache.james.transport.mailets.spf.explanation"); public static final AttributeName RESULT_ATTRIBUTE = AttributeName.of("org.apache.james.transport.mailets.spf.result"); @@ -100,7 +100,7 @@ public class SPF extends GenericMailet { public void init() { debug = Boolean.parseBoolean(getInitParameter("debug", "false")); addHeader = Boolean.parseBoolean(getInitParameter("addHeader", "false")); -addHeader = Boolean.parseBoolean(getInitParameter("checkLocalIps", "false")); +ignoreLocalIps = Boolean.parseBoolean(getInitParameter("ignoreLocalIps", "true")); if (spfDnsService == null) { createSPF(new DNSServiceXBillImpl()); @@ -118,13 +118,14 @@ public class SPF extends GenericMailet { } private void createSPF(org.apache.james.jspf.core.DNSService dnsProbe) { +// TODO use once fixed AsynchronousSPFExecutor (see JAMES-3920) WiringServiceTable wiringService = new WiringServiceTable(); wiringService.put(DNSServiceEnabled.class, dnsProbe); MacroExpand macroExpand = new MacroExpand(dnsProbe); wiringService.put(MacroExpandEnabled.class, macroExpand); RFC4408SPF1Parser parser = new RFC4408SPF1Parser(new DefaultTermsFactory(wiringService)); SynchronousSPFExecutor executor = new SynchronousSPFExecutor(dnsProbe); -spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, macroExpand,executor ); +spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, macroExpand, executor); wiringService.put(SPFCheckEnabled.class, spf); } @@ -132,7 +133,7 @@ public class SPF extends GenericMailet { public void service(Mail mail) throws MessagingException { String remoteAddr = mail.getRemoteAddr(); -if (ignoreLocalIps || netMatcher.matchInetNetwork(remoteAddr)) { +if (ignoreLocalIps && netMatcher.matchInetNetwork(remoteAddr)) { LOGGER.debug("ignore SPF check for ip:{}", remoteAddr); } else { String helo = AttributeUtils.getValueAndCastFromMail(mail, Mail.SMTP_HELO, String.class).orElse(mail.getRemoteHost()); - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[james-project] 01/03: JAMES-3920 SPF integration test
This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit cf0897bff90cef3df94e483b648d1eb3eaabd30d Author: Benoit Tellier AuthorDate: Tue Jul 4 00:21:14 2023 +0700 JAMES-3920 SPF integration test Check gmail is recognised as spoofed --- .../apache/james/mailets/SPFIntegrationTests.java | 113 + .../org/apache/james/transport/mailets/SPF.java| 4 +- .../apache/james/transport/mailets/SPFTest.java| 21 ++-- 3 files changed, 123 insertions(+), 15 deletions(-) diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java new file mode 100644 index 00..3f1d71ff44 --- /dev/null +++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SPFIntegrationTests.java @@ -0,0 +1,113 @@ +/ + * 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.mailets; + +import static org.apache.james.mailets.configuration.CommonProcessors.ERROR_REPOSITORY; +import static org.apache.james.mailets.configuration.Constants.DEFAULT_DOMAIN; +import static org.apache.james.mailets.configuration.Constants.FROM; +import static org.apache.james.mailets.configuration.Constants.LOCALHOST_IP; +import static org.apache.james.mailets.configuration.Constants.PASSWORD; +import static org.apache.james.mailets.configuration.Constants.RECIPIENT; +import static org.apache.james.mailets.configuration.Constants.awaitAtMostOneMinute; + +import java.io.File; + +import org.apache.james.MemoryJamesServerMain; +import org.apache.james.mailbox.model.MailboxConstants; +import org.apache.james.mailets.configuration.CommonProcessors; +import org.apache.james.mailets.configuration.MailetConfiguration; +import org.apache.james.mailets.configuration.MailetContainer; +import org.apache.james.mailets.configuration.ProcessorConfiguration; +import org.apache.james.modules.MailboxProbeImpl; +import org.apache.james.modules.protocols.ImapGuiceProbe; +import org.apache.james.modules.protocols.SieveProbeImpl; +import org.apache.james.modules.protocols.SmtpGuiceProbe; +import org.apache.james.probe.DataProbe; +import org.apache.james.transport.mailets.SPF; +import org.apache.james.transport.mailets.ToRepository; +import org.apache.james.transport.matchers.All; +import org.apache.james.transport.matchers.HasMailAttribute; +import org.apache.james.transport.matchers.HasMailAttributeWithValue; +import org.apache.james.transport.matchers.SizeGreaterThan; +import org.apache.james.utils.DataProbeImpl; +import org.apache.james.utils.MailRepositoryProbeImpl; +import org.apache.james.utils.SMTPMessageSender; +import org.apache.james.utils.TestIMAPClient; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; + +class SPFIntegrationTests { +public static final String FROM = "u...@gmail.com"; +public static final String POSTMASTER = "postmaster@" + DEFAULT_DOMAIN; + +@RegisterExtension +public TestIMAPClient testIMAPClient = new TestIMAPClient(); +@RegisterExtension +public SMTPMessageSender messageSender = new SMTPMessageSender(DEFAULT_DOMAIN); + +private TemporaryJamesServer jamesServer; + +@BeforeEach +void setup(@TempDir File temporaryFolder) throws Exception { +jamesServer = TemporaryJamesServer.builder() +.withBase(MemoryJamesServerMain.SMTP_AND_IMAP_MODULE) +.withMailetContainer( +
[james-project] 02/03: JAMES-3920 Switch tu synchronous SPF executor
This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git commit 2dfe0ed14ba582a1c507f14f6d3cab531125d516 Author: Benoit Tellier AuthorDate: Tue Jul 4 00:23:06 2023 +0700 JAMES-3920 Switch tu synchronous SPF executor --- .../org/apache/james/transport/mailets/SPF.java| 25 +++--- .../apache/james/transport/mailets/SPFTest.java| 14 ++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java index 1bda369912..d215a73591 100644 --- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java +++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/SPF.java @@ -27,8 +27,16 @@ import javax.mail.internet.MimeMessage; import org.apache.james.dnsservice.api.DNSService; import org.apache.james.dnsservice.library.netmatcher.NetMatcher; +import org.apache.james.jspf.core.DNSServiceEnabled; +import org.apache.james.jspf.core.MacroExpand; +import org.apache.james.jspf.core.MacroExpandEnabled; +import org.apache.james.jspf.core.SPFCheckEnabled; import org.apache.james.jspf.executor.SPFResult; -import org.apache.james.jspf.impl.DefaultSPF; +import org.apache.james.jspf.executor.SynchronousSPFExecutor; +import org.apache.james.jspf.impl.DNSServiceXBillImpl; +import org.apache.james.jspf.impl.DefaultTermsFactory; +import org.apache.james.jspf.parser.RFC4408SPF1Parser; +import org.apache.james.jspf.wiring.WiringServiceTable; import org.apache.mailet.Attribute; import org.apache.mailet.AttributeName; import org.apache.mailet.AttributeUtils; @@ -95,9 +103,9 @@ public class SPF extends GenericMailet { addHeader = Boolean.parseBoolean(getInitParameter("checkLocalIps", "false")); if (spfDnsService == null) { -spf = new DefaultSPF(); +createSPF(new DNSServiceXBillImpl()); } else { -spf = new org.apache.james.jspf.impl.SPF(spfDnsService); +createSPF(spfDnsService); } Collection ignoredNetworks = Splitter.on(',') @@ -109,6 +117,17 @@ public class SPF extends GenericMailet { LOGGER.info("SPF addHeader={} debug={} ignoredNetworks={}", addHeader, debug, ignoredNetworks); } +private void createSPF(org.apache.james.jspf.core.DNSService dnsProbe) { +WiringServiceTable wiringService = new WiringServiceTable(); +wiringService.put(DNSServiceEnabled.class, dnsProbe); +MacroExpand macroExpand = new MacroExpand(dnsProbe); +wiringService.put(MacroExpandEnabled.class, macroExpand); +RFC4408SPF1Parser parser = new RFC4408SPF1Parser(new DefaultTermsFactory(wiringService)); +SynchronousSPFExecutor executor = new SynchronousSPFExecutor(dnsProbe); +spf = new org.apache.james.jspf.impl.SPF(dnsProbe, parser, macroExpand,executor ); +wiringService.put(SPFCheckEnabled.class, spf); +} + @Override public void service(Mail mail) throws MessagingException { String remoteAddr = mail.getRemoteAddr(); diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java index c7e378d731..688ac35187 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SPFTest.java @@ -60,7 +60,7 @@ public class SPFTest { @BeforeAll public static void setupMockedSPFDNSService() throws TimeoutException { mockedSPFDNSService = mock(org.apache.james.jspf.core.DNSService.class); -when(mockedSPFDNSService.getRecordsAsync(any(DNSRequest.class))) +when(mockedSPFDNSService.getRecords(any(DNSRequest.class))) .thenAnswer(invocation -> { DNSRequest req = invocation.getArgument(0); switch (req.getRecordType()) { @@ -69,26 +69,26 @@ public class SPFTest { List l = new ArrayList<>(); switch (req.getHostname()) { case "some.host.local": -return CompletableFuture.completedFuture(l); +return l; case "spf1.james.apache.org": // pass l.add("v=spf1 +all"); -return CompletableFuture.completedFuture(l); +return l; case "spf2.james.apache.org": // fail l.add("v=spf1 -all"); -
[james-project] branch master updated (92353c9144 -> 5a5db5f138)
This is an automated email from the ASF dual-hosted git repository. btellier pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git from 92353c9144 Register the DNSPublicKeyRecordRetriever bean so the DKIMVerify mailet works correctly (#1638) new cf0897bff9 JAMES-3920 SPF integration test new 2dfe0ed14b JAMES-3920 Switch tu synchronous SPF executor new 5a5db5f138 JAMES-3920 Add todo once AsynchronousSPFExecutor is fixed 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: ...tegrationTest.java => SPFIntegrationTests.java} | 57 ++ .../org/apache/james/transport/mailets/SPF.java| 30 ++-- .../apache/james/transport/mailets/SPFTest.java| 35 ++--- 3 files changed, 67 insertions(+), 55 deletions(-) copy server/mailet/integration-testing/src/test/java/org/apache/james/mailets/{SizeGreaterThanIntegrationTest.java => SPFIntegrationTests.java} (73%) - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[GitHub] [james-project] chibenwa merged pull request #1627: JAMES-3920 Integration test for SPF + temporary fix
chibenwa merged PR #1627: URL: https://github.com/apache/james-project/pull/1627 -- 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 master updated: Register the DNSPublicKeyRecordRetriever bean so the DKIMVerify mailet works correctly (#1638)
This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git The following commit(s) were added to refs/heads/master by this push: new 92353c9144 Register the DNSPublicKeyRecordRetriever bean so the DKIMVerify mailet works correctly (#1638) 92353c9144 is described below commit 92353c914487cc1420a22089939a91e0fc4d318a Author: asdfjkluiop <47774017+asdfjklu...@users.noreply.github.com> AuthorDate: Tue Jul 11 02:32:46 2023 -0700 Register the DNSPublicKeyRecordRetriever bean so the DKIMVerify mailet works correctly (#1638) Co-authored-by: Scoopta --- .../main/resources/META-INF/org/apache/james/spring-server.xml| 8 1 file changed, 8 insertions(+) diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml index 9165e0b055..7e68e89591 100644 --- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml +++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml @@ -315,4 +315,12 @@ + + + + - To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org
[GitHub] [james-project] chibenwa merged pull request #1638: Register the DNSPublicKeyRecordRetriever bean
chibenwa merged PR #1638: URL: https://github.com/apache/james-project/pull/1638 -- 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
[GitHub] [james-project] Arsnael commented on pull request #1623: JAMES-3924 RabbitMQ mail queue updates: not performed
Arsnael commented on PR #1623: URL: https://github.com/apache/james-project/pull/1623#issuecomment-1630406214 > Or add a check to avoid the NPE... That maybe avoids the NPE but I don't see how it's fixing the test? Also you didn't really answer my questions and concerns on why you want to dispose the mail object here? Your test is trying to check with dedup that if we dequeue two identical mails (subject + content) we check we dequeue two emails, and checking they have the same mime message content... But because of the dispose the content has been disposed of. Seeing also as we deliver those mails after dequeing them, does it mean we send them without content then? As I said above, I'm not sure I understood well that part of the code, so a bit more detailed answer would be appreciated. -- 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
[GitHub] [james-project] chibenwa commented on a diff in pull request #1641: [EXAMPLE] Fix Thunderbird well-known auto-config file path
chibenwa commented on code in PR #1641: URL: https://github.com/apache/james-project/pull/1641#discussion_r1259400946 ## examples/imap-autoconf/README.adoc: ## @@ -83,4 +83,45 @@ docker exec -ti james james-cli Adduser b...@domain.tld 123456 - 4. Start Thunderbird and enjoy auto-configuration! -image:thunderbird_autoconf.png[Auto-configuration was applied in Thunderbird] \ No newline at end of file +image:thunderbird_autoconf.png[Auto-configuration was applied in Thunderbird] + +== Outlook Review Comment: Can we have this as a docker in the docker compose too? -- 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
[GitHub] [james-project] chibenwa commented on a diff in pull request #1641: [EXAMPLE] Fix Thunderbird well-known auto-config file path
chibenwa commented on code in PR #1641: URL: https://github.com/apache/james-project/pull/1641#discussion_r1259400946 ## examples/imap-autoconf/README.adoc: ## @@ -83,4 +83,45 @@ docker exec -ti james james-cli Adduser b...@domain.tld 123456 - 4. Start Thunderbird and enjoy auto-configuration! -image:thunderbird_autoconf.png[Auto-configuration was applied in Thunderbird] \ No newline at end of file +image:thunderbird_autoconf.png[Auto-configuration was applied in Thunderbird] + +== Outlook Review Comment: Can we have this as a docker in the docker compose too? (so that package is done) -- 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
[GitHub] [james-project] chibenwa commented on pull request #1623: JAMES-3924 RabbitMQ mail queue updates: not performed
chibenwa commented on PR #1623: URL: https://github.com/apache/james-project/pull/1623#issuecomment-1630390970 > Here when we dequeue you trying to dispose of the mail item right away. So in the test of course when you trying to access the content of it, it returns a NPE. Seeing as well how the mail item is trying to be delivered after being dequeued in theJamesMailSpooler for example, I'm not sure we want to do a dispose here. I think we should revert this commit, but maybe I misunderstood sth? Or add a check to avoid the NPE... -- 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
[GitHub] [james-project] chibenwa commented on pull request #1627: JAMES-3920 Integration test for SPF + temporary fix
chibenwa commented on PR #1627: URL: https://github.com/apache/james-project/pull/1627#issuecomment-1630389598 Rebased to squash the fixup -- 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
[GitHub] [james-project] Arsnael commented on pull request #1641: [EXAMPLE] Fix Thunderbird well-known auto-config file path
Arsnael commented on PR #1641: URL: https://github.com/apache/james-project/pull/1641#issuecomment-1630387407 > Any chance to get a demo of outlook auto-conf You mean this posted an hour ago? :) => https://github.com/linagora/james-project/issues/4809#issuecomment-1630304266 -- 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
[GitHub] [james-project] Arsnael commented on pull request #1623: JAMES-3924 RabbitMQ mail queue updates: not performed
Arsnael commented on PR #1623: URL: https://github.com/apache/james-project/pull/1623#issuecomment-1630376345 I'm not an expert with the browse start and dequeue, but from what I can observe, there is two issues: - `dequeueShouldStillRetrieveAllBlobsWhenIdenticalContentAndDeduplication` (reported by the CI). Provoked by https://github.com/apache/james-project/pull/1623/commits/0ef98d2fccc0420df6b6be68ca3cb58a7f1b3621 . Here when we dequeue you trying to dispose of the mail item right away. So in the test of course when you trying to access the content of it, it returns a NPE. Seeing as well how the mail item is trying to be delivered after being dequeued in theJamesMailSpooler for example, I'm not sure we want to do a dispose here. I think we should revert this commit, but maybe I misunderstood sth? - `MailQueueSizeMetricsEnabled` nested tests seem rather unstable, at least on my local (maybe @quantranhong1999 can double check this). Sometimes it's green, and sometimes some tests are failing, but seems rather random. -- 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 master updated: JAMES-2600 implement an object storage healthcheck (#1637)
This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git The following commit(s) were added to refs/heads/master by this push: new 63740a8efd JAMES-2600 implement an object storage healthcheck (#1637) 63740a8efd is described below commit 63740a8efd739fcdc9b040e1e2a6fb7a8e9cd519 Author: hungphan227 <45198168+hungphan...@users.noreply.github.com> AuthorDate: Tue Jul 11 14:23:01 2023 +0700 JAMES-2600 implement an object storage healthcheck (#1637) --- server/blob/blob-api/pom.xml | 8 +++ .../james/blob/api/ObjectStorageHealthCheck.java | 59 .../objectstorage/aws/DockerAwsS3Container.java| 15 .../blob/objectstorage/aws/S3HealthCheckTest.java | 82 ++ server/container/guice/distributed/pom.xml | 4 ++ .../modules/blobstore/BlobStoreModulesChooser.java | 4 ++ ...itMQWebAdminServerIntegrationImmutableTest.java | 2 +- 7 files changed, 173 insertions(+), 1 deletion(-) diff --git a/server/blob/blob-api/pom.xml b/server/blob/blob-api/pom.xml index 8c779e796f..5613a52e17 100644 --- a/server/blob/blob-api/pom.xml +++ b/server/blob/blob-api/pom.xml @@ -33,6 +33,10 @@ Apache James :: Server :: Blob :: API + +${james.groupId} +james-core + ${james.groupId} james-server-util @@ -61,6 +65,10 @@ commons-io test + +io.projectreactor.addons +reactor-extra + javax.inject javax.inject diff --git a/server/blob/blob-api/src/main/java/org/apache/james/blob/api/ObjectStorageHealthCheck.java b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/ObjectStorageHealthCheck.java new file mode 100644 index 00..555c1d5fed --- /dev/null +++ b/server/blob/blob-api/src/main/java/org/apache/james/blob/api/ObjectStorageHealthCheck.java @@ -0,0 +1,59 @@ +/ + * 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.blob.api; + +import java.time.Duration; + +import javax.inject.Inject; + +import org.apache.james.core.healthcheck.ComponentName; +import org.apache.james.core.healthcheck.HealthCheck; +import org.apache.james.core.healthcheck.Result; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class ObjectStorageHealthCheck implements HealthCheck { + +private static final Integer HEALTH_CHECK_TIMEOUT = 10; + +private static final ComponentName COMPONENT_NAME = new ComponentName("ObjectStorage"); + +private final BlobStoreDAO blobStoreDAO; + +@Inject +public ObjectStorageHealthCheck(BlobStoreDAO blobStoreDAO) { +this.blobStoreDAO = blobStoreDAO; +} + +@Override +public ComponentName componentName() { +return COMPONENT_NAME; +} + +@Override +public Mono check() { +return Flux.from(blobStoreDAO.listBuckets()) +.timeout(Duration.ofSeconds(HEALTH_CHECK_TIMEOUT)) +.next() +.thenReturn(Result.healthy(COMPONENT_NAME)) +.onErrorResume(e -> Mono.just(Result.unhealthy(COMPONENT_NAME, "Error checking ObjectSotrage", e))); +} +} diff --git a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/DockerAwsS3Container.java b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/DockerAwsS3Container.java index 98e0e8070b..d47469054c 100644 --- a/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/DockerAwsS3Container.java +++ b/server/blob/blob-s3/src/test/java/org/apache/james/blob/objectstorage/aws/DockerAwsS3Container.java @@ -61,6 +61,21 @@ public
[GitHub] [james-project] chibenwa merged pull request #1637: James 2600 implement an object storage healthcheck
chibenwa merged PR #1637: URL: https://github.com/apache/james-project/pull/1637 -- 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