Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add received:from:ipv4/ipv6/fqdn to inet:email:message #3564

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions synapse/models/inet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', {}, (
Expand Down
6 changes: 6 additions & 0 deletions synapse/tests/test_model_inet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2662,6 +2662,9 @@ async def test_model_inet_email_message(self):
:headers=(('to', 'Visi Stark <visi@vertex.link>'),)
: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 )]}
Expand All @@ -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'))
Expand Down
Loading