Skip to content

Commit 97f8d1f

Browse files
committed
add getValue() method
1 parent e60fa6f commit 97f8d1f

File tree

1 file changed

+11
-11
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks

1 file changed

+11
-11
lines changed

ruby/ql/lib/codeql/ruby/frameworks/Ldap.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ module NetLdap {
4545
NetLdapConnection() { this in [ldap().getAnInstantiation(), ldap().getAMethodCall("open")] }
4646

4747
predicate usesSsl() {
48-
[
49-
this.getKeywordArgument("encryption"), this.getAMethodCall("encryption").getArgument(0),
50-
this.getAMethodCall("encryption").getKeywordArgument("method")
51-
].getConstantValue().isStringlikeValue("simple_tls")
48+
getValue(this, "encryption").getConstantValue().isStringlikeValue("simple_tls")
5249
}
5350

5451
DataFlow::Node getAuthValue(string arg) {
@@ -88,13 +85,7 @@ module NetLdap {
8885

8986
NetLdapBind() { this = l.getAMethodCall("bind") }
9087

91-
override DataFlow::Node getHost() {
92-
result =
93-
[
94-
l.getKeywordArgument("host"), l.getAMethodCall("host").getArgument(0),
95-
l.getAMethodCall("host").getKeywordArgument("method")
96-
]
97-
}
88+
override DataFlow::Node getHost() { result = getValue(l, "host") }
9889

9990
override DataFlow::Node getPassword() {
10091
result = l.getAuthValue("password") or
@@ -103,4 +94,13 @@ module NetLdap {
10394

10495
override predicate usesSsl() { l.usesSsl() }
10596
}
97+
98+
/** LDAP Attribute value */
99+
DataFlow::Node getValue(NetLdapConnection l, string attr) {
100+
result =
101+
[
102+
l.getKeywordArgument(attr), l.getAMethodCall(attr).getArgument(0),
103+
l.getAMethodCall(attr).getKeywordArgument(attr)
104+
]
105+
}
106106
}

0 commit comments

Comments
 (0)