Compare commits
3 Commits
b6995355ac
...
3ae09c1e17
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ae09c1e17 | |||
| 834e873862 | |||
| 6c07b18eec |
54
Cargo.lock
generated
54
Cargo.lock
generated
@ -447,7 +447,7 @@ dependencies = [
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"http-body-util",
|
||||
"hyper 1.6.0",
|
||||
"hyper 1.7.0",
|
||||
"hyper-util",
|
||||
"itoa 1.0.15",
|
||||
"matchit 0.8.4",
|
||||
@ -2706,13 +2706,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.6.0"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80"
|
||||
checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e"
|
||||
dependencies = [
|
||||
"atomic-waker",
|
||||
"bytes 1.10.1",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"futures-core",
|
||||
"h2 0.4.12",
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
@ -2720,6 +2721,7 @@ dependencies = [
|
||||
"httpdate",
|
||||
"itoa 1.0.15",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"smallvec 1.15.1",
|
||||
"tokio 1.47.1",
|
||||
"want 0.3.1",
|
||||
@ -2732,7 +2734,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58"
|
||||
dependencies = [
|
||||
"http 1.3.1",
|
||||
"hyper 1.6.0",
|
||||
"hyper 1.7.0",
|
||||
"hyper-util",
|
||||
"rustls",
|
||||
"rustls-pki-types",
|
||||
@ -2748,7 +2750,7 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0"
|
||||
dependencies = [
|
||||
"hyper 1.6.0",
|
||||
"hyper 1.7.0",
|
||||
"hyper-util",
|
||||
"pin-project-lite",
|
||||
"tokio 1.47.1",
|
||||
@ -2789,7 +2791,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
|
||||
dependencies = [
|
||||
"bytes 1.10.1",
|
||||
"http-body-util",
|
||||
"hyper 1.6.0",
|
||||
"hyper 1.7.0",
|
||||
"hyper-util",
|
||||
"native-tls",
|
||||
"tokio 1.47.1",
|
||||
@ -2810,7 +2812,7 @@ dependencies = [
|
||||
"futures-util",
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"hyper 1.6.0",
|
||||
"hyper 1.7.0",
|
||||
"ipnet",
|
||||
"libc",
|
||||
"percent-encoding",
|
||||
@ -3157,7 +3159,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-notmuch"
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"log",
|
||||
@ -3172,9 +3174,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-notmuch"
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
|
||||
checksum = "911a2a75389c464bcd34a0b3166565ffaca4bbb11b153f428e6b0a74aeb352bc"
|
||||
checksum = "f8553357f63cca5f540f58ed8ae2a0e93745a2d3dd986697a8e04c013877dfbf"
|
||||
dependencies = [
|
||||
"log",
|
||||
"mailparse",
|
||||
@ -3186,12 +3188,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-procmail2notmuch"
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"letterbox-notmuch 0.17.33 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"letterbox-shared 0.17.33 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"letterbox-notmuch 0.17.34 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"letterbox-shared 0.17.34 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"serde",
|
||||
"sqlx",
|
||||
"tokio 1.47.1",
|
||||
@ -3199,7 +3201,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-server"
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
dependencies = [
|
||||
"ammonia",
|
||||
"anyhow",
|
||||
@ -3219,8 +3221,8 @@ dependencies = [
|
||||
"futures 0.3.31",
|
||||
"headers",
|
||||
"html-escape",
|
||||
"letterbox-notmuch 0.17.33",
|
||||
"letterbox-shared 0.17.33",
|
||||
"letterbox-notmuch 0.17.34",
|
||||
"letterbox-shared 0.17.34",
|
||||
"linkify",
|
||||
"lol_html",
|
||||
"mailparse",
|
||||
@ -3246,10 +3248,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-shared"
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
dependencies = [
|
||||
"build-info",
|
||||
"letterbox-notmuch 0.17.33",
|
||||
"letterbox-notmuch 0.17.34",
|
||||
"regex",
|
||||
"serde",
|
||||
"sqlx",
|
||||
@ -3259,12 +3261,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-shared"
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
|
||||
checksum = "ec953a4f8de343d1bffb37faaf27c30743c7019132c521d6931ac0efe2571ff8"
|
||||
checksum = "fc4f19d9601d651e8cd8411f0600fc22975d8fac09f0256ad5ef13ab371e5d8e"
|
||||
dependencies = [
|
||||
"build-info",
|
||||
"letterbox-notmuch 0.17.33 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"letterbox-notmuch 0.17.34 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"regex",
|
||||
"serde",
|
||||
"sqlx",
|
||||
@ -3274,7 +3276,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-web"
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
dependencies = [
|
||||
"build-info",
|
||||
"build-info-build",
|
||||
@ -3286,7 +3288,7 @@ dependencies = [
|
||||
"graphql_client",
|
||||
"human_format",
|
||||
"itertools",
|
||||
"letterbox-shared 0.17.33",
|
||||
"letterbox-shared 0.17.34",
|
||||
"log",
|
||||
"seed",
|
||||
"seed_hooks",
|
||||
@ -4876,7 +4878,7 @@ dependencies = [
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"http-body-util",
|
||||
"hyper 1.6.0",
|
||||
"hyper 1.7.0",
|
||||
"hyper-rustls",
|
||||
"hyper-tls 0.6.0",
|
||||
"hyper-util",
|
||||
@ -6753,7 +6755,7 @@ dependencies = [
|
||||
"http 1.3.1",
|
||||
"http-body 1.0.1",
|
||||
"http-body-util",
|
||||
"hyper 1.6.0",
|
||||
"hyper 1.7.0",
|
||||
"hyper-timeout",
|
||||
"hyper-util",
|
||||
"percent-encoding",
|
||||
|
||||
@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
|
||||
edition = "2021"
|
||||
license = "UNLICENSED"
|
||||
publish = ["xinu"]
|
||||
version = "0.17.33"
|
||||
version = "0.17.34"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
|
||||
[profile.dev]
|
||||
|
||||
@ -29,8 +29,8 @@ flate2 = "1.1.2"
|
||||
futures = "0.3.31"
|
||||
headers = "0.4.0"
|
||||
html-escape = "0.2.13"
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.33", registry = "xinu" }
|
||||
letterbox-shared = { path = "../shared", version = "0.17.33", registry = "xinu" }
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.34", registry = "xinu" }
|
||||
letterbox-shared = { path = "../shared", version = "0.17.34", registry = "xinu" }
|
||||
linkify = "0.10.0"
|
||||
lol_html = "2.3.0"
|
||||
mailparse = "0.16.1"
|
||||
|
||||
@ -362,7 +362,7 @@ pub fn extract_mixed(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body
|
||||
.subparts
|
||||
.iter()
|
||||
.map(|sp| sp.ctype.mimetype.as_str())
|
||||
.filter(|mt| !handled_types.contains(&mt))
|
||||
.filter(|mt| !handled_types.contains(mt))
|
||||
.collect();
|
||||
unhandled_types.sort();
|
||||
if !unhandled_types.is_empty() {
|
||||
@ -500,7 +500,7 @@ pub fn extract_related(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Bo
|
||||
.subparts
|
||||
.iter()
|
||||
.map(|sp| sp.ctype.mimetype.as_str())
|
||||
.filter(|mt| !handled_types.contains(&mt))
|
||||
.filter(|mt| !handled_types.contains(mt))
|
||||
.collect();
|
||||
unhandled_types.sort();
|
||||
if !unhandled_types.is_empty() {
|
||||
@ -774,6 +774,7 @@ pub struct FormattedRecord {
|
||||
pub source_ip: String,
|
||||
pub count: String,
|
||||
pub header_from: String,
|
||||
pub envelope_to: String,
|
||||
pub disposition: String,
|
||||
pub dkim: String,
|
||||
pub spf: String,
|
||||
@ -811,6 +812,7 @@ pub struct FormattedFeedback {
|
||||
pub report_metadata: Option<FormattedReportMetadata>,
|
||||
pub policy_published: Option<FormattedPolicyPublished>,
|
||||
pub record: Option<Vec<FormattedRecord>>,
|
||||
pub has_envelope_to: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
@ -999,6 +1001,7 @@ pub struct FormattedTlsRptFailureDetails {
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct Identifiers {
|
||||
pub header_from: Option<String>,
|
||||
pub envelope_to: Option<String>,
|
||||
}
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct AuthResults {
|
||||
@ -1109,6 +1112,11 @@ pub fn parse_dmarc_report(xml: &str) -> Result<String, ServerError> {
|
||||
.as_ref()
|
||||
.and_then(|i| i.header_from.clone())
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
envelope_to: rec
|
||||
.identifiers
|
||||
.as_ref()
|
||||
.and_then(|i| i.envelope_to.clone())
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
disposition: rec
|
||||
.row
|
||||
.as_ref()
|
||||
@ -1166,10 +1174,17 @@ pub fn parse_dmarc_report(xml: &str) -> Result<String, ServerError> {
|
||||
pct: pol.pct.unwrap_or_else(|| "".to_string()),
|
||||
});
|
||||
|
||||
let has_envelope_to = formatted_record
|
||||
.as_ref()
|
||||
.map_or(false, |r: &Vec<FormattedRecord>| {
|
||||
r.iter().any(|rec| !rec.envelope_to.is_empty())
|
||||
});
|
||||
|
||||
let formatted_feedback = FormattedFeedback {
|
||||
report_metadata: formatted_report_metadata,
|
||||
policy_published: formatted_policy_published,
|
||||
record: formatted_record,
|
||||
has_envelope_to,
|
||||
};
|
||||
|
||||
let template = DmarcReportTemplate {
|
||||
@ -1217,3 +1232,25 @@ pub fn pretty_print_xml_with_trimming(xml_input: &str) -> Result<String, ServerE
|
||||
let result = writer.into_inner().into_inner();
|
||||
Ok(String::from_utf8(result)?)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_parse_dmarc_report() {
|
||||
let xml = fs::read_to_string("testdata/dmarc-example.xml").unwrap();
|
||||
let html = parse_dmarc_report(&xml).unwrap();
|
||||
assert!(html.contains("hotmail.com"));
|
||||
assert!(html.contains("msn.com"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_dmarc_report_no_envelope_to() {
|
||||
let xml = fs::read_to_string("testdata/dmarc-example-no-envelope-to.xml").unwrap();
|
||||
let html = parse_dmarc_report(&xml).unwrap();
|
||||
assert!(!html.contains("Envelope To"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,9 @@
|
||||
<th style="border:1px solid #bbb;padding:4px 8px;">Source IP</th>
|
||||
<th style="border:1px solid #bbb;padding:4px 8px;">Count</th>
|
||||
<th style="border:1px solid #bbb;padding:4px 8px;">Header From</th>
|
||||
{% if report.has_envelope_to %}
|
||||
<th style="border:1px solid #bbb;padding:4px 8px;">Envelope To</th>
|
||||
{% endif %}
|
||||
<th style="border:1px solid #bbb;padding:4px 8px;">Disposition</th>
|
||||
<th style="border:1px solid #bbb;padding:4px 8px;">DKIM</th>
|
||||
<th style="border:1px solid #bbb;padding:4px 8px;">SPF</th>
|
||||
@ -52,6 +55,9 @@
|
||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.source_ip }}</td>
|
||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.count }}</td>
|
||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.header_from }}</td>
|
||||
{% if report.has_envelope_to %}
|
||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.envelope_to }}</td>
|
||||
{% endif %}
|
||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.disposition }}</td>
|
||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.dkim }}</td>
|
||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.spf }}</td>
|
||||
|
||||
48
server/testdata/dmarc-example-no-envelope-to.xml
vendored
Normal file
48
server/testdata/dmarc-example-no-envelope-to.xml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<feedback>
|
||||
<version>1.0</version>
|
||||
<report_metadata>
|
||||
<org_name>google.com</org_name>
|
||||
<email>noreply-dmarc-support@google.com</email>
|
||||
<extra_contact_info>https://support.google.com/a/answer/2466580</extra_contact_info>
|
||||
<report_id>5142106658860834914</report_id>
|
||||
<date_range>
|
||||
<begin>1755302400</begin>
|
||||
<end>1755388799</end>
|
||||
</date_range>
|
||||
</report_metadata>
|
||||
<policy_published>
|
||||
<domain>xinu.tv</domain>
|
||||
<adkim>s</adkim>
|
||||
<aspf>s</aspf>
|
||||
<p>quarantine</p>
|
||||
<sp>reject</sp>
|
||||
<pct>100</pct>
|
||||
<np>reject</np>
|
||||
</policy_published>
|
||||
<record>
|
||||
<row>
|
||||
<source_ip>74.207.253.222</source_ip>
|
||||
<count>1</count>
|
||||
<policy_evaluated>
|
||||
<disposition>none</disposition>
|
||||
<dkim>pass</dkim>
|
||||
<spf>pass</spf>
|
||||
</policy_evaluated>
|
||||
</row>
|
||||
<identifiers>
|
||||
<header_from>xinu.tv</header_from>
|
||||
</identifiers>
|
||||
<auth_results>
|
||||
<dkim>
|
||||
<domain>xinu.tv</domain>
|
||||
<result>pass</result>
|
||||
<selector>mail</selector>
|
||||
</dkim>
|
||||
<spf>
|
||||
<domain>xinu.tv</domain>
|
||||
<result>pass</result>
|
||||
</spf>
|
||||
</auth_results>
|
||||
</record>
|
||||
</feedback>
|
||||
78
server/testdata/dmarc-example.xml
vendored
Normal file
78
server/testdata/dmarc-example.xml
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0"?>
|
||||
<feedback xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<version>1.0</version>
|
||||
<report_metadata>
|
||||
<org_name>Outlook.com</org_name>
|
||||
<email>dmarcreport@microsoft.com</email>
|
||||
<report_id>e6c5a2ce6e074d7d8cd041a0d6f32a3d</report_id>
|
||||
<date_range>
|
||||
<begin>1755302400</begin>
|
||||
<end>1755388800</end>
|
||||
</date_range>
|
||||
</report_metadata>
|
||||
<policy_published>
|
||||
<domain>xinu.tv</domain>
|
||||
<adkim>s</adkim>
|
||||
<aspf>s</aspf>
|
||||
<p>quarantine</p>
|
||||
<sp>reject</sp>
|
||||
<pct>100</pct>
|
||||
<fo>1</fo>
|
||||
</policy_published>
|
||||
<record>
|
||||
<row>
|
||||
<source_ip>74.207.253.222</source_ip>
|
||||
<count>1</count>
|
||||
<policy_evaluated>
|
||||
<disposition>none</disposition>
|
||||
<dkim>pass</dkim>
|
||||
<spf>pass</spf>
|
||||
</policy_evaluated>
|
||||
</row>
|
||||
<identifiers>
|
||||
<envelope_to>msn.com</envelope_to>
|
||||
<envelope_from>xinu.tv</envelope_from>
|
||||
<header_from>xinu.tv</header_from>
|
||||
</identifiers>
|
||||
<auth_results>
|
||||
<dkim>
|
||||
<domain>xinu.tv</domain>
|
||||
<selector>mail</selector>
|
||||
<result>pass</result>
|
||||
</dkim>
|
||||
<spf>
|
||||
<domain>xinu.tv</domain>
|
||||
<scope>mfrom</scope>
|
||||
<result>pass</result>
|
||||
</spf>
|
||||
</auth_results>
|
||||
</record>
|
||||
<record>
|
||||
<row>
|
||||
<source_ip>74.207.253.222</source_ip>
|
||||
<count>1</count>
|
||||
<policy_evaluated>
|
||||
<disposition>none</disposition>
|
||||
<dkim>pass</dkim>
|
||||
<spf>pass</spf>
|
||||
</policy_evaluated>
|
||||
</row>
|
||||
<identifiers>
|
||||
<envelope_to>hotmail.com</envelope_to>
|
||||
<envelope_from>xinu.tv</envelope_from>
|
||||
<header_from>xinu.tv</header_from>
|
||||
</identifiers>
|
||||
<auth_results>
|
||||
<dkim>
|
||||
<domain>xinu.tv</domain>
|
||||
<selector>mail</selector>
|
||||
<result>pass</result>
|
||||
</dkim>
|
||||
<spf>
|
||||
<domain>xinu.tv</domain>
|
||||
<scope>mfrom</scope>
|
||||
<result>pass</result>
|
||||
</spf>
|
||||
</auth_results>
|
||||
</record>
|
||||
</feedback>
|
||||
@ -12,7 +12,7 @@ version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
build-info = "0.0.41"
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.33", registry = "xinu" }
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.34", registry = "xinu" }
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
sqlx = "0.8.5"
|
||||
|
||||
@ -33,7 +33,7 @@ wasm-bindgen = "=0.2.100"
|
||||
uuid = { version = "1.16.0", features = [
|
||||
"js",
|
||||
] } # direct dep to set js feature, prevents Rng issues
|
||||
letterbox-shared = { path = "../shared/", version = "0.17.33", registry = "xinu" }
|
||||
letterbox-shared = { path = "../shared/", version = "0.17.34", registry = "xinu" }
|
||||
seed_hooks = { version = "0.4.1", registry = "xinu" }
|
||||
strum_macros = "0.27.1"
|
||||
gloo-console = "0.3.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user