Skip to content

Commit 6319902

Browse files
committed
Add missing QLDoc
1 parent f6215d4 commit 6319902

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

ruby/ql/lib/codeql/ruby/security/TaintedFormatStringCustomizations.qll

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ private import codeql.ruby.DataFlow
88
private import codeql.ruby.dataflow.RemoteFlowSources
99
private import codeql.ruby.ApiGraphs
1010

11+
/**
12+
* Provides default sources, sinks and sanitizers for reasoning about
13+
* format injections, as well as extension points for adding your own.
14+
*/
1115
module TaintedFormatString {
1216
/**
1317
* A data flow source for format injections.
@@ -47,11 +51,20 @@ module TaintedFormatString {
4751
*/
4852
abstract class PrintfCall extends DataFlow::CallNode {
4953
// We assume that most printf-like calls have the signature f(format_string, args...)
54+
/**
55+
* Gets the format string of this call.
56+
*/
5057
DataFlow::Node getFormatString() { result = this.getArgument(0) }
5158

52-
DataFlow::Node getFormatArgument(int n) { n > 0 and result = this.getArgument(n) }
59+
/**
60+
* Gets then `n`th formatted argument of this call.
61+
*/
62+
DataFlow::Node getFormatArgument(int n) { result = this.getArgument(n + 1) }
5363
}
5464

65+
/**
66+
* A call to `Kernel.printf`.
67+
*/
5568
class KernelPrintfCall extends PrintfCall {
5669
KernelPrintfCall() {
5770
this = API::getTopLevelMember("Kernel").getAMethodCall("printf")
@@ -66,6 +79,9 @@ module TaintedFormatString {
6679
override DataFlow::Node getFormatString() { result = this.getArgument([0, 1]) }
6780
}
6881

82+
/**
83+
* A call to `Kernel.sprintf`.
84+
*/
6985
class KernelSprintfCall extends PrintfCall {
7086
KernelSprintfCall() {
7187
this = API::getTopLevelMember("Kernel").getAMethodCall("sprintf")
@@ -75,6 +91,9 @@ module TaintedFormatString {
7591
}
7692
}
7793

94+
/**
95+
* A call to `IO#printf`.
96+
*/
7897
class IOPrintfCall extends PrintfCall {
7998
IOPrintfCall() { this = API::getTopLevelMember("IO").getInstance().getAMethodCall("printf") }
8099
}

0 commit comments

Comments
 (0)