@@ -36,16 +36,27 @@ private class GoLdapBindSink extends LdapAuthSink {
36
36
*/
37
37
class RegexpCheckAsBarrierGuard extends RegexpCheckBarrier , LdapSanitizer { }
38
38
39
+ /**
40
+ * An empty string.
41
+ */
42
+ class EmptyString extends DataFlow:: Node {
43
+ EmptyString ( ) { this .asExpr ( ) .getStringValue ( ) = "" }
44
+ }
45
+
39
46
private predicate equalityAsSanitizerGuard ( DataFlow:: Node g , Expr e , boolean outcome ) {
40
- exists ( DataFlow:: Node passwd , DataFlow:: EqualityTestNode eq |
47
+ exists ( DataFlow:: Node nonConstNode , DataFlow :: Node constNode , DataFlow:: EqualityTestNode eq |
41
48
g = eq and
42
- passwd = eq .getAnOperand ( ) and
43
- e = passwd .asExpr ( ) and
49
+ nonConstNode = eq .getAnOperand ( ) and
50
+ not nonConstNode .isConst ( ) and
51
+ constNode = eq .getAnOperand ( ) and
52
+ constNode .isConst ( ) and
53
+ e = nonConstNode .asExpr ( ) and
44
54
(
45
- eq .getAnOperand ( ) .getStringValue ( ) .length ( ) > 0 and outcome = eq .getPolarity ( )
55
+ // If `constNode` is not an empty string a comparison is considered a sanitizer
56
+ not constNode instanceof EmptyString and outcome = eq .getPolarity ( )
46
57
or
47
- eq . getAnOperand ( ) . getStringValue ( ) . length ( ) = 0 and
48
- outcome = eq .getPolarity ( ) .booleanNot ( )
58
+ // If `constNode` is an empty string a not comparison is considered a sanitizer
59
+ constNode instanceof EmptyString and outcome = eq .getPolarity ( ) .booleanNot ( )
49
60
)
50
61
)
51
62
}
@@ -60,12 +71,6 @@ class EqualityAsSanitizerGuard extends LdapSanitizer {
60
71
}
61
72
}
62
73
63
- /**
64
- */
65
- class EmptyString extends DataFlow:: Node {
66
- EmptyString ( ) { this .asExpr ( ) .getStringValue ( ) = "" }
67
- }
68
-
69
74
/**
70
75
* A taint-tracking configuration for reasoning about when an `UntrustedFlowSource`
71
76
* flows into an argument or field that is vulnerable to Improper LDAP Authentication.
0 commit comments