File tree Expand file tree Collapse file tree
python/ql/src/Security/CWE-327 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,10 +22,28 @@ class SSLDefaultContextCreation extends ContextCreation {
2222 override DataFlow:: CfgNode getProtocol ( ) { none ( ) }
2323}
2424
25+ /** Gets a reference to an `ssl.Context` instance. */
26+ private DataFlow:: LocalSourceNode sslContextInstance ( DataFlow:: TypeTracker t ) {
27+ t .start ( ) and
28+ result = API:: moduleImport ( "ssl" ) .getMember ( [ "SSLContext" , "create_default_context" ] ) .getACall ( )
29+ or
30+ exists ( DataFlow:: TypeTracker t2 | result = sslContextInstance ( t2 ) .track ( t2 , t ) )
31+ }
32+
33+ /** Gets a reference to an `ssl.Context` instance. */
34+ DataFlow:: Node sslContextInstance ( ) {
35+ sslContextInstance ( DataFlow:: TypeTracker:: end ( ) ) .flowsTo ( result )
36+ }
37+
2538class WrapSocketCall extends ConnectionCreation {
2639 override CallNode node ;
2740
28- WrapSocketCall ( ) { node .getFunction ( ) .( AttrNode ) .getName ( ) = "wrap_socket" }
41+ WrapSocketCall ( ) {
42+ exists ( DataFlow:: AttrRead call | node .getFunction ( ) = call .asCfgNode ( ) |
43+ call .getAttributeName ( ) = "wrap_socket" and
44+ call .getObject ( ) = sslContextInstance ( )
45+ )
46+ }
2947
3048 override DataFlow:: CfgNode getContext ( ) {
3149 result .getNode ( ) = node .getFunction ( ) .( AttrNode ) .getObject ( )
You can’t perform that action at this time.
0 commit comments