@@ -42,11 +42,12 @@ module StaticCreation {
42
42
predicate isCdnUrlWithCheckingRequired ( string url ) {
43
43
// Some CDN URLs are required to have an integrity attribute. We only add CDNs to that list
44
44
// that recommend integrity-checking.
45
- url .regexpMatch ( "(?i)" +
45
+ url .regexpMatch ( "(?i)^https?:// " +
46
46
[
47
- "^https?://code\\.jquery\\.com/.*\\.js$" , "^https?://cdnjs\\.cloudflare\\.com/.*\\.js$" ,
48
- "^https?://cdnjs\\.com/.*\\.js$"
49
- ] )
47
+ "code\\.jquery\\.com" , //
48
+ "cdnjs\\.cloudflare\\.com" , //
49
+ "cdnjs\\.com" //
50
+ ] + "/.*\\.js$" )
50
51
}
51
52
52
53
/** A script element that refers to untrusted content. */
@@ -56,9 +57,7 @@ module StaticCreation {
56
57
isUntrustedSourceUrl ( super .getSourcePath ( ) )
57
58
}
58
59
59
- override string getProblem ( ) {
60
- result = "HTML script element loaded using unencrypted connection."
61
- }
60
+ override string getProblem ( ) { result = "Script loaded using unencrypted connection." }
62
61
}
63
62
64
63
/** A script element that refers to untrusted content. */
@@ -77,9 +76,7 @@ module StaticCreation {
77
76
class IframeElementWithUntrustedContent extends AddsUntrustedUrl instanceof HTML:: IframeElement {
78
77
IframeElementWithUntrustedContent ( ) { isUntrustedSourceUrl ( super .getSourcePath ( ) ) }
79
78
80
- override string getProblem ( ) {
81
- result = "HTML iframe element loaded using unencrypted connection."
82
- }
79
+ override string getProblem ( ) { result = "Iframe loaded using unencrypted connection." }
83
80
}
84
81
}
85
82
@@ -153,14 +150,17 @@ module DynamicCreation {
153
150
string name ;
154
151
155
152
IframeOrScriptSrcAssignment ( ) {
153
+ name = [ "script" , "iframe" ] and
156
154
exists ( DataFlow:: Node n | n .asExpr ( ) = this |
157
155
isAssignedToSrcAttribute ( name , n ) and
158
156
n = urlTrackedFromUnsafeSourceLiteral ( )
159
157
)
160
158
}
161
159
162
160
override string getProblem ( ) {
163
- result = "HTML " + name + " element loaded using unencrypted connection."
161
+ name = "script" and result = "Script loaded using unencrypted connection."
162
+ or
163
+ name = "iframe" and result = "Iframe loaded using unencrypted connection."
164
164
}
165
165
}
166
166
}
0 commit comments