From f5e04dd2aa248e3b1475fe81720616e68c4eb9e9 Mon Sep 17 00:00:00 2001 From: visi Date: Wed, 14 Feb 2024 10:37:23 -0500 Subject: [PATCH] Add received:from:ipv4/ipv6/fqdn to inet:email:message --- synapse/models/inet.py | 9 +++++++++ synapse/tests/test_model_inet.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/synapse/models/inet.py b/synapse/models/inet.py index 36fa1e1e08..731cd24fc1 100644 --- a/synapse/models/inet.py +++ b/synapse/models/inet.py @@ -1560,6 +1560,15 @@ def getModelDefs(self): ('headers', ('array', {'type': 'inet:email:header'}), { 'doc': 'An array of email headers from the message.'}), + ('received:from:ipv4', ('inet:ipv4', {}), { + 'doc': 'The sending SMTP server IPv4, potentially from the Received: header.'}), + + ('received:from:ipv6', ('inet:ipv6', {}), { + 'doc': 'The sending SMTP server IPv6, potentially from the Received: header.'}), + + ('received:from:fqdn', ('inet:fqdn', {}), { + 'doc': 'The sending server FQDN, potentially from the Received: header.'}), + )), ('inet:email:header', {}, ( diff --git a/synapse/tests/test_model_inet.py b/synapse/tests/test_model_inet.py index 1d774a0f62..446a1c7239 100644 --- a/synapse/tests/test_model_inet.py +++ b/synapse/tests/test_model_inet.py @@ -2662,6 +2662,9 @@ async def test_model_inet_email_message(self): :headers=(('to', 'Visi Stark '),) :cc=(baz@faz.org, foo@bar.com, baz@faz.org) :bytes="*" + :received:from:ipv4=1.2.3.4 + :received:from:ipv6="::1" + :received:from:fqdn=smtp.vertex.link ] {[( inet:email:message:link=($node, https://www.vertex.link) :text=Vertex )]} @@ -2671,6 +2674,9 @@ async def test_model_inet_email_message(self): self.len(1, nodes) self.eq(nodes[0].get('cc'), ('baz@faz.org', 'foo@bar.com')) + self.eq(nodes[0].get('received:from:ipv6'), '::1') + self.eq(nodes[0].get('received:from:ipv4'), 0x01020304) + self.eq(nodes[0].get('received:from:fqdn'), 'smtp.vertex.link') self.len(1, await core.nodes('inet:email:message:to=woot@woot.com')) self.len(1, await core.nodes('inet:email:message:date=2015'))