DLP at DATA: block, warn and override over SMTP and JMAP
Phase 2f of the DLP and mail flow rules spec: the rules now run on mail
an authenticated sender submits, after the DATA system script and
before headers and DKIM signing (§2.1).
- smtp/inbound/mailflow.rs: builds what the rules look at from the
message (subject, the text version of each body, one level of attached
messages, attachment text via the extractor, 10 MB of text at most)
and the envelope (sender's groups and tenant; each recipient local or
not, and its groups). Skipped entirely when no enabled rule applies to
outgoing mail. Rules that can't be loaded refuse with a 451: nothing
unchecked leaves.
- Block: 550 5.7.1 with the rule's notice. Warn: 550 5.7.1 with the
notice and how to override: "[override: reason]" at the start of the
subject, taken out before the message goes on (settled answer 1).
Until phase 3, a hold rule blocks rather than let mail through.
- JMAP: EmailSubmission takes inbuxa:dlpOverride {reason}; a refusal
comes back as inbuxa:dlpWarning or inbuxa:dlpBlocked with each rule's
name and notice (description too, for older clients).
- Audit: one record per DLP match, the sender as actor, action create,
target a message: the recipient domains, each rule with its detectors'
counts, the outcome, an override's reason. Never the matched text. No
new audit action: an older node that meets one fails its daily
clean-up, which would make rolling back unsafe (spec §2.7 updated).
Tests: mail_rules_tests gains the DLP flow over JMAP (no rules, warning
with rule and notice, local recipient not warned, override with a
reason, block that no reason passes, the subject tag stripped from the
delivered message, audit records with no card or key text). smtp
inbound tests pass; system_tests passed twice after one timeout in the
email delivery tests that didn't recur.
This commit is contained in:
@@ -47,6 +47,18 @@ struct SetErrorInner<P: Property> {
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
#[serde(rename = "validationErrors")]
|
||||
validation_errors: Vec<ValidationError>,
|
||||
|
||||
// inbuxa: DLP (dlp-and-mail-flow-rules spec, §2.5): each rule that
|
||||
// warned or blocked, with its notice
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
rules: Vec<DlpRule>,
|
||||
}
|
||||
|
||||
/// inbuxa: a DLP rule named in an `inbuxa:dlpWarning` or `inbuxa:dlpBlocked`.
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
pub struct DlpRule {
|
||||
pub name: String,
|
||||
pub notice: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -127,6 +139,12 @@ pub enum SetErrorType {
|
||||
// inbuxa: a create that couldn't run (ai-explain spec: busy, timeout, …)
|
||||
#[serde(rename = "serverFail")]
|
||||
ServerFail,
|
||||
// inbuxa: DLP (dlp-and-mail-flow-rules spec, §2.5): a warning the
|
||||
// sender may answer with inbuxa:dlpOverride, and a block
|
||||
#[serde(rename = "inbuxa:dlpWarning")]
|
||||
DlpWarning,
|
||||
#[serde(rename = "inbuxa:dlpBlocked")]
|
||||
DlpBlocked,
|
||||
}
|
||||
|
||||
impl SetErrorType {
|
||||
@@ -166,6 +184,8 @@ impl SetErrorType {
|
||||
SetErrorType::PrimaryKeyViolation => "primaryKeyViolation",
|
||||
SetErrorType::ValidationFailed => "validationFailed",
|
||||
SetErrorType::ServerFail => "serverFail",
|
||||
SetErrorType::DlpWarning => "inbuxa:dlpWarning",
|
||||
SetErrorType::DlpBlocked => "inbuxa:dlpBlocked",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,9 +200,16 @@ impl<T: Property> SetError<T> {
|
||||
object_id: None,
|
||||
linked_objects: Vec::new(),
|
||||
validation_errors: Vec::new(),
|
||||
rules: Vec::new(),
|
||||
}))
|
||||
}
|
||||
|
||||
/// inbuxa: the DLP rules behind a warning or block.
|
||||
pub fn with_dlp_rules(mut self, rules: Vec<DlpRule>) -> Self {
|
||||
self.0.rules = rules;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_description(mut self, description: impl Into<Cow<'static, str>>) -> Self {
|
||||
self.0.description = description.into().into();
|
||||
self
|
||||
@@ -353,6 +380,7 @@ impl From<PatchError> for SetError<registry::schema::properties::Property> {
|
||||
object_id: None,
|
||||
linked_objects: Vec::new(),
|
||||
validation_errors: Vec::new(),
|
||||
rules: Vec::new(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*
|
||||
* Modified by Coffey Labs in 2026 for INBUXA.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
@@ -40,6 +42,9 @@ pub enum EmailSubmissionProperty {
|
||||
Displayed,
|
||||
DsnBlobIds,
|
||||
MdnBlobIds,
|
||||
// inbuxa: DLP (dlp-and-mail-flow-rules spec, §2.5): `{"reason": ...}`
|
||||
// to send despite a warning
|
||||
DlpOverride,
|
||||
|
||||
Pointer(JsonPointer<EmailSubmissionProperty>),
|
||||
}
|
||||
@@ -90,6 +95,7 @@ impl Property for EmailSubmissionProperty {
|
||||
EmailSubmissionProperty::Id => "id",
|
||||
EmailSubmissionProperty::IdentityId => "identityId",
|
||||
EmailSubmissionProperty::MdnBlobIds => "mdnBlobIds",
|
||||
EmailSubmissionProperty::DlpOverride => "inbuxa:dlpOverride",
|
||||
EmailSubmissionProperty::SendAt => "sendAt",
|
||||
EmailSubmissionProperty::ThreadId => "threadId",
|
||||
EmailSubmissionProperty::UndoStatus => "undoStatus",
|
||||
@@ -181,6 +187,7 @@ impl EmailSubmissionProperty {
|
||||
"displayed" => EmailSubmissionProperty::Displayed,
|
||||
"dsnBlobIds" => EmailSubmissionProperty::DsnBlobIds,
|
||||
"mdnBlobIds" => EmailSubmissionProperty::MdnBlobIds,
|
||||
"inbuxa:dlpOverride" => EmailSubmissionProperty::DlpOverride,
|
||||
)
|
||||
.or_else(|| {
|
||||
if allow_patch && value.contains('/') {
|
||||
|
||||
Reference in New Issue
Block a user