Linux maintainer tooling and workflows
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Kernel.org Tools" <tools@kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Subject: [PATCH b4 v2 1/5] misc/send-receive: support BCC in web submission endpoint
Date: Sun, 11 Oct 2026 22:58:26 -0700	[thread overview]
Message-ID: <20261011-send-series-bcc-v2-1-cd17584c40fb@gmail.com> (raw)
In-Reply-To: <20261011-send-series-bcc-v2-0-cd17584c40fb@gmail.com>

Support receiving and processing client-specified BCC envelope
destinations in the web submission endpoint.

Extract optional top-level "bcc" list from JSON request payload in
receive(), validate email address format, enforce max-client-bcc
limit (default: 10) to guard against relay abuse, and merge validated
addresses into destaddrs for SMTP delivery.

Assisted-by: LLM
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 misc/default.conf    |  2 ++
 misc/send-receive.py | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/misc/default.conf b/misc/default.conf
index 100c8cd..2aab3c0 100644
--- a/misc/default.conf
+++ b/misc/default.conf
@@ -29,6 +29,8 @@
   # Always bcc the address(es) listed here, separated by comma
   # Useful during initial testing
   #alwaysbcc = one@example.com, two@example.com
+  # Maximum number of BCC recipients allowed in client submissions (default: 10)
+  #max-client-bcc = 10
   # If dryrun is set, the messages are printed to stdout instead of
   # being actually sent out. Useful for testing.
   #dryrun = false
diff --git a/misc/send-receive.py b/misc/send-receive.py
index e1cf98e..22e049b 100644
--- a/misc/send-receive.py
+++ b/misc/send-receive.py
@@ -18,7 +18,7 @@ import textwrap
 from configparser import ConfigParser, ExtendedInterpolation
 from email import charset, utils
 from string import Template
-from typing import List, Mapping, Optional, Sequence, Tuple, Union
+from typing import List, Mapping, Optional, Sequence, Set, Tuple, Union
 
 import ezpi
 import falcon
@@ -519,6 +519,33 @@ class SendReceiveListener(object):
             return
         logger.debug('Received a request for %s messages', len(umsgs))
 
+        client_bcc: Set[str] = set()
+        if 'bcc' in jdata:
+            jbcc = jdata.get('bcc')
+            if not isinstance(jbcc, list):
+                self.send_error(resp, message='Invalid bcc payload format')
+                return
+            max_bcc = self._config['main'].getint('max-client-bcc', fallback=10)
+            for entry in jbcc:
+                if not isinstance(entry, str):
+                    self.send_error(resp, message='Invalid bcc address format')
+                    return
+                parsed = utils.getaddresses([entry])
+                if not parsed:
+                    self.send_error(resp, message='Invalid bcc address format')
+                    return
+                for _, addr in parsed:
+                    local, _, domain = addr.partition('@')
+                    if not (local and domain and not any(c.isspace() for c in addr)):
+                        self.send_error(resp, message='Invalid bcc address format')
+                        return
+                    client_bcc.add(addr.lower())
+            if len(client_bcc) > max_bcc:
+                self.send_error(
+                    resp, message=f'Too many BCC recipients (max: {max_bcc})'
+                )
+                return
+
         diffre = re.compile(
             rb'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)',
             flags=re.M | re.I,
@@ -761,6 +788,9 @@ class SendReceiveListener(object):
                             msg.set_charset('utf-8')
                             msg.replace_header('Content-Transfer-Encoding', '8bit')
 
+            if client_bcc and not reflect:
+                destaddrs.update(client_bcc)
+
             if bccaddrs:
                 destaddrs.update(bccaddrs)
 

-- 
2.56.0.385.gd3acb90ef8-goog


  reply	other threads:[~2026-10-12  5:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12  5:58 [PATCH b4 v2 0/5] b4: Implement BCC support for patch submissions and review Dmitry Torokhov
2026-10-12  5:58 ` Dmitry Torokhov [this message]
2026-10-12  5:58 ` [PATCH b4 v2 2/5] b4: implement --bcc and send-series-bcc config option Dmitry Torokhov
2026-10-12  5:58 ` [PATCH b4 v2 3/5] b4: handle per-message Bcc headers in send_mail and TUIs Dmitry Torokhov
2026-10-12  5:58 ` [PATCH b4 v2 4/5] b4: reject Bcc trailers in patches and cover letter Dmitry Torokhov
2026-10-12  5:58 ` [PATCH b4 v2 5/5] misc/send-receive: require messages payload to be a list Dmitry Torokhov
2026-11-13  2:00 ` [PATCH b4 v2 0/5] b4: Implement BCC support for patch submissions and review Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261011-send-series-bcc-v2-1-cd17584c40fb@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=konstantin@linuxfoundation.org \
    --cc=tools@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox