From a232b550beb50909fcd6fba4503fabed5c26df80 Mon Sep 17 00:00:00 2001 From: terashiman Date: Mon, 24 Aug 2026 16:27:04 +0900 Subject: [PATCH] Handle bytes values in AWS special agent JSON serializer WAFv2 ByteMatchStatement.SearchString is returned by boto3 as bytes. The special agent's custom JSON serializer only handled datetime objects and raised TypeError for anything else, crashing the AWS special agent (and check_mk_discovery with it) whenever a monitored WAFv2 Web ACL contains a byte-match rule (e.g. one blocking a URI path such as "/admin/"). Decode bytes to str so the wafv2_web_acl section can be serialized instead of aborting the whole agent run. --- .../cmk-plugins/cmk/plugins/aws/special_agent/agent_aws.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/cmk-plugins/cmk/plugins/aws/special_agent/agent_aws.py b/packages/cmk-plugins/cmk/plugins/aws/special_agent/agent_aws.py index f021c2b21d1..e3af638aa1c 100644 --- a/packages/cmk-plugins/cmk/plugins/aws/special_agent/agent_aws.py +++ b/packages/cmk-plugins/cmk/plugins/aws/special_agent/agent_aws.py @@ -297,6 +297,9 @@ def datetime_serializer(obj): """Custom serializer to pass to json dump functions""" if isinstance(obj, datetime): return str(obj) + if isinstance(obj, bytes): + # e.g. WAFv2 ByteMatchStatement.SearchString is returned by boto3 as bytes + return obj.decode("utf-8", errors="replace") # fall back to json default behaviour: raise TypeError("%r is not JSON serializable" % obj)