Skip to content

Commit b96f9e0

Browse files
committed
Fix #227: Add msal library to installation
1 parent 4f058d4 commit b96f9e0

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

Dockerfile

-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=var-cache-
2626
--mount=type=tmpfs,target=/tmp \
2727
--mount=type=bind,from=build-scripts,source=/build-scripts,target=/build-scripts \
2828
sh /build-scripts/postfix-install.sh
29-
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=var-cache-apt-$TARGETPLATFORM \
30-
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=var-lib-apt-$TARGETPLATFORM \
31-
--mount=type=tmpfs,target=/var/cache/apk \
32-
--mount=type=tmpfs,target=/tmp \
33-
--mount=type=bind,from=build-scripts,source=/build-scripts,target=/build-scripts \
34-
python3 -m pip3 install msal
3529

3630
# ============================ BUILD SASL XOAUTH2 ============================
3731
FROM base AS sasl

build-scripts/postfix-install.sh

+12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ do_alpine() {
3434
musl-utils \
3535
netcat-openbsd \
3636
opendkim-utils \
37+
python3 \
38+
py3-pip
3739
rsyslog \
3840
supervisor \
3941
tzdata
@@ -80,12 +82,15 @@ do_ubuntu() {
8082
opendkim-tools \
8183
postfix-lmdb \
8284
procps \
85+
python3 \
86+
python3-pip \
8387
rsyslog \
8488
sasl2-bin \
8589
supervisor \
8690
tzdata
8791
apt-get clean
8892
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
93+
8994
}
9095

9196
if [ -f /etc/alpine-release ]; then
@@ -94,6 +99,13 @@ else
9499
do_ubuntu
95100
fi
96101

102+
# masl is needed for the sasl-xoauth2-tool.
103+
PIP=pip
104+
if command -v pip3 > /dev/null 2>&1; then
105+
PIP=pip3
106+
fi
107+
$PIP install --break-system-packages msal
108+
97109
# Some services (eg. cron) will complain if this file does not exists, even if it's empty.
98110
# The file is usually generated by update-locales, which is ran automatically when you do
99111
# `apt-get install locales`. So instead of adding another package, which at the moment we

scripts/email-anonymizer.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
5-
Filter to anonyimize email addresses. It reads input line by line,
5+
Filter to anonymize email addresses. It reads input line by line,
66
finds all emails in the input and masks them using given filter.
77
88
Big thanks to [Sergio Del Río Mayoral](https://github.com/sdelrio)
@@ -26,8 +26,8 @@
2626
# BIG FAT NOTICE on emails and regular expressions:
2727
# If you're planning on using a regular expression to validate an email: don't. Emails
2828
# are much more complex than you would imagine and most regular expressions will not
29-
# cover all usecases. Newer RFCs even allow for international (read: UTF-8) email addresses.
30-
# Most of your favourite programming languages will have a dedicated library for validating
29+
# cover all use cases. Newer RFCs even allow for international (read: UTF-8) email addresses.
30+
# Most of your favorite programming languages will have a dedicated library for validating
3131
# addresses.
3232
#
3333
# This pattern below, should, however match anything that remotely looks like an email.
@@ -85,7 +85,7 @@ def is_message_id(self, match: re.match, msg: str) -> bool:
8585
start = match.start()
8686
email = match.group()
8787

88-
# Note that our regex will match thigs like "message-id=Issue1649523226559@postfix-mail.mail-system.svc.cluster.local"
88+
# Note that our regex will match things like "message-id=Issue1649523226559@postfix-mail.mail-system.svc.cluster.local"
8989
# so we need to filter / check for these first
9090

9191
if email.startswith(self.MESSAGE_ID_LINE):
@@ -123,9 +123,9 @@ def processMessage(self, msg: str) -> typing.Optional[str]:
123123
"""
124124
This filter will take an educated guess at how to best mask the emails, specifically:
125125
126-
* It will leave the first and the last letter of the local part (if it's oly one letter, it will get repated)
126+
* It will leave the first and the last letter of the local part (if it's oly one letter, it will get repeated)
127127
* If the local part is in quotes, it will remove the quotes (Warning: if the email starts with a space, this might look weird in logs)
128-
* It will replace all the letters inbetween with **ONE** asterisk
128+
* It will replace all the letters in between with **ONE** asterisk
129129
* It will replace everything but a TLD with a star
130130
* Address-style domains will see the number replaced with stars
131131

0 commit comments

Comments
 (0)