Skip to content

Commit

Permalink
Fix qldoc and remove PotentialViewCallable class
Browse files Browse the repository at this point in the history
  • Loading branch information
joefarebrother committed Apr 30, 2024
1 parent 4f22b91 commit c6372d5
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions python/ql/lib/semmle/python/frameworks/Pyramid.qll
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ private import semmle.python.frameworks.Stdlib
module Pyramid {
/** Provides models for pyramid View callables. */
module View {
/** A dataflow node that sets up a route on a server using the Pyramid framework. */
abstract private class PyramidRouteSetup extends Http::Server::RouteSetup::Range {
override string getFramework() { result = "Pyramid" }
}

/**
* A callable that could be used as a pyramid view callable.
* A Pyramid view callable, that handles incoming requests.
*/
private class PotentialViewCallable extends Function {
PotentialViewCallable() { this.getPositionalParameterCount() in [1, 2] }
class ViewCallable extends Function {
ViewCallable() { this = any(PyramidRouteSetup rs).getARequestHandler() }

/** Gets the `request` parameter of this view callable. */
/** Gets the `request` parameter of this callable. */
Parameter getRequestParameter() {
this.getPositionalParameterCount() = 1 and
result = this.getArg(0)
Expand All @@ -37,18 +42,6 @@ module Pyramid {
}
}

/** A dataflow node that sets up a route on a server using the Pyramid framework. */
abstract private class PyramidRouteSetup extends Http::Server::RouteSetup::Range {
override string getFramework() { result = "Pyramid" }
}

/**
* A Pyramid view callable, that handles incoming requests.
*/
class ViewCallable extends PotentialViewCallable {
ViewCallable() { this = any(PyramidRouteSetup rs).getARequestHandler() }
}

/** A pyramid route setup using the `pyramid.view.view_config` decorator. */
private class DecoratorSetup extends PyramidRouteSetup {
DecoratorSetup() {
Expand Down Expand Up @@ -92,15 +85,16 @@ module Pyramid {
/** Gets a reference to an instance of `pyramid.config.Configurator`. */
DataFlow::Node instance() { instance(DataFlow::TypeTracker::end()).flowsTo(result) }

/** Gets a call to the `add_view` method of an instance of `pyramid.config.Configurator`. */
/** A call to the `add_view` method of an instance of `pyramid.config.Configurator`. */
class AddViewCall extends DataFlow::MethodCallNode {
AddViewCall() { this.calls(instance(), "add_view") }

/** Gets the `view` argument of this call. */
DataFlow::Node getViewArg() { result = [this.getArg(0), this.getArgByName("view")] }
}
}

/** Provides modelling for pyramid requests. */
/** Provides modeling for pyramid requests. */
module Request {
/**
* A source of instances of `pyramid.request.Request`, extend this class to model new instances.
Expand Down Expand Up @@ -167,7 +161,7 @@ module Pyramid {
}
}

/** Provides modelling for pyramid responses. */
/** Provides modeling for pyramid responses. */
module Response {
/** A response returned by a view callable. */
private class PyramidReturnResponse extends Http::Server::HttpResponse::Range {
Expand Down Expand Up @@ -287,7 +281,7 @@ module Pyramid {
])
}

/** Gets a call to a pyramid HTTP exception class that represents an HTTP redirect response. */
/** A call to a pyramid HTTP exception class that represents an HTTP redirect response. */
class PyramidRedirect extends Http::Server::HttpRedirectResponse::Range, DataFlow::CallCfgNode {
PyramidRedirect() { this = classRef().getACall() }

Expand Down

0 comments on commit c6372d5

Please sign in to comment.