Compare commits
No commits in common. "834e873862a3d4f5012a775b942193dc0b508395" and "b191bcbddfa05f7d0815b9b1ce40052c8f3b3768" have entirely different histories.
834e873862
...
b191bcbddf
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -3171,7 +3171,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-notmuch"
|
name = "letterbox-notmuch"
|
||||||
version = "0.17.34"
|
version = "0.17.33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
@ -3186,7 +3186,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-procmail2notmuch"
|
name = "letterbox-procmail2notmuch"
|
||||||
version = "0.17.34"
|
version = "0.17.33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@ -3199,7 +3199,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-server"
|
name = "letterbox-server"
|
||||||
version = "0.17.34"
|
version = "0.17.33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ammonia",
|
"ammonia",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@ -3219,8 +3219,8 @@ dependencies = [
|
|||||||
"futures 0.3.31",
|
"futures 0.3.31",
|
||||||
"headers",
|
"headers",
|
||||||
"html-escape",
|
"html-escape",
|
||||||
"letterbox-notmuch 0.17.34",
|
"letterbox-notmuch 0.17.33",
|
||||||
"letterbox-shared 0.17.34",
|
"letterbox-shared 0.17.33",
|
||||||
"linkify",
|
"linkify",
|
||||||
"lol_html",
|
"lol_html",
|
||||||
"mailparse",
|
"mailparse",
|
||||||
@ -3261,10 +3261,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-shared"
|
name = "letterbox-shared"
|
||||||
version = "0.17.34"
|
version = "0.17.33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-info",
|
"build-info",
|
||||||
"letterbox-notmuch 0.17.34",
|
"letterbox-notmuch 0.17.33",
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
@ -3274,7 +3274,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "letterbox-web"
|
name = "letterbox-web"
|
||||||
version = "0.17.34"
|
version = "0.17.33"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"build-info",
|
"build-info",
|
||||||
"build-info-build",
|
"build-info-build",
|
||||||
@ -3286,7 +3286,7 @@ dependencies = [
|
|||||||
"graphql_client",
|
"graphql_client",
|
||||||
"human_format",
|
"human_format",
|
||||||
"itertools",
|
"itertools",
|
||||||
"letterbox-shared 0.17.34",
|
"letterbox-shared 0.17.33",
|
||||||
"log",
|
"log",
|
||||||
"seed",
|
"seed",
|
||||||
"seed_hooks",
|
"seed_hooks",
|
||||||
|
|||||||
@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "UNLICENSED"
|
license = "UNLICENSED"
|
||||||
publish = ["xinu"]
|
publish = ["xinu"]
|
||||||
version = "0.17.34"
|
version = "0.17.33"
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
@ -29,8 +29,8 @@ flate2 = "1.1.2"
|
|||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
headers = "0.4.0"
|
headers = "0.4.0"
|
||||||
html-escape = "0.2.13"
|
html-escape = "0.2.13"
|
||||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.34", registry = "xinu" }
|
letterbox-notmuch = { path = "../notmuch", version = "0.17.33", registry = "xinu" }
|
||||||
letterbox-shared = { path = "../shared", version = "0.17.34", registry = "xinu" }
|
letterbox-shared = { path = "../shared", version = "0.17.33", registry = "xinu" }
|
||||||
linkify = "0.10.0"
|
linkify = "0.10.0"
|
||||||
lol_html = "2.3.0"
|
lol_html = "2.3.0"
|
||||||
mailparse = "0.16.1"
|
mailparse = "0.16.1"
|
||||||
|
|||||||
@ -362,7 +362,7 @@ pub fn extract_mixed(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body
|
|||||||
.subparts
|
.subparts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sp| sp.ctype.mimetype.as_str())
|
.map(|sp| sp.ctype.mimetype.as_str())
|
||||||
.filter(|mt| !handled_types.contains(mt))
|
.filter(|mt| !handled_types.contains(&mt))
|
||||||
.collect();
|
.collect();
|
||||||
unhandled_types.sort();
|
unhandled_types.sort();
|
||||||
if !unhandled_types.is_empty() {
|
if !unhandled_types.is_empty() {
|
||||||
@ -500,7 +500,7 @@ pub fn extract_related(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Bo
|
|||||||
.subparts
|
.subparts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|sp| sp.ctype.mimetype.as_str())
|
.map(|sp| sp.ctype.mimetype.as_str())
|
||||||
.filter(|mt| !handled_types.contains(mt))
|
.filter(|mt| !handled_types.contains(&mt))
|
||||||
.collect();
|
.collect();
|
||||||
unhandled_types.sort();
|
unhandled_types.sort();
|
||||||
if !unhandled_types.is_empty() {
|
if !unhandled_types.is_empty() {
|
||||||
@ -774,7 +774,6 @@ pub struct FormattedRecord {
|
|||||||
pub source_ip: String,
|
pub source_ip: String,
|
||||||
pub count: String,
|
pub count: String,
|
||||||
pub header_from: String,
|
pub header_from: String,
|
||||||
pub envelope_to: String,
|
|
||||||
pub disposition: String,
|
pub disposition: String,
|
||||||
pub dkim: String,
|
pub dkim: String,
|
||||||
pub spf: String,
|
pub spf: String,
|
||||||
@ -812,7 +811,6 @@ pub struct FormattedFeedback {
|
|||||||
pub report_metadata: Option<FormattedReportMetadata>,
|
pub report_metadata: Option<FormattedReportMetadata>,
|
||||||
pub policy_published: Option<FormattedPolicyPublished>,
|
pub policy_published: Option<FormattedPolicyPublished>,
|
||||||
pub record: Option<Vec<FormattedRecord>>,
|
pub record: Option<Vec<FormattedRecord>>,
|
||||||
pub has_envelope_to: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
@ -1001,7 +999,6 @@ pub struct FormattedTlsRptFailureDetails {
|
|||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
pub struct Identifiers {
|
pub struct Identifiers {
|
||||||
pub header_from: Option<String>,
|
pub header_from: Option<String>,
|
||||||
pub envelope_to: Option<String>,
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
pub struct AuthResults {
|
pub struct AuthResults {
|
||||||
@ -1112,11 +1109,6 @@ pub fn parse_dmarc_report(xml: &str) -> Result<String, ServerError> {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|i| i.header_from.clone())
|
.and_then(|i| i.header_from.clone())
|
||||||
.unwrap_or_else(|| "".to_string()),
|
.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
|
disposition: rec
|
||||||
.row
|
.row
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1174,17 +1166,10 @@ pub fn parse_dmarc_report(xml: &str) -> Result<String, ServerError> {
|
|||||||
pct: pol.pct.unwrap_or_else(|| "".to_string()),
|
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 {
|
let formatted_feedback = FormattedFeedback {
|
||||||
report_metadata: formatted_report_metadata,
|
report_metadata: formatted_report_metadata,
|
||||||
policy_published: formatted_policy_published,
|
policy_published: formatted_policy_published,
|
||||||
record: formatted_record,
|
record: formatted_record,
|
||||||
has_envelope_to,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let template = DmarcReportTemplate {
|
let template = DmarcReportTemplate {
|
||||||
@ -1232,25 +1217,3 @@ pub fn pretty_print_xml_with_trimming(xml_input: &str) -> Result<String, ServerE
|
|||||||
let result = writer.into_inner().into_inner();
|
let result = writer.into_inner().into_inner();
|
||||||
Ok(String::from_utf8(result)?)
|
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,9 +40,6 @@
|
|||||||
<th style="border:1px solid #bbb;padding:4px 8px;">Source IP</th>
|
<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;">Count</th>
|
||||||
<th style="border:1px solid #bbb;padding:4px 8px;">Header From</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;">Disposition</th>
|
||||||
<th style="border:1px solid #bbb;padding:4px 8px;">DKIM</th>
|
<th style="border:1px solid #bbb;padding:4px 8px;">DKIM</th>
|
||||||
<th style="border:1px solid #bbb;padding:4px 8px;">SPF</th>
|
<th style="border:1px solid #bbb;padding:4px 8px;">SPF</th>
|
||||||
@ -55,9 +52,6 @@
|
|||||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.source_ip }}</td>
|
<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.count }}</td>
|
||||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.header_from }}</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.disposition }}</td>
|
||||||
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.dkim }}</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>
|
<td style="border:1px solid #bbb;padding:4px 8px;">{{ rec.spf }}</td>
|
||||||
|
|||||||
48
server/testdata/dmarc-example-no-envelope-to.xml
vendored
48
server/testdata/dmarc-example-no-envelope-to.xml
vendored
@ -1,48 +0,0 @@
|
|||||||
<?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
78
server/testdata/dmarc-example.xml
vendored
@ -1,78 +0,0 @@
|
|||||||
<?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]
|
[dependencies]
|
||||||
build-info = "0.0.41"
|
build-info = "0.0.41"
|
||||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.34", registry = "xinu" }
|
letterbox-notmuch = { path = "../notmuch", version = "0.17.33", registry = "xinu" }
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
sqlx = "0.8.5"
|
sqlx = "0.8.5"
|
||||||
|
|||||||
@ -33,7 +33,7 @@ wasm-bindgen = "=0.2.100"
|
|||||||
uuid = { version = "1.16.0", features = [
|
uuid = { version = "1.16.0", features = [
|
||||||
"js",
|
"js",
|
||||||
] } # direct dep to set js feature, prevents Rng issues
|
] } # direct dep to set js feature, prevents Rng issues
|
||||||
letterbox-shared = { path = "../shared/", version = "0.17.34", registry = "xinu" }
|
letterbox-shared = { path = "../shared/", version = "0.17.33", registry = "xinu" }
|
||||||
seed_hooks = { version = "0.4.1", registry = "xinu" }
|
seed_hooks = { version = "0.4.1", registry = "xinu" }
|
||||||
strum_macros = "0.27.1"
|
strum_macros = "0.27.1"
|
||||||
gloo-console = "0.3.0"
|
gloo-console = "0.3.0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user