Skip to content
Snippets Groups Projects
Commit 26c8d819 authored by Sven Mäder's avatar Sven Mäder :speech_balloon:
Browse files

Move all logs with attribute output to debug

parent 39107a1f
Branches
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ import lib_path
import lib
import dphysldap
# security warning: using DEBUG may log sensitive data
# log levels: CRITICAL | ERROR | WARNING | INFO | DEBUG | NOTSET
# default: WARNING
log_level = logging.INFO
......@@ -103,7 +104,7 @@ def is_skipped(entry):
for attribute in entry['attributes']['reqMod']:
try:
if not rgx_skip.search(attribute):
log.info('interesting attribute: {}'.format(attribute))
log.debug('interesting attribute: {}'.format(attribute))
return False
except:
log.debug('caught exception: while checking skipped, assume interesting attribute: {}'.format(attribute))
......@@ -125,14 +126,14 @@ def filtered(entry):
if type(attribute) is bytes:
is_bytes = True
log.info('this is a bytes object, decoding it...')
log.debug('this is a bytes object, decoding it...')
log.debug('encoded: {}'.format(attribute))
decoded = attribute.decode('utf-8', errors='ignore')
attribute = decoded
try:
if rgx_filter.search(attribute):
log.info('filter attribute: {}'.format(attribute))
log.debug('filter attribute: {}'.format(attribute))
entry['attributes']['reqMod'].remove(attribute)
elif rgx_redacted.search(attribute):
......@@ -147,14 +148,14 @@ def filtered(entry):
log.info('redact attribute: {}'.format(redacted))
else:
redacted = ''.join([key, delimiter])
log.info('redact attribute (nothing to redact): {}'.format(redacted))
log.debug('redact attribute (nothing to redact): {}'.format(redacted))
entry['attributes']['reqMod'][index] = redacted
else:
log.error('error: matching rgx_attr_key on redacted attribute')
unknown_redacted = 'unknownAttribute: [REDACTED]'
log.error('using: {}'.format(unknown_redacted))
log.debug('using: {}'.format(unknown_redacted))
entry['attributes']['reqMod'][index] = unknown_redacted
elif is_bytes:
......@@ -171,19 +172,19 @@ def filtered(entry):
value_base64 = base64.b64encode(value_bytes).decode('utf-8')
log.debug('value_base64: {}'.format(value_base64))
half_encoded_base64 = ''.join([key_delimit, value_base64])
log.info('bytes attribute: {}'.format(half_encoded_base64))
log.debug('bytes attribute: {}'.format(half_encoded_base64))
entry['attributes']['reqMod'][index] = half_encoded_base64
else:
log.warning('warning: something strange has happened, this should not happen (maybe)')
encoded_base64 = base64.b64encode(entry['attributes']['reqMod'][index]).decode('utf-8')
log.error('bytes attribute, using base64 encoding: {}'.format(encoded_base64))
log.debug('bytes attribute, using base64 encoding: {}'.format(encoded_base64))
entry['attributes']['reqMod'][index] = encoded_base64
else:
log.error('error: matching rgx_attr_key on bytes attribute')
encoded_base64 = base64.b64encode(entry['attributes']['reqMod'][index]).decode('utf-8')
log.error('bytes attribute, using full base64 encoding: {}'.format(encoded_base64))
log.debug('bytes attribute, using full base64 encoding: {}'.format(encoded_base64))
entry['attributes']['reqMod'][index] = encoded_base64
except:
......@@ -214,10 +215,10 @@ def write(entry):
entry['attributes'] = dict(entry['attributes'])
# debug
entry['raw_attributes'] = dict(entry['raw_attributes'])
log.debug('original entry:')
log.debug(pprint.pformat(entry, indent=1))
# debugging
#entry['raw_attributes'] = dict(entry['raw_attributes'])
#log.debug('original entry:')
#log.debug(pprint.pformat(entry, indent=1))
filtered_entry = filtered(entry)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment