|
5 | 5 | */ |
6 | 6 |
|
7 | 7 | import javascript |
8 | | -private import semmle.javascript.frameworks.Cors |
9 | 8 |
|
10 | 9 | module CorsMisconfigurationForCredentials { |
11 | 10 | /** |
@@ -88,46 +87,13 @@ module CorsMisconfigurationForCredentials { |
88 | 87 | } |
89 | 88 |
|
90 | 89 | /** |
91 | | - * The value of cors origin when initializing the application. |
| 90 | + * The value of cors origin configuration. |
92 | 91 | */ |
93 | | - class CorsApolloServer extends Sink, DataFlow::ValueNode { |
94 | | - CorsApolloServer() { |
95 | | - exists(API::NewNode agql | |
96 | | - agql = ModelOutput::getATypeNode("ApolloServer").getAnInstantiation() and |
97 | | - this = |
98 | | - agql.getOptionArgument(0, "cors").getALocalSource().getAPropertyWrite("origin").getRhs() |
99 | | - ) |
100 | | - } |
101 | | - |
102 | | - override Http::HeaderDefinition getCredentialsHeader() { none() } |
103 | | - } |
104 | | - |
105 | | - /** |
106 | | - * The value of cors origin when initializing the application. |
107 | | - */ |
108 | | - class ExpressCors extends Sink, DataFlow::ValueNode { |
109 | | - ExpressCors() { |
110 | | - exists(CorsConfiguration config | this = config.getCorsConfiguration().getOrigin()) |
| 92 | + class CorsOriginSink extends Sink, DataFlow::ValueNode { |
| 93 | + CorsOriginSink() { |
| 94 | + this = ModelOutput::getASinkNode("cors-misconfiguration").asSink() |
111 | 95 | } |
112 | 96 |
|
113 | 97 | override Http::HeaderDefinition getCredentialsHeader() { none() } |
114 | 98 | } |
115 | | - |
116 | | - /** |
117 | | - * An express route setup configured with the `cors` package. |
118 | | - */ |
119 | | - class CorsConfiguration extends DataFlow::MethodCallNode { |
120 | | - Cors::Cors corsConfig; |
121 | | - |
122 | | - CorsConfiguration() { |
123 | | - exists(Express::RouteSetup setup | this = setup | |
124 | | - if setup.isUseCall() |
125 | | - then corsConfig = setup.getArgument(0) |
126 | | - else corsConfig = setup.getArgument(any(int i | i > 0)) |
127 | | - ) |
128 | | - } |
129 | | - |
130 | | - /** Gets the expression that configures `cors` on this route setup. */ |
131 | | - Cors::Cors getCorsConfiguration() { result = corsConfig } |
132 | | - } |
133 | 99 | } |
0 commit comments