Skip to content

Commit aa24ce5

Browse files
Apply suggestions from code review
Co-authored-by: Erik Krogh Kristensen <[email protected]>
1 parent 4ef4c92 commit aa24ce5

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import javascript
66

77
/** Provides classes modeling the apollo packages [@apollo/server](https://npmjs.com/package/@apollo/server`) */
88
module Apollo {
9-
/** Get an instanceof of `Apollo` */
9+
/** Get a reference to the `ApolloServer` class. */
1010
private API::Node apollo() {
1111
result =
1212
API::moduleImport([
@@ -30,7 +30,7 @@ module Apollo {
3030
}
3131

3232
/** A string that is interpreted as a GraphQL query by a `apollo` package. */
33-
class ApolloGraphQLString extends GraphQL::GraphQLString {
33+
private class ApolloGraphQLString extends GraphQL::GraphQLString {
3434
ApolloGraphQLString() { this = gql().getACall().getArgument(0) }
3535
}
3636
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44

55
import javascript
66

7-
/** Provides classes modeling [cors package](https://npmjs.com/package/cors) */
7+
/** Provides classes modeling [cors](https://npmjs.com/package/cors) library. */
88
module Cors {
99
/**
1010
* An expression that creates a new CORS configuration.
1111
*/
1212
class Cors extends DataFlow::CallNode {
13-
/** Get an instanceof of `cors` */
1413
Cors() { this = DataFlow::moduleImport("cors").getAnInvocation() }
1514

16-
/** Get Cors configuration */
17-
DataFlow::Node getCorsArgument() { result = this.getArgument(0) }
15+
/** Get the options used to configure Cors */
16+
DataFlow::Node getOptionsArgument() { result = this.getArgument(0) }
1817

1918
/** Holds if cors is using default configuration */
2019
predicate isDefault() { this.getNumArgument() = 0 }
2120

2221
/** Gets the value of origin */
2322
DataFlow::Node getOrigin() {
24-
result = this.getCorsArgument().getALocalSource().getAPropertyWrite("origin").getRhs()
23+
result = this.getOptionArgument(0, "origin")
2524
}
2625
}
2726
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,21 +1074,20 @@ module Express {
10741074
}
10751075

10761076
/**
1077-
* The CORS configuration used in Express
1077+
* An express route setup configured with the `cors` package.
10781078
*/
10791079
class CorsConfiguration extends DataFlow::MethodCallNode {
1080-
/** Get an `app.use` with a cors object as argument */
10811080
CorsConfiguration() {
10821081
this = appCreation().getAMethodCall("use") and this.getArgument(0) instanceof Cors::Cors
10831082
}
10841083

1085-
/** Get Cors configuration */
1084+
/** Gets the options used to configure `cors`. */
10861085
DataFlow::Node getCorsArgument() { result = this.getArgument(0).(Cors::Cors).getCorsArgument() }
10871086

1088-
/** Holds if cors is using default configuration */
1087+
/** Holds if cors is using its default configuration. */
10891088
predicate isDefault() { this.getArgument(0).(Cors::Cors).isDefault() }
10901089

1091-
/** Get Cors origin value */
1090+
/** Gets the `origin` option that the call to `cors` is configured with. */
10921091
DataFlow::Node getOrigin() { result = this.getArgument(0).(Cors::Cors).getOrigin() }
10931092
}
10941093
}

0 commit comments

Comments
 (0)