Skip to content

Commit d2ca1fb

Browse files
committed
Address review comments #2
1 parent 12058a2 commit d2ca1fb

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

ql/lib/semmle/go/controlflow/ControlFlowGraph.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ module ControlFlow {
147147
}
148148

149149
/**
150-
* Holds if this node sets the value of element `idx` on `base` (or its implicit dereference)
150+
* Holds if this node sets the value of element `index` on `base` (or its implicit dereference)
151151
* to `rhs`.
152152
*
153153
* For example, for the assignment `xs[i] = v`, `base` is either the data-flow node

ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,38 +190,38 @@ predicate summaryModel(
190190
}
191191

192192
/** Holds if `package` have CSV framework coverage. */
193-
private predicate relevantPackage(string package) {
193+
private predicate packageHasCsvCoverage(string package) {
194194
sourceModel(package, _, _, _, _, _, _, _) or
195195
sinkModel(package, _, _, _, _, _, _, _) or
196196
summaryModel(package, _, _, _, _, _, _, _, _)
197197
}
198198

199199
/**
200-
* Holds if `shortpkg` and `longpkg` have CSV framework coverage and `shortpkg`
201-
* is a subpackage of `longpkg`.
200+
* Holds if `package` and `subpkg` have CSV framework coverage and `subpkg`
201+
* is a subpackage of `package`.
202202
*/
203-
private predicate packageLink(string shortpkg, string longpkg) {
204-
relevantPackage(shortpkg) and
205-
relevantPackage(longpkg) and
206-
longpkg.prefix(longpkg.indexOf(".")) = shortpkg
203+
private predicate packageHasASubpackage(string package, string subpkg) {
204+
packageHasCsvCoverage(package) and
205+
packageHasCsvCoverage(subpkg) and
206+
subpkg.prefix(subpkg.indexOf(".")) = package
207207
}
208208

209209
/**
210210
* Holds if `package` has CSV framework coverage and it is not a subpackage of
211211
* any other package with CSV framework coverage.
212212
*/
213213
private predicate canonicalPackage(string package) {
214-
relevantPackage(package) and not packageLink(_, package)
214+
packageHasCsvCoverage(package) and not packageHasASubpackage(_, package)
215215
}
216216

217217
/**
218218
* Holds if `package` and `subpkg` have CSV framework coverage, `subpkg` is a
219219
* subpackage of `package` (or they are the same), and `package` is not a
220220
* subpackage of any other package with CSV framework coverage.
221221
*/
222-
private predicate canonicalPkgLink(string package, string subpkg) {
222+
private predicate canonicalPackageHasASubpackage(string package, string subpkg) {
223223
canonicalPackage(package) and
224-
(subpkg = package or packageLink(package, subpkg))
224+
(subpkg = package or packageHasASubpackage(package, subpkg))
225225
}
226226

227227
/**
@@ -230,29 +230,29 @@ private predicate canonicalPkgLink(string package, string subpkg) {
230230
* which have CSV framework coverage (including `package` itself).
231231
*/
232232
predicate modelCoverage(string package, int pkgs, string kind, string part, int n) {
233-
pkgs = strictcount(string subpkg | canonicalPkgLink(package, subpkg)) and
233+
pkgs = strictcount(string subpkg | canonicalPackageHasASubpackage(package, subpkg)) and
234234
(
235235
part = "source" and
236236
n =
237237
strictcount(string subpkg, string type, boolean subtypes, string name, string signature,
238238
string ext, string output |
239-
canonicalPkgLink(package, subpkg) and
239+
canonicalPackageHasASubpackage(package, subpkg) and
240240
sourceModel(subpkg, type, subtypes, name, signature, ext, output, kind)
241241
)
242242
or
243243
part = "sink" and
244244
n =
245245
strictcount(string subpkg, string type, boolean subtypes, string name, string signature,
246246
string ext, string input |
247-
canonicalPkgLink(package, subpkg) and
247+
canonicalPackageHasASubpackage(package, subpkg) and
248248
sinkModel(subpkg, type, subtypes, name, signature, ext, input, kind)
249249
)
250250
or
251251
part = "summary" and
252252
n =
253253
strictcount(string subpkg, string type, boolean subtypes, string name, string signature,
254254
string ext, string input, string output |
255-
canonicalPkgLink(package, subpkg) and
255+
canonicalPackageHasASubpackage(package, subpkg) and
256256
summaryModel(subpkg, type, subtypes, name, signature, ext, input, output, kind)
257257
)
258258
)

ql/lib/semmle/go/dataflow/internal/DataFlowNodes.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@ module Public {
545545
abstract predicate isParameterOf(DataFlowCallable c, int i);
546546
}
547547

548+
/**
549+
* A summary node which represents a parameter in a function which doesn't
550+
* already have a parameter nodes.
551+
*/
548552
class SummarizedParameterNode extends ParameterNode, MkSummarizedParameterNode {
549553
DataFlowCallable c;
550554
int i;
@@ -1085,18 +1089,20 @@ module Public {
10851089
* A data-flow node representing an index of an array, map, slice or string defined from `range` statement.
10861090
*
10871091
* Example: in `i, _ := range y { ... }`, this represents the `Node` that extracts the index from the
1088-
* range statement, which will flow to `x`.
1092+
* range statement, which will flow to `i`.
10891093
*/
10901094
class RangeIndexNode extends Node {
10911095
DataFlow::Node base;
10921096

10931097
RangeIndexNode() {
1098+
// when there is a comma, as in `i, x := range y { ... }`
10941099
exists(IR::ExtractTupleElementInstruction extract |
10951100
this.asInstruction() = extract and
10961101
extract.extractsElement(_, 0) and
10971102
extract.getBase().(IR::GetNextEntryInstruction).getDomain() = base.asInstruction()
10981103
)
10991104
or
1105+
// when there is no comma, as in `i := range y { ... }`
11001106
not exists(IR::ExtractTupleElementInstruction extract |
11011107
extract.getBase() = this.asInstruction()
11021108
) and

0 commit comments

Comments
 (0)