← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1305056] [NEW] Impossible to use method search_s in BaseLdap if attribute 'page_size' is not 0.

 

Public bug reported:

/opt/stack/keystone/keystone/common/ldap/core.py #493-520

def search_s(self, base, scope,
                 filterstr='(objectClass=*)', attrlist=None, attrsonly=0):
        # NOTE(morganfainberg): Remove "None" singletons from this list, which
        # allows us to set mapped attributes to "None" as defaults in config.
        # Without this filtering, the ldap query would raise a TypeError since
        # attrlist is expected to be an iterable of strings.
        if attrlist is not None:
            attrlist = [attr for attr in attrlist if attr is not None]
        LOG.debug('LDAP search: base=%s scope=%s filterstr=%s '
                  'attrs=%s attrsonly=%s',
                  base, scope, filterstr, attrlist, attrsonly)
        if self.page_size:
            ldap_result = self._paged_search_s(base, scope,
                                               filterstr, attrlist)
        else:
            base_utf8 = utf8_encode(base)
            filterstr_utf8 = utf8_encode(filterstr)
            if attrlist is None:
                attrlist_utf8 = None
            else:
                attrlist_utf8 = map(utf8_encode, attrlist)
            ldap_result = self.conn.search_s(base_utf8, scope,
                                             filterstr_utf8,
                                             attrlist_utf8, attrsonly)

            py_result = convert_ldap_result(ldap_result)

        return py_result

Variable 'py_result' can be not initialized if self.page_size > 0
because it's initialized only in the 'else' block.

** Affects: keystone
     Importance: Undecided
     Assignee: Sergey Nikitin (snikitin)
         Status: In Progress

** Changed in: keystone
     Assignee: (unassigned) => Sergey Nikitin (snikitin)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Keystone.
https://bugs.launchpad.net/bugs/1305056

Title:
  Impossible to use method search_s in BaseLdap if attribute 'page_size'
  is not 0.

Status in OpenStack Identity (Keystone):
  In Progress

Bug description:
  /opt/stack/keystone/keystone/common/ldap/core.py #493-520

  def search_s(self, base, scope,
                   filterstr='(objectClass=*)', attrlist=None, attrsonly=0):
          # NOTE(morganfainberg): Remove "None" singletons from this list, which
          # allows us to set mapped attributes to "None" as defaults in config.
          # Without this filtering, the ldap query would raise a TypeError since
          # attrlist is expected to be an iterable of strings.
          if attrlist is not None:
              attrlist = [attr for attr in attrlist if attr is not None]
          LOG.debug('LDAP search: base=%s scope=%s filterstr=%s '
                    'attrs=%s attrsonly=%s',
                    base, scope, filterstr, attrlist, attrsonly)
          if self.page_size:
              ldap_result = self._paged_search_s(base, scope,
                                                 filterstr, attrlist)
          else:
              base_utf8 = utf8_encode(base)
              filterstr_utf8 = utf8_encode(filterstr)
              if attrlist is None:
                  attrlist_utf8 = None
              else:
                  attrlist_utf8 = map(utf8_encode, attrlist)
              ldap_result = self.conn.search_s(base_utf8, scope,
                                               filterstr_utf8,
                                               attrlist_utf8, attrsonly)

              py_result = convert_ldap_result(ldap_result)

          return py_result

  Variable 'py_result' can be not initialized if self.page_size > 0
  because it's initialized only in the 'else' block.

To manage notifications about this bug go to:
https://bugs.launchpad.net/keystone/+bug/1305056/+subscriptions


Follow ups

References