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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...