From a00f4e049e6449531277ad32c3e25e434bfcc3c2 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Tue, 2 Sep 2025 14:27:25 -0700 Subject: [PATCH 1/2] Implemented scrub_keys function --- polyapi/poly_tables.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/polyapi/poly_tables.py b/polyapi/poly_tables.py index 3b51913..358a1f2 100644 --- a/polyapi/poly_tables.py +++ b/polyapi/poly_tables.py @@ -6,6 +6,21 @@ from polyapi.typedefs import TableSpecDto from polyapi.constants import JSONSCHEMA_TO_PYTHON_TYPE_MAP +def scrub(data) -> Dict[str, Any]: + if (not data or not isinstance(data, (Dict, List))): return data + if isinstance(data, List): + return [scrub(item) for item in data] + else: + temp = {} + secrets = ["x_api_key", "x-api-key", "access_token", "access-token", "authorization", "api_key", "api-key", "apikey", "accesstoken", "token", "password", "key"] + for key, value in data.items(): + if isinstance(value, (Dict, List)): + temp[key] = scrub(data[key]) + elif key.lower() in secrets: + temp[key] = '********' + else: + temp[key] = data[key] + return temp def scrub_keys(e: Exception) -> Dict[str, Any]: """ @@ -16,7 +31,7 @@ def scrub_keys(e: Exception) -> Dict[str, Any]: "error": str(e), "type": type(e).__name__, "message": str(e), - "args": getattr(e, 'args', None) + "args": scrub(getattr(e, 'args', None)) } From cf8006b75a323e862b527dc05a10b39c74cbd653 Mon Sep 17 00:00:00 2001 From: Daniel Estoll Date: Wed, 3 Sep 2025 08:48:25 -0700 Subject: [PATCH 2/2] bumped version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a49fb75..06616ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"] [project] name = "polyapi-python" -version = "0.3.10.dev4" +version = "0.3.10.dev5" description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers" authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }] dependencies = [