@@ -13,7 +13,12 @@ module InsecureDownload {
13
13
/**
14
14
* A data flow source for download of sensitive file through insecure connection.
15
15
*/
16
- abstract class Source extends DataFlow:: Node { }
16
+ abstract class Source extends DataFlow:: Node {
17
+ /**
18
+ * Gets a flow-label for this source
19
+ */
20
+ abstract DataFlow:: FlowLabel getALabel ( ) ;
21
+ }
17
22
18
23
/**
19
24
* A data flow sink for download of sensitive file through insecure connection.
@@ -23,25 +28,50 @@ module InsecureDownload {
23
28
* Gets the call that downloads the sensitive file.
24
29
*/
25
30
abstract DataFlow:: Node getDownloadCall ( ) ;
31
+
32
+ /**
33
+ * Gets a flow-label where this sink is vulnerable.
34
+ */
35
+ abstract DataFlow:: FlowLabel getALabel ( ) ;
26
36
}
27
37
28
38
/**
29
39
* A sanitizer for download of sensitive file through insecure connection.
30
40
*/
31
41
abstract class Sanitizer extends DataFlow:: Node { }
32
42
43
+ module Label {
44
+ /**
45
+ * A flow-label for file URLs that are both sensitive and downloaded over an insecure connection.
46
+ */
47
+ class SensitiveInsecureURL extends DataFlow:: FlowLabel {
48
+ SensitiveInsecureURL ( ) { this = "sensitiveInsecure" }
49
+ }
50
+
51
+ class InsecureURL extends DataFlow:: FlowLabel {
52
+ InsecureURL ( ) { this = "insecure" }
53
+ }
54
+ }
55
+
33
56
/**
34
57
* A HTTP or FTP URL that refers to a file with a sensitive file extension,
35
58
* seen as a source for download of sensitive file through insecure connection.
36
59
*/
37
60
class SensitiveFileUrl extends Source {
61
+ string str ;
62
+
38
63
SensitiveFileUrl ( ) {
39
- exists ( string str | str = this .getStringValue ( ) |
40
- str .regexpMatch ( "http://.*|ftp://.*" ) and
41
- exists ( string suffix | suffix = unsafeExtension ( ) |
42
- str .suffix ( str .length ( ) - suffix .length ( ) - 1 ) .toLowerCase ( ) = "." + suffix
43
- )
44
- )
64
+ str = this .getStringValue ( ) and
65
+ str .regexpMatch ( "http://.*|ftp://.*" )
66
+ }
67
+
68
+ override DataFlow:: FlowLabel getALabel ( ) {
69
+ result instanceof Label:: InsecureURL
70
+ or
71
+ exists ( string suffix | suffix = unsafeExtension ( ) |
72
+ str .suffix ( str .length ( ) - suffix .length ( ) - 1 ) .toLowerCase ( ) = "." + suffix
73
+ ) and
74
+ result instanceof Label:: SensitiveInsecureURL
45
75
}
46
76
}
47
77
@@ -58,13 +88,17 @@ module InsecureDownload {
58
88
59
89
/**
60
90
* A url downloaded by a client-request, seen as a sink for download of
61
- * sensitive file through insecure connection.a
91
+ * sensitive file through insecure connection.
62
92
*/
63
93
class ClientRequestURL extends Sink {
64
94
ClientRequest request ;
65
95
66
96
ClientRequestURL ( ) { this = request .getUrl ( ) }
67
97
68
98
override DataFlow:: Node getDownloadCall ( ) { result = request }
99
+
100
+ override DataFlow:: FlowLabel getALabel ( ) {
101
+ result instanceof Label:: SensitiveInsecureURL // TODO: Also non-sensitive.
102
+ }
69
103
}
70
104
}
0 commit comments