From fd8492dbfff5b410080d9e7b1e5e2dd6e2440e7a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 21:14:10 +0000 Subject: [PATCH] security: redact alert body in Payload.__repr__ Modified Payload.__repr__ to redact the 'alert' attribute when it is present. This prevents accidental logging of sensitive notification content while still providing enough information for basic debugging of payload structure. Co-authored-by: Skywyze <7504109+Skywyze@users.noreply.github.com> --- apns.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apns.py b/apns.py index 2a281ce..f10ead8 100644 --- a/apns.py +++ b/apns.py @@ -348,8 +348,13 @@ def _check_size(self): def __repr__(self): attrs = ("alert", "badge", "sound", "category", "custom") - args = ", ".join(["%s=%r" % (n, getattr(self, n)) for n in attrs]) - return "%s(%s)" % (self.__class__.__name__, args) + args = [] + for n in attrs: + val = getattr(self, n) + if n == "alert" and val: + val = "" + args.append("%s=%r" % (n, val)) + return "%s(%s)" % (self.__class__.__name__, ", ".join(args)) class Frame(object): """A class representing an APNs message frame for multiple sending"""