All Apps and Add-ons

BUG: UTF-8 reencoding inside sa-ldapsearch ldapfilter

matejkaj
Engager

Hello,
I'd like to report a bug in following plugin:
Splunk Supporting Add-on for Active Directory
If you run a search that yield non-ascii fields and you pass them as parameters into ldapfilter, the search fails with an error.
Example:

| ldapsearch search="(cn=Ůïkëllok Řúxľif)" attrs="distinguishedName"| ldapfilter search="(distinguishedName=$distinguishedName$)" attrs="cn"

The subsequent ldapfilter crashes with following trace:

  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/ldapfilter.py", line 117, in stream
    for entry in entry_generator:
  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/packages/ldap3/extend/standard/PagedSearch.py", line 57, in paged_search_generator
    None if cookie is True else cookie)
  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/packages/ldap3/core/connection.py", line 398, in search
    request = search_operation(search_base, search_filter, search_scope, dereference_aliases, attributes, size_limit, time_limit, types_only, self.server.schema if self.server and self.check_names else None)
  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/packages/ldap3/operation/search.py", line 356, in search_operation
    request['filter'] = build_filter(search_filter, schema)  # parse the searchFilter string and compile it starting from the root node
  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/packages/ldap3/operation/search.py", line 307, in build_filter
    return compile_filter(parse_filter(search_filter, schema).elements[0])
  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/packages/ldap3/operation/search.py", line 215, in parse_filter
    current_node.append(evaluate_match(search_filter[start_pos:end_pos], schema))
  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/packages/ldap3/operation/search.py", line 175, in evaluate_match
    assertion = {'attr': left_part, 'value': validate_assertion_value(schema, left_part, right_part)}
  File "/opt/splunk/etc/apps/SA-ldapsearch/bin/packages/ldap3/protocol/convert.py", line 164, in validate_assertion_value
    validated_value += value[pos].encode('utf-8', errors='ignore')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc4 in position 0: unexpected end of data

Possible workaround: simply remove ".encode('utf-8', errors='ignore')"

Please fix this issue.
Thanks!

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...