Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue 1775: in ldapquery, validation out of bounds query should be case insensitive as ldap is. #1756

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/security/ldapquery/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (o *LDAPQueryOnAttribute) NewSearchRequest(attributeValue string, attribute
if err != nil {
return nil, fmt.Errorf("could not search by dn, invalid dn value: %v", err)
}
if !baseDN.AncestorOf(dn) && !baseDN.Equal(dn) {
if !baseDN.AncestorOfFold(dn) && !baseDN.EqualFold(dn) {
return nil, NewQueryOutOfBoundsError(attributeValue, o.BaseDN)
}
return o.buildDNQuery(attributeValue, attributes), nil
Expand Down
28 changes: 28 additions & 0 deletions pkg/security/ldapquery/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"reflect"
"strings"
"testing"

"github.com/go-ldap/ldap/v3"
Expand Down Expand Up @@ -178,6 +179,33 @@ func TestNewSearchRequest(t *testing.T) {
expectedRequest: nil,
expectedError: true,
},
{
name: "dn query should not be out of bounds",
options: LDAPQueryOnAttribute{
LDAPQuery: LDAPQuery{
BaseDN: strings.ToUpper(DefaultBaseDN),
Scope: DefaultScope,
DerefAliases: DefaultDerefAliases,
TimeLimit: DefaultTimeLimit,
Filter: DefaultFilter,
},
QueryAttribute: "DN",
},
attributeValue: "uid=john,o=users,dc=example,dc=com",
attributes: DefaultAttributes,
expectedRequest: &ldap.SearchRequest{
BaseDN: "uid=john,o=users,dc=example,dc=com",
Scope: ldap.ScopeBaseObject,
DerefAliases: int(DefaultDerefAliases),
SizeLimit: DefaultSizeLimit,
TimeLimit: DefaultTimeLimit,
TypesOnly: DefaultTypesOnly,
Filter: "(objectClass=*)",
Attributes: DefaultAttributes,
Controls: DefaultControls,
},
expectedError: false,
},
{
name: "attribute query no attributes with paging",
options: LDAPQueryOnAttribute{
Expand Down