Skip to content

Commit 7b4ceb5

Browse files
committed
Extract TLS requiretls feature data from 'postfix_tls'
Also switch to named captures when possible
1 parent 44172d9 commit 7b4ceb5

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

50-filter-postfix.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ filter {
299299
]
300300
gsub => [
301301
# rewrite some extracted values
302-
"postfix_tls_policy_undecided", "\?", "true"
302+
"postfix_tls_policy_undecided", "\?", "true",
303+
"postfix_tls_requiretls_undecided", "\?", "true",
304+
"postfix_tls_requiretls_policy_violation", "\!", "true",
305+
"postfix_tls_requiretls", "requiretls", "true"
303306
]
304307
}
305308
}

postfix.grok

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ POSTFIX_VERIFY_CACHE cache %{DATA} (?<postfix_verify_cleanup_type>(full|partial)
122122
POSTFIX_LOCAL_DELIVERY %{POSTFIX_KEYVALUE} status=%{STATUS_WORD:postfix_status}( \(%{GREEDYDATA:postfix_local_response}\))?
123123

124124
# TLS features
125-
POSTFIX_TLS_POLICY_UNDECIDED \?
126-
POSTFIX_TLS_FEATURES %{STATUS_WORD:postfix_tls_security_level}(:%{STATUS_WORD:postfix_tls_downgrade_level})?(%{POSTFIX_TLS_POLICY_UNDECIDED:postfix_tls_policy_undecided})?
125+
POSTFIX_TLS_FEAT_REQUIRETLS (?<postfix_tls_requiretls_policy_violation>\!)?(?<postfix_tls_requiretls>requiretls)(:%{STATUS_WORD:postfix_tls_requiretls_downgrade_level})?(?<postfix_tls_requiretls_undecided>\?)?
126+
POSTFIX_TLS_FEATURES %{STATUS_WORD:postfix_tls_security_level}(:%{STATUS_WORD:postfix_tls_downgrade_level})?(?<postfix_tls_policy_undecided>\?)?(/%{POSTFIX_TLS_FEAT_REQUIRETLS})?
127127

128128
# aggregate all patterns
129129
POSTFIX_SMTPD %{POSTFIX_SMTPD_CONNECT}|%{POSTFIX_SMTPD_DISCONNECT}|%{POSTFIX_SMTPD_LOSTCONN}|%{POSTFIX_SMTPD_NOQUEUE}|%{POSTFIX_SMTPD_PIPELINING}|%{POSTFIX_TLSCONN}|%{POSTFIX_WARNING}|%{POSTFIX_SMTPD_PROXY}|%{POSTFIX_KEYVALUE}

test/tls_features_0010.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pattern: "^%{POSTFIX_TLS_FEATURES}$"
2+
data: "dane/requiretls"
3+
results:
4+
postfix_tls_security_level: dane
5+
postfix_tls_requiretls: requiretls

test/tls_features_0011.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pattern: "^%{POSTFIX_TLS_FEATURES}$"
2+
data: "dane/requiretls?"
3+
results:
4+
postfix_tls_security_level: dane
5+
postfix_tls_requiretls: requiretls
6+
postfix_tls_requiretls_undecided: "?"

test/tls_features_0012.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pattern: "^%{POSTFIX_TLS_FEATURES}$"
2+
data: "dane/!requiretls:nostarttls"
3+
results:
4+
postfix_tls_security_level: dane
5+
postfix_tls_requiretls: requiretls
6+
postfix_tls_requiretls_policy_violation: "!"
7+
postfix_tls_requiretls_downgrade_level: nostarttls

test_pipeline.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ perform_cleanup() {
2323
trap perform_cleanup INT TERM
2424

2525
echo Preparing input data
26-
echo "postfix/smtp[123]: 7EE668039: to=<admin@example.com>, relay=127.0.0.1[127.0.0.1]:2525, delay=3.6, delays=0.2/0.02/0.04/3.3, dsn=2.0.0, tls=dane?, status=sent (250 2.0.0 Ok: queued as 153053D)" > "$INPUT"
26+
echo "postfix/smtp[123]: 7EE668039: to=<admin@example.com>, relay=127.0.0.1[127.0.0.1]:2525, delay=3.6, delays=0.2/0.02/0.04/3.3, dsn=2.0.0, tls=dane/!requiretls:nostarttls, status=sent (250 2.0.0 Ok: queued as 153053D)" > "$INPUT"
2727

2828
echo Preparing pipeline config
2929
cat > "$PIPELINE" << EOF

0 commit comments

Comments
 (0)