Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwstubbs committed Aug 27, 2024
1 parent 1db7865 commit 0420d25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion python/ql/lib/semmle/python/Concepts.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ module Http {
string middleware_name() { result = super.middleware_name() }

/**
* Gets the dataflow node corresponding to the allowed CORS origins
* Gets the dataflow node corresponding to the allowed CORS origins
*/
DataFlow::Node allowed_origins() { result = super.allowed_origins() }

Expand Down
32 changes: 17 additions & 15 deletions python/ql/lib/semmle/python/frameworks/FastApi.qll
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,32 @@ module FastApi {
* A call to `app.add_middleware` adding CORSMiddleware.
*/
class AddCorsMiddlewareCall extends Http::Server::CorsMiddleware::Range, AddMiddlewareCall {
/**
* Gets the string corresponding to the middleware
*/
/**
* Gets the string corresponding to the middleware
*/
override string middleware_name() { result = this.getArg(0).asExpr().(Name).toString() }

/**
* Gets the dataflow node corresponding to the allowed CORS origins
*/
* Gets the dataflow node corresponding to the allowed CORS origins
*/
override DataFlow::Node allowed_origins() { result = this.getArgByName("allow_origins") }
/**
* Gets the boolean value corresponding to if CORS credentials is enabled
* (`true`) or disabled (`false`) by this node.
*/

/**
* Gets the boolean value corresponding to if CORS credentials is enabled
* (`true`) or disabled (`false`) by this node.
*/
override DataFlow::Node allowed_credentials() {
result = this.getArgByName("allow_credentials")
}
/**
* Gets the dataflow node corresponding to the allowed CORS methods
*/

/**
* Gets the dataflow node corresponding to the allowed CORS methods
*/
DataFlow::Node allowed_methods() { result = this.getArgByName("allow_methods") }

/**
* Gets the dataflow node corresponding to the allowed CORS headers
*/
/**
* Gets the dataflow node corresponding to the allowed CORS headers
*/
DataFlow::Node allowed_headers() { result = this.getArgByName("allow_headers") }
}

Expand Down
22 changes: 10 additions & 12 deletions python/ql/lib/semmle/python/frameworks/Starlette.qll
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ private import semmle.python.frameworks.data.ModelsAsData
module Starlette {
/**
* Provides models for the `starlette.app` class
*
*
*/
module App {
/** Gets import of `starlette.app`. */
Expand All @@ -53,25 +51,25 @@ module Starlette {
* A call to any of the execute methods on a `app.add_middleware` with CORSMiddleware.
*/
class AddCorsMiddlewareCall extends AddMiddlewareCall, Http::Server::CorsMiddleware::Range {

/**
* Gets the string corresponding to the middleware
*/
/**
* Gets the string corresponding to the middleware
*/
override string middleware_name() { result = this.getArg(0).asExpr().(Name).toString() }

override DataFlow::Node allowed_origins() { result = this.getArgByName("allow_origins") }

override DataFlow::Node allowed_credentials() {
result = this.getArgByName("allow_credentials")
}
/**
* Gets the dataflow node corresponding to the allowed CORS methods
*/

/**
* Gets the dataflow node corresponding to the allowed CORS methods
*/
DataFlow::Node allowed_methods() { result = this.getArgByName("allow_methods") }

/**
* Gets the dataflow node corresponding to the allowed CORS headers
*/
/**
* Gets the dataflow node corresponding to the allowed CORS headers
*/
DataFlow::Node allowed_headers() { result = this.getArgByName("allow_headers") }
}

Expand Down

0 comments on commit 0420d25

Please sign in to comment.