devpi-ldap icon indicating copy to clipboard operation
devpi-ldap copied to clipboard

Problem with scenario when conn.response contains attributes dict with {'dn':[]} inside

Open DamianSkrzypczak opened this issue 8 years ago • 2 comments

Hello,

in devpi_ldap/main.py/line 175 there is: if any(attribute_name in x.get('attributes', {}) for x in conn.response):

but I had scenario when conn.response returned dict {attributes:{'dn':[]}} and attribute_name was set to "dn" which, I guess, should result with transition to line 181 elif attribute_name in ('dn', 'distinguishedName'):

Maybe something like this should solve this problem but I don't think it's beautiful solution, rather hotfix suggestion (I'm sorry if this looks insolent, I'm always try to offer some solution when I found problem): if any(attribute_name in x.get('attributes', {}) and x.get('attributes', {})[attribute_name] for x in conn.response):

DamianSkrzypczak avatar Dec 22 '16 22:12 DamianSkrzypczak

Could you provide the raw data from conn.response? Then we can write a proper test for it and I can think about a fix. Just obfuscate any sensitive data.

fschulze avatar Dec 23 '16 12:12 fschulze

This is print of conn.response:

[{'dn': u'some_specific_attr=xxx1,ou=xxx2,ou=xxx,o=xxx3', 'attributes': {'dn': []},
    'raw_attributes': {'dn': []}, 'type': 'searchResEntry'}]

I hope this is enough, I had to obfuscate pretty much.

DamianSkrzypczak avatar Dec 23 '16 16:12 DamianSkrzypczak