Skip to content

Commit 6aded7b

Browse files
committed
Ruby: Improve AccessPath printing.
1 parent e73d6d5 commit 6aded7b

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,52 @@ SummaryComponent interpretComponentSpecific(AccessPathToken c) {
139139
)
140140
}
141141

142+
private string getContentSpecific(Content c) {
143+
exists(string name | c = TFieldContent(name) and result = "Field[" + name + "]")
144+
or
145+
exists(ConstantValue cv |
146+
c = TKnownElementContent(cv) and result = "Element[" + cv.toString() + "!]"
147+
)
148+
or
149+
c = TUnknownElementContent() and result = "Element[?]"
150+
}
151+
152+
private string getContentSetSpecific(ContentSet cs) {
153+
exists(Content c | cs = TSingletonContent(c) and result = getContentSpecific(c))
154+
or
155+
cs = TAnyElementContent() and result = "Element[any]"
156+
or
157+
exists(Content::KnownElementContent kec |
158+
cs = TKnownOrUnknownElementContent(kec) and result = "Element[" + kec.getIndex() + "]"
159+
)
160+
or
161+
exists(int lower, boolean includeUnknown, string unknown |
162+
cs = TElementLowerBoundContent(lower, includeUnknown) and
163+
(if includeUnknown = true then unknown = "" else unknown = "!") and
164+
result = "Element[" + lower + ".." + unknown + "]"
165+
)
166+
}
167+
142168
/** Gets the textual representation of a summary component in the format used for flow summaries. */
143-
string getAccessStepSpecific(SummaryComponent sc) { none() }
169+
string getAccessStepSpecific(SummaryComponent sc) {
170+
exists(ContentSet cs | sc = TContentSummaryComponent(cs) and result = getContentSetSpecific(cs))
171+
or
172+
exists(ContentSet cs |
173+
sc = TWithoutContentSummaryComponent(cs) and
174+
result = "WithoutElement[" + getContentSetSpecific(cs) + "]"
175+
)
176+
or
177+
exists(ContentSet cs |
178+
sc = TWithContentSummaryComponent(cs) and
179+
result = "WithElement[" + getContentSetSpecific(cs) + "]"
180+
)
181+
or
182+
exists(ReturnKind rk |
183+
sc = TReturnSummaryComponent(rk) and
184+
not rk = getReturnValueKind() and
185+
result = "ReturnValue[" + rk + "]"
186+
)
187+
}
144188

145189
/** Gets the textual representation of a parameter position in the format used for flow summaries. */
146190
string getParameterPosition(ParameterPosition pos) {
@@ -170,6 +214,9 @@ string getParameterPosition(ParameterPosition pos) {
170214
or
171215
pos.isAnyNamed() and
172216
result = "any-named"
217+
or
218+
pos.isHashSplat() and
219+
result = "hash-splat"
173220
}
174221

175222
/** Gets the textual representation of an argument position in the format used for flow summaries. */

0 commit comments

Comments
 (0)