Commit
Author: mdecimus [mauro@stalw.art]
Hash: 3378f966a03efca33ede9ddcb0f25a9d57a3ccb4
Timestamp: Wed, 03 Apr 2024 13:42:41 +0000 (6 months ago)

+5 -2 +/-2 browse
Check PTR against FQDN (including dot at the end) (closes #28)
1diff --git a/resources/spf/basic.yml b/resources/spf/basic.yml
2index 57ea3ab..a00787c 100644
3--- a/resources/spf/basic.yml
4+++ b/resources/spf/basic.yml
5 @@ -96,7 +96,7 @@ records:
6 spf: ptr.test.org v=spf1 ptr:test.org -all
7 mx: mx.test.org 10.0.0.1,10.0.0.2,10.0.0.3,10.0.0.4,10.0.0.5,10.0.0.6,10.0.0.7,10.0.0.8,10.0.0.9,10.0.0.10,10.0.0.11
8 ptr: 10.0.0.1 h1.test.org
9- ptr: 10.0.0.11 h1.test.org, h2.test.org, h3.test.org, h4.test.org, h5.test.org, h6.test.org, h7.test.org, h8.test.org, h9.test.org, h10.test.org, h11.test.org
10+ ptr: 10.0.0.11 h1.test.org, h2.test.org., h3.test.org., h4.test.org, h5.test.org, h6.test.org, h7.test.org, h8.test.org, h9.test.org, h10.test.org, h11.test.org
11 a: h1.test.org 10.0.0.1
12 a: h11.test.org 10.0.0.11
13 tests:
14 diff --git a/src/spf/verify.rs b/src/spf/verify.rs
15index b781a02..22842b8 100644
16--- a/src/spf/verify.rs
17+++ b/src/spf/verify.rs
18 @@ -269,7 +269,10 @@ impl Resolver {
19 self.ip_matches(record, ip, u32::MAX, u128::MAX).await
20 {
21 matches = record == &target_addr
22- || record.ends_with(&target_sub_addr);
23+ || record
24+ .strip_suffix('.')
25+ .unwrap_or(record.as_str())
26+ .ends_with(&target_sub_addr);
27 if matches {
28 break;
29 }