Skip to content

Commit 4f68f60

Browse files
Apply review
Co-authored-by: Erik Krogh Kristensen <[email protected]>
1 parent 87cac2a commit 4f68f60

File tree

1 file changed

+7
-14
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+7
-14
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Express.qll

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,24 +1077,17 @@ module Express {
10771077
* An express route setup configured with the `cors` package.
10781078
*/
10791079
class CorsConfiguration extends DataFlow::MethodCallNode {
1080+
Cors::Cors corsConfig;
1081+
10801082
CorsConfiguration() {
10811083
exists(Express::RouteSetup setup | this = setup |
1082-
setup.isUseCall() and setup.getArgument(0) instanceof Cors::Cors
1083-
or
1084-
not setup.isUseCall() and setup.getAnArgument() instanceof Cors::Cors
1084+
if setup.isUseCall()
1085+
then corsConfig = setup.getArgument(0)
1086+
else corsConfig = setup.getArgument(any(int i | i > 0))
10851087
)
10861088
}
10871089

1088-
/** Gets the cors argument */
1089-
Cors::Cors getArgument() { result = this.getArgument(0) }
1090-
1091-
/** Gets the options used to configure `cors`. */
1092-
DataFlow::Node getCorsArgument() { result = this.getArgument().getOptionsArgument() }
1093-
1094-
/** Holds if cors is using its default configuration. */
1095-
predicate isDefault() { this.getArgument().isDefault() }
1096-
1097-
/** Gets the `origin` option that the call to `cors` is configured with. */
1098-
DataFlow::Node getOrigin() { result = this.getArgument().getOrigin() }
1090+
/** Gets the expression that configures `cors` on this route setup. */
1091+
Cors::Cors getCorsConfiguration() { result = corsConfig }
10991092
}
11001093
}

0 commit comments

Comments
 (0)