Skip to content

Commit 4a01de1

Browse files
committed
Ruby: avoid toString in query warning
1 parent 0aee7f6 commit 4a01de1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ module CodeInjection {
3131

3232
/** Flow states used to distinguish whether an attacker controls the entire string. */
3333
class State extends TState {
34-
string toString() {
34+
string toString() { result = this.getStringRepresentation() }
35+
36+
/**
37+
* Gets a canonical string representation of this state.
38+
*/
39+
string getStringRepresentation() {
3540
this = TSubString() and result = "substring"
3641
or
3742
this = TFull() and result = "full"

ruby/ql/src/queries/security/cwe-094/CodeInjection.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ where
2929
otherSink) and
3030
otherSink.getNode() = sink.getNode()
3131
|
32-
otherSink order by otherSink.getState().toString()
32+
otherSink order by otherSink.getState().getStringRepresentation()
3333
)
3434
select sink.getNode(), source, sink, "This code execution depends on a $@.", sourceNode,
3535
"user-provided value"

0 commit comments

Comments
 (0)