Skip to content

Commit 62d064f

Browse files
committed
[16.0][FIX] users_ldap_groups: vulnerability
res.company.ldap.operator operators should be private methods; public methods allow arbitrary LDAP queries via JSON-API
1 parent d4d03d3 commit 62d064f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

users_ldap_groups/models/res_company_ldap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _get_or_create_user(self, conf, login, ldap_entry):
4848
_logger.debug("deleting all groups from user %d", user_id)
4949
groups.append((5, False, False))
5050
for mapping in this.group_mapping_ids:
51-
operator = getattr(op_obj, mapping.operator)
51+
operator = getattr(op_obj, f"_{mapping.operator}")
5252
_logger.debug("checking mapping %s", mapping)
5353
if operator(ldap_entry, mapping):
5454
_logger.debug(

users_ldap_groups/models/res_company_ldap_operator.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ def operators(self):
2020
"""Return names of function to call on this model as operator"""
2121
return ("contains", "equals", "query")
2222

23-
def contains(self, ldap_entry, mapping):
23+
def _contains(self, ldap_entry, mapping):
2424
return mapping.ldap_attribute in ldap_entry[1] and mapping.value in map(
2525
lambda x: x.decode(), ldap_entry[1][mapping.ldap_attribute]
2626
)
2727

28-
def equals(self, ldap_entry, mapping):
28+
def _equals(self, ldap_entry, mapping):
2929
return mapping.ldap_attribute in ldap_entry[1] and mapping.value == str(
3030
list(map(lambda x: x.decode(), ldap_entry[1][mapping.ldap_attribute]))
3131
)
3232

33-
def query(self, ldap_entry, mapping):
33+
def _query(self, ldap_entry, mapping):
3434
query_string = Template(mapping.value).safe_substitute(
3535
{attr: ldap_entry[1][attr][0].decode() for attr in ldap_entry[1]}
3636
)

0 commit comments

Comments
 (0)