Also mask query parameters which are defined in
MASKED_ATTRIBUTES_BLACKLIST constant and log.mask_secrets_blacklist
config option.
# limitations under the License.
from __future__ import absolute_import
+
import time
import types
import itertools
+from oslo_config import cfg
+
from st2common.constants.api import REQUEST_ID_HEADER
from st2common.constants.auth import QUERY_PARAM_ATTRIBUTE_NAME
from st2common.constants.auth import QUERY_PARAM_API_KEY_ATTRIBUTE_NAME
from st2common.constants.secrets import MASKED_ATTRIBUTE_VALUE
+from st2common.constants.secrets import MASKED_ATTRIBUTES_BLACKLIST
from st2common import log as logging
from st2common.router import Request, NotFoundException
@@ -30,7 +34,7 @@ LOG = logging.getLogger(__name__)
SECRET_QUERY_PARAMS = [
QUERY_PARAM_ATTRIBUTE_NAME,
QUERY_PARAM_API_KEY_ATTRIBUTE_NAME
-]
+] + MASKED_ATTRIBUTES_BLACKLIST
try:
clock = time.perf_counter
@@ -57,7 +61,8 @@ class LoggingMiddleware(object):
query_params = request.GET.dict_of_lists()
# Mask secret / sensitive query params
- for param_name in SECRET_QUERY_PARAMS:
+ secret_query_params = SECRET_QUERY_PARAMS + cfg.CONF.log.mask_secrets_blacklist
+ for param_name in secret_query_params:
if param_name in query_params:
query_params[param_name] = MASKED_ATTRIBUTE_VALUE
