Skip to content

Commit 69eb24e

Browse files
committed
Ruby: fix toCsv representation of argument/parameter positions
1 parent 6870a19 commit 69eb24e

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,38 @@ SummaryComponent interpretComponentSpecific(AccessPathToken c) {
7979
string getComponentSpecificCsv(SummaryComponent sc) { none() }
8080

8181
/** Gets the textual representation of a parameter position in the format used for flow summaries. */
82-
string getParameterPositionCsv(ParameterPosition pos) { result = pos.toString() }
82+
string getParameterPositionCsv(ParameterPosition pos) {
83+
pos.isSelf() and result = "self"
84+
or
85+
pos.isBlock() and result = "block"
86+
or
87+
exists(int i |
88+
pos.isPositional(i) and
89+
result = i.toString()
90+
)
91+
or
92+
exists(string name |
93+
pos.isKeyword(name) and
94+
result = name + ":"
95+
)
96+
}
8397

8498
/** Gets the textual representation of an argument position in the format used for flow summaries. */
85-
string getArgumentPositionCsv(ArgumentPosition pos) { result = pos.toString() }
99+
string getArgumentPositionCsv(ArgumentPosition pos) {
100+
pos.isSelf() and result = "self"
101+
or
102+
pos.isBlock() and result = "block"
103+
or
104+
exists(int i |
105+
pos.isPositional(i) and
106+
result = i.toString()
107+
)
108+
or
109+
exists(string name |
110+
pos.isKeyword(name) and
111+
result = name + ":"
112+
)
113+
}
86114

87115
/** Holds if input specification component `c` needs a reference. */
88116
predicate inputNeedsReferenceSpecific(string c) { none() }

0 commit comments

Comments
 (0)