Skip to content

Commit 7f5ae4c

Browse files
authored
Merge pull request OCA#659 from oh2fih/16.0-jsonrpc-vuln
[16.0][FIX] users_ldap_groups JSON RPC vulnerability
2 parents 1e8e386 + 5307f85 commit 7f5ae4c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ class ResCompanyLdapOperator(models.AbstractModel):
1717

1818
@api.model
1919
def operators(self):
20-
"""Return names of function to call on this model as operator"""
20+
"""Return names (without '_') 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)