@@ -38,8 +38,9 @@ module StaticCreation {
3838 // Some CDN URLs are required to have an integrity attribute. We only add CDNs to that list
3939 // that recommend integrity-checking.
4040 exists ( string hostname , string requiredCheckingHostname |
41- hostname = url .regexpCapture ( "(?i)^(?:https?:)?//([^/]+)/.*\\.js$" , 1 )
42- and isCdnDomainWithCheckingRequired ( requiredCheckingHostname ) and hostname = requiredCheckingHostname
41+ hostname = url .regexpCapture ( "(?i)^(?:https?:)?//([^/]+)/.*\\.js$" , 1 ) and
42+ isCdnDomainWithCheckingRequired ( requiredCheckingHostname ) and
43+ hostname = requiredCheckingHostname
4344 )
4445 }
4546
@@ -87,23 +88,22 @@ module StaticCreation {
8788bindingset [ url]
8889predicate isUrlWithUntrustedDomain ( string url ) {
8990 exists ( string hostname |
90- hostname = url .regexpCapture ( "(?i)^(?:https?:)?//([^/]+)/.*" , 1 )
91- and isUntrustedHostname ( hostname )
91+ hostname = url .regexpCapture ( "(?i)^(?:https?:)?//([^/]+)/.*" , 1 ) and
92+ isUntrustedHostname ( hostname )
9293 )
9394}
9495
9596/** Holds if `hostname` refers to a domain or subdomain that is untrusted. */
9697bindingset [ hostname]
9798predicate isUntrustedHostname ( string hostname ) {
9899 exists ( string domain |
99- ( hostname = domain or hostname .matches ( "%." + domain ) ) and
100+ ( hostname = domain or hostname .matches ( "%." + domain ) ) and
100101 isUntrustedDomain ( domain )
101102 )
102103}
103104
104105// The following predicates are extended in data extensions under javascript/ql/lib/semmle/javascript/security/domains/
105106// and can be extended with custom model packs as necessary.
106-
107107/** Holds for hostnames defined in data extensions */
108108extensible predicate isCdnDomainWithCheckingRequired ( string hostname ) ;
109109
0 commit comments