@@ -10,14 +10,52 @@ import javascript
1010 * Classes and predicates for reasoning about download of sensitive file through insecure connection vulnerabilities.
1111 */
1212module 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+
1348 /**
1449 * A data flow source for download of sensitive file through insecure connection.
1550 */
1651 abstract class Source extends DataFlow:: Node {
1752 /**
18- * Gets a flow-label for this source.
53+ * Gets a flow state for this source.
1954 */
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 ( ) }
2159 }
2260
2361 /**
@@ -30,9 +68,14 @@ module InsecureDownload {
3068 abstract DataFlow:: Node getDownloadCall ( ) ;
3169
3270 /**
33- * Gets a flow-label where this sink is vulnerable.
71+ * Gets a flow state where this sink is vulnerable.
3472 */
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 ( ) }
3679 }
3780
3881 /**
@@ -71,11 +114,11 @@ module InsecureDownload {
71114 str .regexpMatch ( "http://.*|ftp://.*" )
72115 }
73116
74- override DataFlow :: FlowLabel getALabel ( ) {
75- result instanceof Label :: InsecureUrl
117+ override FlowState getAFlowState ( ) {
118+ result = FlowState :: insecureUrl ( )
76119 or
77120 hasUnsafeExtension ( str ) and
78- result instanceof Label :: SensitiveInsecureUrl
121+ result = FlowState :: sensitiveInsecureUrl ( )
79122 }
80123 }
81124
@@ -113,11 +156,11 @@ module InsecureDownload {
113156
114157 override DataFlow:: Node getDownloadCall ( ) { result = request }
115158
116- override DataFlow :: FlowLabel getALabel ( ) {
117- result instanceof Label :: SensitiveInsecureUrl
159+ override FlowState getAFlowState ( ) {
160+ result = FlowState :: sensitiveInsecureUrl ( )
118161 or
119162 hasUnsafeExtension ( request .getASavePath ( ) .getStringValue ( ) ) and
120- result instanceof Label :: InsecureUrl
163+ result = FlowState :: insecureUrl ( )
121164 }
122165 }
123166
@@ -145,7 +188,7 @@ module InsecureDownload {
145188 )
146189 }
147190
148- override DataFlow :: FlowLabel getALabel ( ) { result instanceof Label :: InsecureUrl }
191+ override FlowState getAFlowState ( ) { result = FlowState :: insecureUrl ( ) }
149192
150193 override DataFlow:: Node getDownloadCall ( ) { result = request }
151194 }
0 commit comments