Univention Bugzilla – Attachment 6681 Details for
Bug 37665
traceback when logging attributes: TypeError: must be string without null bytes, not str
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for sanitizing input before logging
37665.patch (text/plain), 9.35 KB, created by
Florian Best
on 2015-02-17 14:00:12 CET
(
hide
)
Description:
patch for sanitizing input before logging
Filename:
MIME Type:
Creator:
Florian Best
Created:
2015-02-17 14:00:12 CET
Size:
9.35 KB
patch
obsolete
>diff --git a/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/__init__.py b/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/__init__.py >index bb0ff9e..1a19ee8 100644 >--- a/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/__init__.py >+++ b/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/__init__.py >@@ -401,7 +401,7 @@ def _thread(request): > raise ObjectDoesNotExist(ldap_dn) > result.append({'$dn$': ldap_dn, 'success': False, 'details': _('LDAP object does not exist.')}) > continue >- MODULE.info('Modifying LDAP object %s' % (ldap_dn,)) >+ MODULE.info('Modifying LDAP object %r' % (ldap_dn,)) > if '$labelObjectType$' in properties: > del properties['$labelObjectType$'] > try: >@@ -487,7 +487,7 @@ def _thread(request): > props['$flags$'] = obj.oldattr.get('univentionObjectFlag', []), > result.append(props) > else: >- MODULE.process('The LDAP object for the LDAP DN %s could not be found' % ldap_dn) >+ MODULE.process('The LDAP object for the LDAP DN %r could not be found' % ldap_dn) > return result > > MODULE.info('Starting thread for udm/get request') >@@ -520,7 +520,7 @@ def _thread(request): > if superordinate == 'None': > superordinate = None > elif superordinate is not None: >- MODULE.info('Query defines a superordinate %s' % superordinate) >+ MODULE.info('Query defines a superordinate %r' % superordinate) > mod = get_module(request.flavor, superordinate) > if mod is not None: > MODULE.info('Found UDM module for superordinate') >@@ -547,7 +547,7 @@ def _thread(request): > module = get_module(object_type, obj.dn) > if module is None: > # This happens when concurrent a object is removed between the module.search() and get_module() call >- MODULE.warn('LDAP object does not exists %s (flavor: %s). The object is ignored.' % (obj.dn, request.flavor)) >+ MODULE.warn('LDAP object does not exists %s (flavor: %r). The object is ignored.' % (obj.dn, request.flavor)) > continue > entry = { > '$dn$': obj.dn, >diff --git a/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py b/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py >index 93e1fb4..84f85d7 100644 >--- a/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py >+++ b/ucs-4.0-1/management/univention-management-console-module-udm/umc/python/udm/udm_ldap.py >@@ -377,7 +377,7 @@ def __getitem__(self, key): > def get_default_values(self, property_name): > """Depending on the syntax of the given property a default > search pattern/value is returned""" >- MODULE.info('Searching for property %s' % property_name) >+ MODULE.info('Searching for property %r' % property_name) > for key, prop in getattr(self.module, 'property_descriptions', {}).items(): > if key == property_name: > value = default_value(prop.syntax) >@@ -399,13 +399,13 @@ def _tmp_cmp(i, j): > password_properties = self.password_properties > for property_name, value in sorted(properties.items(), _tmp_cmp): > if property_name in password_properties: >- MODULE.info('Setting password property %s' % (property_name,)) >+ MODULE.info('Setting password property %r' % (property_name,)) > else: >- MODULE.info('Setting property %s to %s' % (property_name, value)) >+ MODULE.info('Setting property %r to %r' % (property_name, value)) > > property_obj = self.get_property(property_name) > if property_obj is None: >- raise UMC_OptionMissing(_('Property %s not found') % property_name) >+ raise UMC_OptionMissing(_('Property %r not found') % property_name) > > # check each element if 'value' is a list > if isinstance(value, (tuple, list)) and property_obj.multivalue: >@@ -466,7 +466,7 @@ def create(self, ldap_object, container=None, superordinate=None, ldap_connectio > MODULE.info('Found UDM module for superordinate') > superordinate = mod.get(superordinate) > else: >- MODULE.error('Superordinate module not found: %s' % (superordinate,)) >+ MODULE.error('Superordinate module not found: %r' % (superordinate,)) > raise SuperordinateDoesNotExist(superordinate) > else: > superordinate = udm_objects.get_superordinate(self.module, None, ldap_connection, container) >@@ -501,7 +501,7 @@ def move(self, ldap_dn, container, ldap_connection=None, ldap_position=None): > # build new dn > rdn = udm.uldap.explodeDn(ldap_dn)[0] > dest = '%s,%s' % (rdn, container) >- MODULE.info('Moving LDAP object %s to %s' % (ldap_dn, dest)) >+ MODULE.info('Moving LDAP object %r to %r' % (ldap_dn, dest)) > obj.move(dest) > return dest > except udm_errors.base as e: >@@ -515,7 +515,7 @@ def remove(self, ldap_dn, cleanup=False, recursive=False, ldap_connection=None, > obj = self.module.object(None, ldap_connection, ldap_position, dn=ldap_dn, superordinate=superordinate) > try: > obj.open() >- MODULE.info('Removing LDAP object %s' % ldap_dn) >+ MODULE.info('Removing LDAP object %r' % ldap_dn) > obj.remove(remove_childs=recursive) > if cleanup: > udm_objects.performCleanup(obj) >@@ -527,7 +527,7 @@ def remove(self, ldap_dn, cleanup=False, recursive=False, ldap_connection=None, > def modify(self, ldap_object, ldap_connection=None, ldap_position=None): > """Modifies a LDAP object""" > superordinate = udm_objects.get_superordinate(self.module, None, ldap_connection, ldap_object['$dn$']) >- MODULE.info('Modifying object %s with superordinate %s' % (ldap_object['$dn$'], superordinate)) >+ MODULE.info('Modifying object %r with superordinate %r' % (ldap_object['$dn$'], superordinate)) > obj = self.module.object(None, ldap_connection, ldap_position, dn=ldap_object.get('$dn$'), superordinate=superordinate) > del ldap_object['$dn$'] > >@@ -535,7 +535,7 @@ def modify(self, ldap_object, ldap_connection=None, ldap_position=None): > obj.open() > if '$options$' in ldap_object: > obj.options = filter(lambda option: ldap_object['$options$'][option] == True, ldap_object['$options$'].keys()) >- MODULE.info('Setting new options to %s' % str(obj.options)) >+ MODULE.info('Setting new options to %r' % str(obj.options)) > del ldap_object['$options$'] > MODULE.info('Modifying LDAP object %s' % obj.dn) > if '$policies$' in ldap_object: >@@ -560,7 +560,7 @@ def search(self, container=None, attribute=None, value=None, superordinate=None, > if attribute in [None, 'None'] and filter: > filter_s = str(filter) > >- MODULE.info('Searching for LDAP objects: container = %s, filter = %s, superordinate = %s' % (container, filter_s, superordinate)) >+ MODULE.info('Searching for LDAP objects: container = %r, filter = %r, superordinate = %r' % (container, filter_s, superordinate)) > result = None > try: > sizelimit = int(ucr.get('directory/manager/web/sizelimit', '2000')) >@@ -1164,7 +1164,7 @@ def get_module(flavor, ldap_dn, ldap_connection=None, ldap_position=None): > > module = UDM_Module(modules[0]) > if module.module is None: >- MODULE.error('Identified module %s for %s (flavor=%s) does not have a relating UDM module.' % (modules[0], ldap_dn, flavor)) >+ MODULE.error('Identified module %r for %r (flavor=%r) does not have a relating UDM module.' % (modules[0], ldap_dn, flavor)) > return None > return module > >@@ -1286,7 +1286,7 @@ def search_syntax_choices_by_key(syntax_name, key): > options = {'objectProperty': attr, 'objectPropertyValue': key} > return read_syntax_choices(syntax_name, options) > >- MODULE.warn('Syntax "%s": No fast search function' % syntax_name) >+ MODULE.warn('Syntax %r: No fast search function' % syntax_name) > # return them all, as there is no reason to filter after everything has loaded > # frontend will cache it. > return read_syntax_choices(syntax_name) >@@ -1341,7 +1341,7 @@ def read_syntax_choices(syntax_name, options={}, module_search_options={}, ldap_ > else: > simple = True > if not simple: >- MODULE.warn('Syntax %s wants to get optimizations but may not. This is a Bug! We provide a fallback but the syntax will respond much slower than it could!' % syntax_name) >+ MODULE.warn('Syntax %r wants to get optimizations but may not. This is a Bug! We provide a fallback but the syntax will respond much slower than it could!' % syntax_name) > > def extract_key_label(syn, dn, info): > key = label = None >@@ -1462,7 +1462,7 @@ def map_choice(obj): > module = UDM_Module(syn.udm_module) > if module.module is None: > return >- MODULE.info('Found syntax %s with udm_module property' % syntax_name) >+ MODULE.info('Found syntax %r with udm_module property' % (syntax_name,)) > if syn.udm_filter == 'dn': > syn.choices = map_choice(module.get(options[syn.depends])) > else: >@@ -1482,7 +1482,7 @@ def map_choice(obj): > try: > result = ldap_connection.searchDn(filter=syn.searchFilter) > except udm_errors.base: >- MODULE.process('Failed to initialize syntax class %s' % syntax_name) >+ MODULE.process('Failed to initialize syntax class %r' % (syntax_name,)) > return > syn.choices = [] > for dn in result: >@@ -1531,7 +1531,7 @@ def map_choice(obj): > id = obj.oldattr[store][0] > else: > # no valid store object, ignore >- MODULE.warn('LDAP_Search syntax "%s": "%s" is no valid property for object "%s" - ignoring entry.' % (options['syntax'], store, dn)) >+ MODULE.warn('LDAP_Search syntax %r: %r is no valid property for object %r - ignoring entry.' % (options['syntax'], store, dn)) > continue > > # find the value to display
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 37665
: 6681