@@ -281,6 +281,66 @@ objectSid:: AQUAAAAAAAUVAAAAF8sUcR3r8QcekDXQw9wAAA==
281281 require .Equal (t , "cn=user1" , res .Results [0 ].Dn )
282282 },
283283 },
284+ {
285+ name : "ldap filter objectSid using AD style with invalid revision" ,
286+ input : `{ "files": [ "./users.ldif" ] }` ,
287+ reader : & dynamictest.Reader {Data : map [string ]* dynamic.Config {
288+ "file:/users.ldif" : {Raw : []byte (`
289+ dn:
290+ namingContexts: dc=example_domain_name
291+ subschemaSubentry: cn=schema
292+
293+ dn: cn=schema
294+ objectClass: top
295+ objectClass: subschema
296+ attributeTypes: ( 1.2.3.4.5.6.7.8 NAME 'objectSid' DESC 'objectSid' EQUALITY activeDirectoryObjectSidMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
297+ ` )},
298+ }},
299+ test : func (t * testing.T , h ldap.Handler , log * test.Hook , err error ) {
300+ require .NoError (t , err )
301+
302+ rr := ldaptest .NewRecorder ()
303+ h .ServeLDAP (rr , ldaptest .NewRequest (0 , & ldap.SearchRequest {
304+ Scope : ldap .ScopeWholeSubtree ,
305+ Filter : fmt .Sprintf ("(objectSid=S-foo-5-21-1234567890-1234567890-1234567890-1001)" ),
306+ }))
307+ res := rr .Message .(* ldap.SearchResponse )
308+
309+ require .Len (t , res .Results , 0 )
310+ require .Len (t , log .Entries , 2 )
311+ require .Equal (t , "ldap: filter syntax error: invalid SID 'S-foo-5-21-1234567890-1234567890-1234567890-1001': invalid SID revision value value 'foo' at position: 0" , log .Entries [1 ].Message )
312+ },
313+ },
314+ {
315+ name : "ldap filter objectSid using AD style with revision to high" ,
316+ input : `{ "files": [ "./users.ldif" ] }` ,
317+ reader : & dynamictest.Reader {Data : map [string ]* dynamic.Config {
318+ "file:/users.ldif" : {Raw : []byte (`
319+ dn:
320+ namingContexts: dc=example_domain_name
321+ subschemaSubentry: cn=schema
322+
323+ dn: cn=schema
324+ objectClass: top
325+ objectClass: subschema
326+ attributeTypes: ( 1.2.3.4.5.6.7.8 NAME 'objectSid' DESC 'objectSid' EQUALITY activeDirectoryObjectSidMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
327+ ` )},
328+ }},
329+ test : func (t * testing.T , h ldap.Handler , log * test.Hook , err error ) {
330+ require .NoError (t , err )
331+
332+ rr := ldaptest .NewRecorder ()
333+ h .ServeLDAP (rr , ldaptest .NewRequest (0 , & ldap.SearchRequest {
334+ Scope : ldap .ScopeWholeSubtree ,
335+ Filter : fmt .Sprintf ("(objectSid=S-300-5-21-1234567890-1234567890-1234567890-1001)" ),
336+ }))
337+ res := rr .Message .(* ldap.SearchResponse )
338+
339+ require .Len (t , res .Results , 0 )
340+ require .Len (t , log .Entries , 2 )
341+ require .Equal (t , "ldap: filter syntax error: invalid SID 'S-300-5-21-1234567890-1234567890-1234567890-1001': SID revision value '5' out of byte range (0-255) at position: 0" , log .Entries [1 ].Message )
342+ },
343+ },
284344 {
285345 name : "ldap filter objectSid using AD style with invalid authId" ,
286346 input : `{ "files": [ "./users.ldif" ] }` ,
0 commit comments