@@ -71,14 +71,19 @@ private predicate isSslOptionsPairDisablingValidation(Pair p) {
71
71
exists ( DataFlow:: Node key , DataFlow:: Node value |
72
72
key .asExpr ( ) .getExpr ( ) = p .getKey ( ) and value .asExpr ( ) .getExpr ( ) = p .getValue ( )
73
73
|
74
- exists ( DataFlow:: LocalSourceNode literal |
75
- literal .asExpr ( ) .getExpr ( ) .( SymbolLiteral ) .getValueText ( ) = "ssl" and
76
- literal .flowsTo ( key )
77
- ) and
74
+ isSymbolLiteral ( key , "ssl" ) and
78
75
( isHashWithVerifyFalse ( value ) or isHashWithVerifyModeNone ( value ) )
79
76
)
80
77
}
81
78
79
+ /** Holds if `node` represents the symbol literal with the given `valueText`. */
80
+ private predicate isSymbolLiteral ( DataFlow:: Node node , string valueText ) {
81
+ exists ( DataFlow:: LocalSourceNode literal |
82
+ literal .asExpr ( ) .getExpr ( ) .( SymbolLiteral ) .getValueText ( ) = valueText and
83
+ literal .flowsTo ( node )
84
+ )
85
+ }
86
+
82
87
/**
83
88
* Holds if `node` represents a hash containing the key-value pair
84
89
* `verify: false`.
@@ -109,10 +114,7 @@ private predicate isVerifyModeNonePair(Pair p) {
109
114
exists ( DataFlow:: Node key , DataFlow:: Node value |
110
115
key .asExpr ( ) .getExpr ( ) = p .getKey ( ) and value .asExpr ( ) .getExpr ( ) = p .getValue ( )
111
116
|
112
- exists ( DataFlow:: LocalSourceNode literal |
113
- literal .asExpr ( ) .getExpr ( ) .( SymbolLiteral ) .getValueText ( ) = "verify_mode" and
114
- literal .flowsTo ( key )
115
- ) and
117
+ isSymbolLiteral ( key , "verify_mode" ) and
116
118
value = API:: getTopLevelMember ( "OpenSSL" ) .getMember ( "SSL" ) .getMember ( "VERIFY_NONE" ) .getAUse ( )
117
119
)
118
120
}
@@ -124,21 +126,15 @@ private predicate isVerifyFalsePair(Pair p) {
124
126
exists ( DataFlow:: Node key , DataFlow:: Node value |
125
127
key .asExpr ( ) .getExpr ( ) = p .getKey ( ) and value .asExpr ( ) .getExpr ( ) = p .getValue ( )
126
128
|
127
- exists ( DataFlow:: LocalSourceNode literal |
128
- literal .asExpr ( ) .getExpr ( ) .( SymbolLiteral ) .getValueText ( ) = "verify" and
129
- literal .flowsTo ( key )
130
- ) and
131
- isFalsey ( value )
129
+ isSymbolLiteral ( key , "verify" ) and
130
+ isFalse ( value )
132
131
)
133
132
}
134
133
135
- /** Holds if `node` contains `0` or `false`. */
136
- private predicate isFalsey ( DataFlow:: Node node ) {
134
+ /** Holds if `node` can contain the Boolean value `false`. */
135
+ private predicate isFalse ( DataFlow:: Node node ) {
137
136
exists ( DataFlow:: LocalSourceNode literal |
138
- (
139
- literal .asExpr ( ) .getExpr ( ) .( BooleanLiteral ) .isFalse ( ) or
140
- literal .asExpr ( ) .getExpr ( ) .( IntegerLiteral ) .getValue ( ) = 0
141
- ) and
137
+ literal .asExpr ( ) .getExpr ( ) .( BooleanLiteral ) .isFalse ( ) and
142
138
literal .flowsTo ( node )
143
139
)
144
140
}
0 commit comments