Skip to content

Commit 5dcf0ad

Browse files
committed
Ruby: Make IOPrintfCall more sensitive
It will now identify cases like this: file = File.open "foo.txt", "a" file.printf(params[:format], arg)
1 parent c253bdd commit 5dcf0ad

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import codeql.ruby.DataFlow
77
import codeql.ruby.dataflow.RemoteFlowSources
88
import codeql.ruby.ApiGraphs
99
import codeql.ruby.TaintTracking
10+
private import codeql.ruby.frameworks.Files::IO
1011

1112
/**
1213
* A call to `printf` or `sprintf`.
@@ -57,5 +58,5 @@ class KernelSprintfCall extends PrintfStyleCall {
5758
* A call to `IO#printf`.
5859
*/
5960
class IOPrintfCall extends PrintfStyleCall {
60-
IOPrintfCall() { this = API::getTopLevelMember("IO").getInstance().getAMethodCall("printf") }
61+
IOPrintfCall() { this.getReceiver() instanceof IOInstance and this.getMethodName() = "printf" }
6162
}

0 commit comments

Comments
 (0)