Skip to content

Commit efb872a

Browse files
committed
Python: Add HttpRedirectResponse concept
1 parent d7ca065 commit efb872a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

python/ql/src/semmle/python/Concepts.qll

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,5 +473,40 @@ module HTTP {
473473
}
474474
}
475475
}
476+
477+
/**
478+
* A data-flow node that creates a HTTP redirect response on a server.
479+
*
480+
* Note: we don't require that this redirect must be sent to a client (a kind of
481+
* "if a tree falls in a forest and nobody hears it" situation).
482+
*
483+
* Extend this class to refine existing API models. If you want to model new APIs,
484+
* extend `HttpRedirectResponse::Range` instead.
485+
*/
486+
class HttpRedirectResponse extends HttpResponse {
487+
override HttpRedirectResponse::Range range;
488+
489+
HttpRedirectResponse() { this = range }
490+
491+
/** Gets the data-flow node that specifies the location of this HTTP redirect response. */
492+
DataFlow::Node getRedirectLocation() { result = range.getRedirectLocation() }
493+
}
494+
495+
/** Provides a class for modeling new HTTP redirect response APIs. */
496+
module HttpRedirectResponse {
497+
/**
498+
* A data-flow node that creates a HTTP redirect response on a server.
499+
*
500+
* Note: we don't require that this redirect must be sent to a client (a kind of
501+
* "if a tree falls in a forest and nobody hears it" situation).
502+
*
503+
* Extend this class to model new APIs. If you want to refine existing API models,
504+
* extend `HttpResponse` instead.
505+
*/
506+
abstract class Range extends HTTP::Server::HttpResponse::Range {
507+
/** Gets the data-flow node that specifies the location of this HTTP redirect response. */
508+
abstract DataFlow::Node getRedirectLocation();
509+
}
510+
}
476511
}
477512
}

0 commit comments

Comments
 (0)