diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Cors.qll b/javascript/ql/lib/semmle/javascript/frameworks/Cors.qll index 57ec67b1f38..f9fa2f950db 100644 --- a/javascript/ql/lib/semmle/javascript/frameworks/Cors.qll +++ b/javascript/ql/lib/semmle/javascript/frameworks/Cors.qll @@ -6,6 +6,9 @@ import javascript /** Provides classes modeling [cors package](https://npmjs.com/package/cors) */ module Cors { + /** + * An expression that creates a new CORS configuration. + */ class Cors extends DataFlow::CallNode { /** Get an instanceof of `cors` */ Cors() { this = DataFlow::moduleImport("cors").getAnInvocation() } @@ -16,7 +19,7 @@ module Cors { /** Holds if cors is using default configuration */ predicate isDefault() { this.getNumArgument() = 0 } - /** The value of origin */ + /** Gets the value of origin */ DataFlow::Node getOrigin() { result = this.getCorsArgument().getALocalSource().getAPropertyWrite("origin").getRhs() } diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Express.qll b/javascript/ql/lib/semmle/javascript/frameworks/Express.qll index dadebb31485..0996e12e944 100644 --- a/javascript/ql/lib/semmle/javascript/frameworks/Express.qll +++ b/javascript/ql/lib/semmle/javascript/frameworks/Express.qll @@ -1073,22 +1073,22 @@ module Express { override predicate definitelyResumesDispatch() { none() } } + /** + * The CORS configuration used in Express + */ class CorsConfiguration extends DataFlow::MethodCallNode { /** Get an `app.use` with a cors object as argument */ CorsConfiguration() { this = appCreation().getAMethodCall("use") and this.getArgument(0) instanceof Cors::Cors } - /** Get Cors */ - private Cors::Cors cors() { result = this.getArgument(0).(Cors::Cors) } - /** Get Cors configuration */ - DataFlow::Node getCorsArgument() { result = cors().getCorsArgument() } + DataFlow::Node getCorsArgument() { result = this.getArgument(0).(Cors::Cors).getCorsArgument() } /** Holds if cors is using default configuration */ - predicate isDefault() { cors().isDefault() } + predicate isDefault() { this.getArgument(0).(Cors::Cors).isDefault() } /** Get Cors origin value */ - DataFlow::Node getOrigin() { result = cors().getOrigin() } + DataFlow::Node getOrigin() { result = this.getArgument(0).(Cors::Cors).getOrigin() } } }