Skip to content

Commit d3485ca

Browse files
authored
Merge pull request #5512 from aschackmull/java/csv-argument-ranges
Java: Support argument and parameter ranges in CSV models.
2 parents 8d15680 + 4955f95 commit d3485ca

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll

+33-11
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,30 @@
3232
* 7. The `input` column specifies how data enters the element selected by the
3333
* first 6 columns, and the `output` column specifies how data leaves the
3434
* element selected by the first 6 columns. An `input` can be either "",
35-
* "Argument", "Argument[n]", "ReturnValue":
35+
* "Argument[n]", "Argument[n1..n2]", "ReturnValue":
3636
* - "": Selects a write to the selected element in case this is a field.
37-
* - "Argument": Selects any argument in a call to the selected element.
38-
* - "Argument[n]": Similar to "Argument" but restricted to a specific numbered
39-
* argument (zero-indexed, and `-1` specifies the qualifier).
37+
* - "Argument[n]": Selects an argument in a call to the selected element.
38+
* The arguments are zero-indexed, and `-1` specifies the qualifier.
39+
* - "Argument[n1..n2]": Similar to "Argument[n]" but select any argument in
40+
* the given range. The range is inclusive at both ends.
4041
* - "ReturnValue": Selects a value being returned by the selected element.
4142
* This requires that the selected element is a method with a body.
4243
*
43-
* An `output` can be either "", "Argument", "Argument[n]", "Parameter",
44-
* "Parameter[n]", or "ReturnValue":
44+
* An `output` can be either "", "Argument[n]", "Argument[n1..n2]", "Parameter",
45+
* "Parameter[n]", "Parameter[n1..n2]", or "ReturnValue":
4546
* - "": Selects a read of a selected field, or a selected parameter.
46-
* - "Argument": Selects the post-update value of an argument in a call to the
47+
* - "Argument[n]": Selects the post-update value of an argument in a call to the
4748
* selected element. That is, the value of the argument after the call returns.
48-
* - "Argument[n]": Similar to "Argument" but restricted to a specific numbered
49-
* argument (zero-indexed, and `-1` specifies the qualifier).
49+
* The arguments are zero-indexed, and `-1` specifies the qualifier.
50+
* - "Argument[n1..n2]": Similar to "Argument[n]" but select any argument in
51+
* the given range. The range is inclusive at both ends.
5052
* - "Parameter": Selects the value of a parameter of the selected element.
5153
* "Parameter" is also allowed in case the selected element is already a
5254
* parameter itself.
5355
* - "Parameter[n]": Similar to "Parameter" but restricted to a specific
5456
* numbered parameter (zero-indexed, and `-1` specifies the value of `this`).
57+
* - "Parameter[n1..n2]": Similar to "Parameter[n]" but selects any parameter
58+
* in the given range. The range is inclusive at both ends.
5559
* - "ReturnValue": Selects the return value of a call to the selected element.
5660
* 8. The `kind` column is a tag that can be referenced from QL to determine to
5761
* which classes the interpreted elements should be added. For example, for
@@ -554,11 +558,29 @@ private string getLast(string s) {
554558
}
555559

556560
private predicate parseParam(string c, int n) {
557-
specSplit(_, c, _) and c.regexpCapture("Parameter\\[([-0-9]+)\\]", 1).toInt() = n
561+
specSplit(_, c, _) and
562+
(
563+
c.regexpCapture("Parameter\\[([-0-9]+)\\]", 1).toInt() = n
564+
or
565+
exists(int n1, int n2 |
566+
c.regexpCapture("Parameter\\[([-0-9]+)\\.\\.([0-9]+)\\]", 1).toInt() = n1 and
567+
c.regexpCapture("Parameter\\[([-0-9]+)\\.\\.([0-9]+)\\]", 2).toInt() = n2 and
568+
n = [n1 .. n2]
569+
)
570+
)
558571
}
559572

560573
private predicate parseArg(string c, int n) {
561-
specSplit(_, c, _) and c.regexpCapture("Argument\\[([-0-9]+)\\]", 1).toInt() = n
574+
specSplit(_, c, _) and
575+
(
576+
c.regexpCapture("Argument\\[([-0-9]+)\\]", 1).toInt() = n
577+
or
578+
exists(int n1, int n2 |
579+
c.regexpCapture("Argument\\[([-0-9]+)\\.\\.([0-9]+)\\]", 1).toInt() = n1 and
580+
c.regexpCapture("Argument\\[([-0-9]+)\\.\\.([0-9]+)\\]", 2).toInt() = n2 and
581+
n = [n1 .. n2]
582+
)
583+
)
562584
}
563585

564586
private predicate inputNeedsReference(string c) {

0 commit comments

Comments
 (0)