11private import ruby
2+ private import codeql.ruby.CFG
23private import codeql.ruby.Concepts
34private import codeql.ruby.ApiGraphs
45
@@ -56,16 +57,16 @@ class FaradayHttpRequest extends HTTP::Client::Request::Range {
5657 |
5758 // Either passed as an individual key:value argument, e.g.:
5859 // Faraday.new(..., ssl: {...})
59- isSslOptionsPairDisablingValidation ( arg .asExpr ( ) . getExpr ( ) ) and
60+ isSslOptionsPairDisablingValidation ( arg .asExpr ( ) ) and
6061 disablingNode = arg
6162 or
6263 // Or as a single hash argument, e.g.:
6364 // Faraday.new(..., { ssl: {...} })
64- exists ( DataFlow:: LocalSourceNode optionsNode , Pair p |
65- p = optionsNode .asExpr ( ) .getExpr ( ) . ( HashLiteral ) .getAKeyValuePair ( ) and
65+ exists ( DataFlow:: LocalSourceNode optionsNode , CfgNodes :: ExprNodes :: PairCfgNode p |
66+ p = optionsNode .asExpr ( ) .( CfgNodes :: ExprNodes :: HashLiteralCfgNode ) .getAKeyValuePair ( ) and
6667 isSslOptionsPairDisablingValidation ( p ) and
6768 optionsNode .flowsTo ( arg ) and
68- disablingNode .asExpr ( ) . getExpr ( ) = p
69+ disablingNode .asExpr ( ) = p
6970 )
7071 )
7172 }
@@ -78,10 +79,10 @@ class FaradayHttpRequest extends HTTP::Client::Request::Range {
7879 * containing either `verify: false` or
7980 * `verify_mode: OpenSSL::SSL::VERIFY_NONE`.
8081 */
81- private predicate isSslOptionsPairDisablingValidation ( Pair p ) {
82+ private predicate isSslOptionsPairDisablingValidation ( CfgNodes :: ExprNodes :: PairCfgNode p ) {
8283 exists ( DataFlow:: Node key , DataFlow:: Node value |
83- key .asExpr ( ) . getExpr ( ) = p .getKey ( ) and value . asExpr ( ) . getExpr ( ) = p . getValue ( )
84- |
84+ key .asExpr ( ) = p .getKey ( ) and
85+ value . asExpr ( ) = p . getValue ( ) and
8586 isSymbolLiteral ( key , "ssl" ) and
8687 ( isHashWithVerifyFalse ( value ) or isHashWithVerifyModeNone ( value ) )
8788 )
@@ -101,7 +102,7 @@ private predicate isSymbolLiteral(DataFlow::Node node, string valueText) {
101102 */
102103private predicate isHashWithVerifyFalse ( DataFlow:: Node node ) {
103104 exists ( DataFlow:: LocalSourceNode hash |
104- isVerifyFalsePair ( hash .asExpr ( ) .getExpr ( ) . ( HashLiteral ) .getAKeyValuePair ( ) ) and
105+ isVerifyFalsePair ( hash .asExpr ( ) .( CfgNodes :: ExprNodes :: HashLiteralCfgNode ) .getAKeyValuePair ( ) ) and
105106 hash .flowsTo ( node )
106107 )
107108}
@@ -112,7 +113,7 @@ private predicate isHashWithVerifyFalse(DataFlow::Node node) {
112113 */
113114private predicate isHashWithVerifyModeNone ( DataFlow:: Node node ) {
114115 exists ( DataFlow:: LocalSourceNode hash |
115- isVerifyModeNonePair ( hash .asExpr ( ) .getExpr ( ) . ( HashLiteral ) .getAKeyValuePair ( ) ) and
116+ isVerifyModeNonePair ( hash .asExpr ( ) .( CfgNodes :: ExprNodes :: HashLiteralCfgNode ) .getAKeyValuePair ( ) ) and
116117 hash .flowsTo ( node )
117118 )
118119}
@@ -121,10 +122,10 @@ private predicate isHashWithVerifyModeNone(DataFlow::Node node) {
121122 * Holds if the pair `p` has the key `:verify_mode` and the value
122123 * `OpenSSL::SSL::VERIFY_NONE`.
123124 */
124- private predicate isVerifyModeNonePair ( Pair p ) {
125+ private predicate isVerifyModeNonePair ( CfgNodes :: ExprNodes :: PairCfgNode p ) {
125126 exists ( DataFlow:: Node key , DataFlow:: Node value |
126- key .asExpr ( ) . getExpr ( ) = p .getKey ( ) and value . asExpr ( ) . getExpr ( ) = p . getValue ( )
127- |
127+ key .asExpr ( ) = p .getKey ( ) and
128+ value . asExpr ( ) = p . getValue ( ) and
128129 isSymbolLiteral ( key , "verify_mode" ) and
129130 value = API:: getTopLevelMember ( "OpenSSL" ) .getMember ( "SSL" ) .getMember ( "VERIFY_NONE" ) .getAUse ( )
130131 )
@@ -133,10 +134,10 @@ private predicate isVerifyModeNonePair(Pair p) {
133134/**
134135 * Holds if the pair `p` has the key `:verify` and the value `false`.
135136 */
136- private predicate isVerifyFalsePair ( Pair p ) {
137+ private predicate isVerifyFalsePair ( CfgNodes :: ExprNodes :: PairCfgNode p ) {
137138 exists ( DataFlow:: Node key , DataFlow:: Node value |
138- key .asExpr ( ) . getExpr ( ) = p .getKey ( ) and value . asExpr ( ) . getExpr ( ) = p . getValue ( )
139- |
139+ key .asExpr ( ) = p .getKey ( ) and
140+ value . asExpr ( ) = p . getValue ( ) and
140141 isSymbolLiteral ( key , "verify" ) and
141142 isFalse ( value )
142143 )
0 commit comments