aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-09-13 10:46:46 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-09-13 10:46:46 -0400
commitbbe6187a90b643fd6e9d70fccdbf392b27ee0f4a (patch)
tree3da685feff837f73eac6290d487e39e42c02a7a9
parent7dadea51e9414806f159ceac62b7dfb05ad5ab09 (diff)
downloadb4-bbe6187a90b643fd6e9d70fccdbf392b27ee0f4a.tar.gz
Only accept web urls as valid endpoints
With .b4-config being able to specify endpoint defaults, allow users to override it in their local configuration by setting send-endpoint-web to "no" (or any other non-URL string). Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--.b4-config2
-rw-r--r--b4/__init__.py4
-rw-r--r--b4/ez.py13
3 files changed, 14 insertions, 5 deletions
diff --git a/.b4-config b/.b4-config
index dba14d6..3f20a71 100644
--- a/.b4-config
+++ b/.b4-config
@@ -1,4 +1,4 @@
[b4]
send-series-to = Kernel.org Tools <tools@linux.kernel.org>
send-series-cc = Konstantin Ryabitsev <konstantin@linuxfoundation.org>
- send-endpoint-web = https://lore.kernel.org/_b4_submit
+ send-endpoint-web = https://lkml.kernel.org/_b4_submit
diff --git a/b4/__init__.py b/b4/__init__.py
index d5504c2..d734680 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -3148,7 +3148,9 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[
logger.info('---')
# Do we have an endpoint defined?
config = get_main_config()
- endpoint = config.get('send-endpoint-web')
+ endpoint = config.get('send-endpoint-web', '')
+ if not re.search(r'https?://', endpoint):
+ endpoint = None
if use_web_endpoint and endpoint:
logger.info('Sending via web endpoint %s', endpoint)
req = {
diff --git a/b4/ez.py b/b4/ez.py
index 3b14b1c..d4eb161 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -73,9 +73,12 @@ Changes in v${newrev}:
def get_auth_configs() -> Tuple[str, str, str, str, str, str]:
config = b4.get_main_config()
- endpoint = config.get('send-endpoint-web')
+ endpoint = config.get('send-endpoint-web', '')
+ if not re.search(r'https?://', endpoint):
+ endpoint = None
+
if not endpoint:
- raise RuntimeError('No web submission endpoint defined, set b4.send-endpoint-web')
+ raise RuntimeError('Web submission endpoint (b4.send-endpoint-web) is not defined, or is not a web URL.')
usercfg = b4.get_user_config()
myemail = usercfg.get('email')
@@ -1231,7 +1234,11 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
send_msgs.append(msg)
- if config.get('send-endpoint-web'):
+ endpoint = config.get('send-endpoint-web', '')
+ if not re.search(r'https?://', endpoint):
+ endpoint = None
+
+ if endpoint:
# Web endpoint always requires signing
if not sign:
logger.critical('CRITICAL: Web endpoint is defined for sending, but signing is turned off')