@@ -10,14 +10,52 @@ import javascript
10
10
* Classes and predicates for reasoning about download of sensitive file through insecure connection vulnerabilities.
11
11
*/
12
12
module InsecureDownload {
13
+ private newtype TFlowState =
14
+ TSensitiveInsecureUrl ( ) or
15
+ TInsecureUrl ( )
16
+
17
+ /** A flow state to associate with a tracked value. */
18
+ class FlowState extends TFlowState {
19
+ /** Gets a string representation fo this flow state */
20
+ string toString ( ) {
21
+ this = TSensitiveInsecureUrl ( ) and result = "sensitive-insecure-url"
22
+ or
23
+ this = TInsecureUrl ( ) and result = "insecure-url"
24
+ }
25
+
26
+ deprecated DataFlow:: FlowLabel toFlowLabel ( ) {
27
+ this = TSensitiveInsecureUrl ( ) and result instanceof Label:: SensitiveInsecureUrl
28
+ or
29
+ this = TInsecureUrl ( ) and result instanceof Label:: InsecureUrl
30
+ }
31
+ }
32
+
33
+ /** Predicates for working with flow states. */
34
+ module FlowState {
35
+ deprecated FlowState fromFlowLabel ( DataFlow:: FlowLabel label ) { result .toFlowLabel ( ) = label }
36
+
37
+ /**
38
+ * A file URL that is both sensitive and downloaded over an insecure connection.
39
+ */
40
+ FlowState sensitiveInsecureUrl ( ) { result = TSensitiveInsecureUrl ( ) }
41
+
42
+ /**
43
+ * A URL that is downloaded over an insecure connection.
44
+ */
45
+ FlowState insecureUrl ( ) { result = TInsecureUrl ( ) }
46
+ }
47
+
13
48
/**
14
49
* A data flow source for download of sensitive file through insecure connection.
15
50
*/
16
51
abstract class Source extends DataFlow:: Node {
17
52
/**
18
- * Gets a flow-label for this source.
53
+ * Gets a flow state for this source.
19
54
*/
20
- abstract DataFlow:: FlowLabel getALabel ( ) ;
55
+ FlowState getAFlowState ( ) { result = FlowState:: insecureUrl ( ) }
56
+
57
+ /** DEPRECATED. Use `getAFlowState()` instead. */
58
+ deprecated DataFlow:: FlowLabel getALabel ( ) { result = this .getAFlowState ( ) .toFlowLabel ( ) }
21
59
}
22
60
23
61
/**
@@ -30,9 +68,14 @@ module InsecureDownload {
30
68
abstract DataFlow:: Node getDownloadCall ( ) ;
31
69
32
70
/**
33
- * Gets a flow-label where this sink is vulnerable.
71
+ * Gets a flow state where this sink is vulnerable.
34
72
*/
35
- abstract DataFlow:: FlowLabel getALabel ( ) ;
73
+ FlowState getAFlowState ( ) {
74
+ result = [ FlowState:: insecureUrl ( ) , FlowState:: sensitiveInsecureUrl ( ) ]
75
+ }
76
+
77
+ /** DEPRECATED. Use `getAFlowState()` instead. */
78
+ deprecated DataFlow:: FlowLabel getALabel ( ) { result = this .getAFlowState ( ) .toFlowLabel ( ) }
36
79
}
37
80
38
81
/**
@@ -71,11 +114,11 @@ module InsecureDownload {
71
114
str .regexpMatch ( "http://.*|ftp://.*" )
72
115
}
73
116
74
- override DataFlow :: FlowLabel getALabel ( ) {
75
- result instanceof Label :: InsecureUrl
117
+ override FlowState getAFlowState ( ) {
118
+ result = FlowState :: insecureUrl ( )
76
119
or
77
120
hasUnsafeExtension ( str ) and
78
- result instanceof Label :: SensitiveInsecureUrl
121
+ result = FlowState :: sensitiveInsecureUrl ( )
79
122
}
80
123
}
81
124
@@ -113,11 +156,11 @@ module InsecureDownload {
113
156
114
157
override DataFlow:: Node getDownloadCall ( ) { result = request }
115
158
116
- override DataFlow :: FlowLabel getALabel ( ) {
117
- result instanceof Label :: SensitiveInsecureUrl
159
+ override FlowState getAFlowState ( ) {
160
+ result = FlowState :: sensitiveInsecureUrl ( )
118
161
or
119
162
hasUnsafeExtension ( request .getASavePath ( ) .getStringValue ( ) ) and
120
- result instanceof Label :: InsecureUrl
163
+ result = FlowState :: insecureUrl ( )
121
164
}
122
165
}
123
166
@@ -145,7 +188,7 @@ module InsecureDownload {
145
188
)
146
189
}
147
190
148
- override DataFlow :: FlowLabel getALabel ( ) { result instanceof Label :: InsecureUrl }
191
+ override FlowState getAFlowState ( ) { result = FlowState :: insecureUrl ( ) }
149
192
150
193
override DataFlow:: Node getDownloadCall ( ) { result = request }
151
194
}
0 commit comments