mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Add some HTMLEscaping implementations for Rails
This commit is contained in:
@@ -134,6 +134,13 @@ private class ActionControllerHtmlSafeCall extends HtmlSafeCall {
|
||||
}
|
||||
}
|
||||
|
||||
// A call to `html_escape` from within a controller.
|
||||
private class ActionControllerHtmlEscapeCall extends HtmlEscapeCall {
|
||||
ActionControllerHtmlEscapeCall() {
|
||||
this.getEnclosingModule() instanceof ActionControllerControllerClass
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to the `redirect_to` method, used in an action to redirect to a
|
||||
* specific URL/path or to a different action in this controller.
|
||||
|
||||
@@ -25,6 +25,29 @@ private class ActionViewHtmlSafeCall extends HtmlSafeCall {
|
||||
ActionViewHtmlSafeCall() { inActionViewContext(this) }
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to a method named "html_escape", "html_escape_once", or "h".
|
||||
*/
|
||||
abstract class HtmlEscapeCall extends MethodCall {
|
||||
// "h" is aliased to "html_escape" in ActiveSupport
|
||||
HtmlEscapeCall() { this.getMethodName() = ["html_escape", "html_escape_once", "h"] }
|
||||
}
|
||||
|
||||
class RailsHtmlEscaping extends Escaping::Range, DataFlow::CallNode {
|
||||
RailsHtmlEscaping() { this.asExpr().getExpr() instanceof HtmlEscapeCall }
|
||||
|
||||
override DataFlow::Node getAnInput() { result = this.getArgument(0) }
|
||||
|
||||
override DataFlow::Node getOutput() { result = this }
|
||||
|
||||
override string getKind() { result = Escaping::getHtmlKind() }
|
||||
}
|
||||
|
||||
// A call to `html_escape` from within a template.
|
||||
private class ActionViewHtmlEscapeCall extends HtmlEscapeCall {
|
||||
ActionViewHtmlEscapeCall() { inActionViewContext(this) }
|
||||
}
|
||||
|
||||
// A call in a context where some commonly used `ActionView` methods are available.
|
||||
private class ActionViewContextCall extends MethodCall {
|
||||
ActionViewContextCall() {
|
||||
|
||||
Reference in New Issue
Block a user