Skip to content

Commit 6da4aa0

Browse files
committed
JS: Tweak performance of CorsOriginHeaderWithAssociatedCredentialHeader
On databases with a large number of Exprs, it can be better to start with the set of route handlers, then find their response headers, then find the expression values set in those headers.
1 parent a82b5ed commit 6da4aa0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/CorsMisconfigurationForCredentialsCustomizations.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ module CorsMisconfigurationForCredentials {
5050
|
5151
routeHandler.getAResponseHeader(_) = origin and
5252
routeHandler.getAResponseHeader(_) = credentials and
53-
origin.definesExplicitly("access-control-allow-origin", this.asExpr()) and
54-
credentials.definesExplicitly("access-control-allow-credentials", credentialsValue)
53+
// Performance optimisation: start with the set of all route handlers
54+
// rather than the set of all exprs.
55+
pragma[only_bind_into](origin)
56+
.definesExplicitly("access-control-allow-origin", this.asExpr()) and
57+
pragma[only_bind_into](credentials)
58+
.definesExplicitly("access-control-allow-credentials", credentialsValue)
5559
|
5660
credentialsValue.mayHaveBooleanValue(true) or
5761
credentialsValue.mayHaveStringValue("true")

0 commit comments

Comments
 (0)