@@ -13,7 +13,12 @@ module InsecureDownload {
1313 /**
1414 * A data flow source for download of sensitive file through insecure connection.
1515 */
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+ }
1722
1823 /**
1924 * A data flow sink for download of sensitive file through insecure connection.
@@ -23,25 +28,50 @@ module InsecureDownload {
2328 * Gets the call that downloads the sensitive file.
2429 */
2530 abstract DataFlow:: Node getDownloadCall ( ) ;
31+
32+ /**
33+ * Gets a flow-label where this sink is vulnerable.
34+ */
35+ abstract DataFlow:: FlowLabel getALabel ( ) ;
2636 }
2737
2838 /**
2939 * A sanitizer for download of sensitive file through insecure connection.
3040 */
3141 abstract class Sanitizer extends DataFlow:: Node { }
3242
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+
3356 /**
3457 * A HTTP or FTP URL that refers to a file with a sensitive file extension,
3558 * seen as a source for download of sensitive file through insecure connection.
3659 */
3760 class SensitiveFileUrl extends Source {
61+ string str ;
62+
3863 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
4575 }
4676 }
4777
@@ -58,13 +88,17 @@ module InsecureDownload {
5888
5989 /**
6090 * 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.
6292 */
6393 class ClientRequestURL extends Sink {
6494 ClientRequest request ;
6595
6696 ClientRequestURL ( ) { this = request .getUrl ( ) }
6797
6898 override DataFlow:: Node getDownloadCall ( ) { result = request }
99+
100+ override DataFlow:: FlowLabel getALabel ( ) {
101+ result instanceof Label:: SensitiveInsecureURL // TODO: Also non-sensitive.
102+ }
69103 }
70104}
0 commit comments