From 2b6daf6157a681a44e297a18f798e300245dd59e Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 19 Jun 2024 14:37:26 +0200 Subject: [PATCH 1/6] fix warnings --- core/admin/mailu/internal/views/postfix.py | 4 ++-- core/admin/mailu/ui/forms.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/admin/mailu/internal/views/postfix.py b/core/admin/mailu/internal/views/postfix.py index cc8a0950..c2399cf7 100644 --- a/core/admin/mailu/internal/views/postfix.py +++ b/core/admin/mailu/internal/views/postfix.py @@ -14,7 +14,7 @@ def postfix_dane_map(domain_name): @internal.route("/postfix/domain/") def postfix_mailbox_domain(domain_name): - if re.match("^\[.*\]$", domain_name): + if re.match(r'^\[.*\]$', domain_name): return flask.abort(404) domain = models.Domain.query.get(domain_name) or \ models.Alternative.query.get(domain_name) or \ @@ -39,7 +39,7 @@ def postfix_alias_map(alias): @internal.route("/postfix/transport/") def postfix_transport(email): - if email == '*' or re.match("(^|.*@)\[.*\]$", email): + if email == '*' or re.match(r'(^|.*@)\[.*\]$', email): return flask.abort(404) _, domain_name = models.Email.resolve_domain(email) relay = models.Relay.query.get(domain_name) or flask.abort(404) diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py index b6c45189..798bd923 100644 --- a/core/admin/mailu/ui/forms.py +++ b/core/admin/mailu/ui/forms.py @@ -7,7 +7,7 @@ import flask_wtf import re import ipaddress -LOCALPART_REGEX = "^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*$" +LOCALPART_REGEX = r'^[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+)*$' class DestinationField(fields.SelectMultipleField): """ Allow for multiple emails selection from current user choices and From cfd7e6b6908f3e00e232191dd4797c9b11561125 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 19 Jun 2024 14:50:09 +0200 Subject: [PATCH 2/6] fix warnings again --- docs/compose/docker-compose.yml | 1 - docs/docker-compose.yml | 1 - setup/docker-compose.yml | 1 - setup/flavors/compose/docker-compose.yml | 2 -- tests/compose/api/docker-compose.yml | 1 - tests/compose/core/docker-compose.yml | 1 - tests/compose/fetchmail/docker-compose.yml | 1 - tests/compose/filters/docker-compose.yml | 1 - tests/compose/webdav/docker-compose.yml | 1 - tests/compose/webmail/docker-compose.yml | 1 - 10 files changed, 11 deletions(-) diff --git a/docs/compose/docker-compose.yml b/docs/compose/docker-compose.yml index 3b964449..4c997c4c 100644 --- a/docs/compose/docker-compose.yml +++ b/docs/compose/docker-compose.yml @@ -1,6 +1,5 @@ # WARNING: this file is being deprecated over the new setup utility, found at https://setup.mailu.io -version: '2' services: diff --git a/docs/docker-compose.yml b/docs/docker-compose.yml index 9c5d2473..eccc14a1 100644 --- a/docs/docker-compose.yml +++ b/docs/docker-compose.yml @@ -1,7 +1,6 @@ # This file is used to test the mailu/docs website # Deployment files can be found on github.com/mailu/infra -version: '3' services: docs: diff --git a/setup/docker-compose.yml b/setup/docker-compose.yml index 9c93fd6f..680dd9ab 100644 --- a/setup/docker-compose.yml +++ b/setup/docker-compose.yml @@ -1,7 +1,6 @@ # This file is used to test the mailu/setup utility # Deployment files can be found on github.com/mailu/infra -version: '3.6' services: redis: diff --git a/setup/flavors/compose/docker-compose.yml b/setup/flavors/compose/docker-compose.yml index 8cd374cd..3eeba1d4 100644 --- a/setup/flavors/compose/docker-compose.yml +++ b/setup/flavors/compose/docker-compose.yml @@ -3,8 +3,6 @@ # Please read the documentation before attempting any change. # Generated for {{ flavor }} flavor -version: '2.2' - services: # External dependencies diff --git a/tests/compose/api/docker-compose.yml b/tests/compose/api/docker-compose.yml index 384e89cd..03879edb 100644 --- a/tests/compose/api/docker-compose.yml +++ b/tests/compose/api/docker-compose.yml @@ -2,7 +2,6 @@ # Please read the documentation before attempting any change. # Generated for compose flavor -version: '3.6' services: diff --git a/tests/compose/core/docker-compose.yml b/tests/compose/core/docker-compose.yml index 384e89cd..03879edb 100644 --- a/tests/compose/core/docker-compose.yml +++ b/tests/compose/core/docker-compose.yml @@ -2,7 +2,6 @@ # Please read the documentation before attempting any change. # Generated for compose flavor -version: '3.6' services: diff --git a/tests/compose/fetchmail/docker-compose.yml b/tests/compose/fetchmail/docker-compose.yml index 067532fa..edd4140e 100644 --- a/tests/compose/fetchmail/docker-compose.yml +++ b/tests/compose/fetchmail/docker-compose.yml @@ -2,7 +2,6 @@ # Please read the documentation before attempting any change. # Generated for compose flavor -version: '3.6' services: diff --git a/tests/compose/filters/docker-compose.yml b/tests/compose/filters/docker-compose.yml index 5a508d58..2d2562a4 100644 --- a/tests/compose/filters/docker-compose.yml +++ b/tests/compose/filters/docker-compose.yml @@ -2,7 +2,6 @@ # Please read the documentation before attempting any change. # Generated for compose flavor -version: '3.6' services: diff --git a/tests/compose/webdav/docker-compose.yml b/tests/compose/webdav/docker-compose.yml index 1391b68d..78bce9d7 100644 --- a/tests/compose/webdav/docker-compose.yml +++ b/tests/compose/webdav/docker-compose.yml @@ -2,7 +2,6 @@ # Please read the documentation before attempting any change. # Generated for compose flavor -version: '3.6' services: diff --git a/tests/compose/webmail/docker-compose.yml b/tests/compose/webmail/docker-compose.yml index d61621d3..0fdc3e5f 100644 --- a/tests/compose/webmail/docker-compose.yml +++ b/tests/compose/webmail/docker-compose.yml @@ -2,7 +2,6 @@ # Please read the documentation before attempting any change. # Generated for compose flavor -version: '3.6' services: From 12c1affc05304a8b058afbceacac441a7462fc94 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 19 Jun 2024 14:52:43 +0200 Subject: [PATCH 3/6] remove another warning ERROR:root:Not sure what to do with in PROXY_PROTOCOL (None) --- core/nginx/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/nginx/config.py b/core/nginx/config.py index 1f06424b..0044772e 100755 --- a/core/nginx/config.py +++ b/core/nginx/config.py @@ -76,7 +76,7 @@ PROTO_ALL_BUT_HTTP=PROTO_MAIL.copy() PROTO_ALL_BUT_HTTP.extend(['443']) PROTO_ALL=PROTO_ALL_BUT_HTTP.copy() PROTO_ALL.extend(['80']) -for item in args.get('PROXY_PROTOCOL', '').split(','): +for item in args.get('PROXY_PROTOCOL', None).split(','): if item.isdigit(): args[f'PROXY_PROTOCOL_{item}']=True elif item == 'mail': From e9db8c4509638bfad65c78fc41a09c036b191afa Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 19 Jun 2024 14:54:57 +0200 Subject: [PATCH 4/6] another one nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/nginx.conf:90 --- core/nginx/conf/nginx.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index e7d4885e..60c263a9 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -104,9 +104,10 @@ http { # Only enable HTTPS if TLS is enabled with no error {% if TLS_443 and not TLS_ERROR %} - listen 443 ssl http2{% if PROXY_PROTOCOL_443 %} proxy_protocol{% endif %}; + listen 443 ssl{% if PROXY_PROTOCOL_443 %} proxy_protocol{% endif %}; {% if SUBNET6 %} - listen [::]:443 ssl http2{% if PROXY_PROTOCOL_443 %} proxy_protocol{% endif %}; + listen [::]:443 ssl{% if PROXY_PROTOCOL_443 %} proxy_protocol{% endif %}; + http2 on; {% endif %} include /etc/nginx/tls.conf; From c0d0dcf71377b639d8c83421c830cd6d69ebec4d Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 19 Jun 2024 14:58:34 +0200 Subject: [PATCH 5/6] another --- core/base/libs/socrate/socrate/system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base/libs/socrate/socrate/system.py b/core/base/libs/socrate/socrate/system.py index 3dcdea3d..fe233a5b 100644 --- a/core/base/libs/socrate/socrate/system.py +++ b/core/base/libs/socrate/socrate/system.py @@ -33,7 +33,7 @@ class LogFilter(object): def __init__(self, stream, re_patterns): self.stream = stream if isinstance(re_patterns, list): - self.pattern = re.compile('|'.join([f'(?:{pattern})' for pattern in re_patterns])) + self.pattern = re.compile('|'.join([fr'(?:{pattern})' for pattern in re_patterns])) elif isinstance(re_patterns, str): self.pattern = re.compile(re_patterns) else: From 89ff26660f5bf0b54cdda0d519934f4d96f27be8 Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Wed, 19 Jun 2024 15:35:44 +0200 Subject: [PATCH 6/6] better --- core/nginx/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/nginx/config.py b/core/nginx/config.py index 0044772e..4a381c2c 100755 --- a/core/nginx/config.py +++ b/core/nginx/config.py @@ -76,7 +76,7 @@ PROTO_ALL_BUT_HTTP=PROTO_MAIL.copy() PROTO_ALL_BUT_HTTP.extend(['443']) PROTO_ALL=PROTO_ALL_BUT_HTTP.copy() PROTO_ALL.extend(['80']) -for item in args.get('PROXY_PROTOCOL', None).split(','): +for item in args.get('PROXY_PROTOCOL', '').split(','): if item.isdigit(): args[f'PROXY_PROTOCOL_{item}']=True elif item == 'mail': @@ -85,6 +85,8 @@ for item in args.get('PROXY_PROTOCOL', None).split(','): for p in PROTO_ALL_BUT_HTTP: args[f'PROXY_PROTOCOL_{p}']=True elif item == 'all': for p in PROTO_ALL: args[f'PROXY_PROTOCOL_{p}']=True + elif item == '': + pass else: log.error(f'Not sure what to do with {item} in PROXY_PROTOCOL ({args.get("PROXY_PROTOCOL")})')