@@ -42,11 +42,12 @@ module StaticCreation {
4242 predicate isCdnUrlWithCheckingRequired ( string url ) {
4343 // Some CDN URLs are required to have an integrity attribute. We only add CDNs to that list
4444 // that recommend integrity-checking.
45- url .regexpMatch ( "(?i)" +
45+ url .regexpMatch ( "(?i)^https?:// " +
4646 [
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$" )
5051 }
5152
5253 /** A script element that refers to untrusted content. */
@@ -56,9 +57,7 @@ module StaticCreation {
5657 isUntrustedSourceUrl ( super .getSourcePath ( ) )
5758 }
5859
59- override string getProblem ( ) {
60- result = "HTML script element loaded using unencrypted connection."
61- }
60+ override string getProblem ( ) { result = "Script loaded using unencrypted connection." }
6261 }
6362
6463 /** A script element that refers to untrusted content. */
@@ -77,9 +76,7 @@ module StaticCreation {
7776 class IframeElementWithUntrustedContent extends AddsUntrustedUrl instanceof HTML:: IframeElement {
7877 IframeElementWithUntrustedContent ( ) { isUntrustedSourceUrl ( super .getSourcePath ( ) ) }
7978
80- override string getProblem ( ) {
81- result = "HTML iframe element loaded using unencrypted connection."
82- }
79+ override string getProblem ( ) { result = "Iframe loaded using unencrypted connection." }
8380 }
8481}
8582
@@ -153,14 +150,17 @@ module DynamicCreation {
153150 string name ;
154151
155152 IframeOrScriptSrcAssignment ( ) {
153+ name = [ "script" , "iframe" ] and
156154 exists ( DataFlow:: Node n | n .asExpr ( ) = this |
157155 isAssignedToSrcAttribute ( name , n ) and
158156 n = urlTrackedFromUnsafeSourceLiteral ( )
159157 )
160158 }
161159
162160 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."
164164 }
165165 }
166166}
0 commit comments