Skip to content

Commit 20bf3c7

Browse files
maikypediaowen-mc
andauthored
Apply suggestions from code review
Co-authored-by: Owen Mansel-Chan <[email protected]>
1 parent 52007fb commit 20bf3c7

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

go/ql/src/experimental/CWE-287/ImproperLdapAuth.qll

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ abstract class LdapSanitizer extends DataFlow::Node { }
2222
*/
2323
private class GoLdapBindSink extends LdapAuthSink {
2424
GoLdapBindSink() {
25-
exists(Method meth, string base, string t, string m |
26-
t = ["Conn"] and
27-
meth.hasQualifiedName(["gopkg.in/ldap.v2"], t, m) and
25+
exists(Method meth |
26+
meth.hasQualifiedName("gopkg.in/ldap.v2", "Conn", "Bind") and
2827
this = meth.getACall().getArgument(1)
29-
|
30-
base = ["Bind"] and m = base
3128
)
3229
}
3330
}

go/ql/src/experimental/CWE-287/examples/LdapAuthGood.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ func good() interface{} {
99
defer l.Close()
1010

1111
if bindPassword != "" {
12-
l.Bind(bindDN, bindPassword)
12+
err = l.Bind("cn=admin,dc=example,dc=com", bindPassword)
1313
if err != nil {
1414
log.Fatalf("LDAP bind failed: %v", err)
1515
}

go/ql/test/experimental/CWE-287/ImproperLdapAuth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@ func main() {
9595
bad(nil, nil)
9696
good1(nil, nil)
9797
good2(nil, nil)
98-
bad2(nil, nil)
98+
bad2(nil)
9999
}

0 commit comments

Comments
 (0)