@@ -37,6 +37,15 @@ module Pycurl {
37
37
/** Gets a reference to an instance of `pycurl.Curl`. */
38
38
private API:: Node instance ( ) { result = classRef ( ) .getReturn ( ) }
39
39
40
+ /** Gets a reference to `pycurl.Curl.setopt`. */
41
+ private API:: Node setopt ( ) { result = instance ( ) .getMember ( "setopt" ) }
42
+
43
+ /** Gets a reference to the constant `pycurl.Curl.SSL_VERIFYPEER`. */
44
+ private API:: Node sslverifypeer ( ) {
45
+ result = API:: moduleImport ( "pycurl" ) .getMember ( "SSL_VERIFYPEER" ) or
46
+ result = instance ( ) .getMember ( "SSL_VERIFYPEER" )
47
+ }
48
+
40
49
/**
41
50
* When the first parameter value of the `setopt` function is set to `pycurl.URL`,
42
51
* the second parameter value is the request resource link.
@@ -45,7 +54,7 @@ module Pycurl {
45
54
*/
46
55
private class OutgoingRequestCall extends Http:: Client:: Request:: Range , DataFlow:: CallCfgNode {
47
56
OutgoingRequestCall ( ) {
48
- this = instance ( ) . getMember ( " setopt" ) .getACall ( ) and
57
+ this = setopt ( ) .getACall ( ) and
49
58
this .getArg ( 0 ) .asCfgNode ( ) .( AttrNode ) .getName ( ) = "URL"
50
59
}
51
60
@@ -58,9 +67,37 @@ module Pycurl {
58
67
override predicate disablesCertificateValidation (
59
68
DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
60
69
) {
61
- // TODO: Look into disabling certificate validation
62
70
none ( )
63
71
}
64
72
}
73
+
74
+ /**
75
+ * When the first parameter value of the `setopt` function is set to `SSL_VERIFYPEER` or `SSL_VERIFYHOST`,
76
+ * the second parameter value disables or enable SSL certifiacte verification.
77
+ *
78
+ * See http://pycurl.io/docs/latest/curlobject.html#pycurl.Curl.setopt.
79
+ */
80
+ private class CurlSslCall extends Http:: Client:: Request:: Range , DataFlow:: CallCfgNode {
81
+ CurlSslCall ( ) {
82
+ this = setopt ( ) .getACall ( ) and
83
+ this .getArg ( 0 ) .asCfgNode ( ) .( AttrNode ) .getName ( ) = [ "SSL_VERIFYPEER" , "SSL_VERIFYHOST" ]
84
+ }
85
+
86
+ override DataFlow:: Node getAUrlPart ( ) { none ( ) }
87
+
88
+ override string getFramework ( ) { result = "pycurl.Curl" }
89
+
90
+ override predicate disablesCertificateValidation (
91
+ DataFlow:: Node disablingNode , DataFlow:: Node argumentOrigin
92
+ ) {
93
+ sslverifypeer ( ) .getAValueReachableFromSource ( ) = this .getArg ( 0 ) and
94
+ (
95
+ this .getArg ( 1 ) .asExpr ( ) .( IntegerLiteral ) .getValue ( ) = 0
96
+ or
97
+ this .getArg ( 1 ) .asExpr ( ) .( BooleanLiteral ) .booleanValue ( ) = false
98
+ ) and
99
+ ( disablingNode = this and argumentOrigin = this .getArg ( 1 ) )
100
+ }
101
+ }
65
102
}
66
103
}
0 commit comments