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)) } 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 = [