Skip to content

Commit 17b3383

Browse files
authored
Merge pull request github#12556 from michaelnebel/java/argumentthis
Java: Argument[-1] -> Argument[this]
2 parents a9d40d3 + 01ade87 commit 17b3383

File tree

194 files changed

+7682
-7584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+7682
-7584
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* "Argument[n]", "Argument[n1..n2]", or "ReturnValue":
4040
* - "": Selects a write to the selected element in case this is a field or property.
4141
* - "Argument[n]": Selects an argument in a call to the selected element.
42-
* The arguments are zero-indexed, and `-1` specifies the qualifier.
42+
* The arguments are zero-indexed, and `this` specifies the qualifier.
4343
* - "Argument[n1..n2]": Similar to "Argument[n]" but select any argument in
4444
* the given range. The range is inclusive at both ends.
4545
* - "ReturnValue": Selects a value being returned by the selected element.
@@ -50,14 +50,14 @@
5050
* - "": Selects a read of a selected field, property, or parameter.
5151
* - "Argument[n]": Selects the post-update value of an argument in a call to the
5252
* selected element. That is, the value of the argument after the call returns.
53-
* The arguments are zero-indexed, and `-1` specifies the qualifier.
53+
* The arguments are zero-indexed, and `this` specifies the qualifier.
5454
* - "Argument[n1..n2]": Similar to "Argument[n]" but select any argument in
5555
* the given range. The range is inclusive at both ends.
5656
* - "Parameter": Selects the value of a parameter of the selected element.
5757
* "Parameter" is also allowed in case the selected element is already a
5858
* parameter itself.
5959
* - "Parameter[n]": Similar to "Parameter" but restricted to a specific
60-
* numbered parameter (zero-indexed, and `-1` specifies the value of `this`).
60+
* numbered parameter (zero-indexed, and `this` specifies the value of `this`).
6161
* - "Parameter[n1..n2]": Similar to "Parameter[n]" but selects any parameter
6262
* in the given range. The range is inclusive at both ends.
6363
* - "ReturnValue": Selects the return value of a call to the selected element.
@@ -173,6 +173,8 @@ module ModelValidation {
173173
or
174174
part = input.getToken(_) and
175175
parseParam(part, _)
176+
or
177+
invalidIndexComponent(input, part)
176178
) and
177179
result = "Unrecognized input specification \"" + part + "\" in " + pred + " model."
178180
)
@@ -184,9 +186,13 @@ module ModelValidation {
184186
or
185187
summaryModel(_, _, _, _, _, _, _, output, _, _) and pred = "summary"
186188
|
187-
invalidSpecComponent(output, part) and
188-
not part = "" and
189-
not (part = ["Argument", "Parameter"] and pred = "source") and
189+
(
190+
invalidSpecComponent(output, part) and
191+
not part = "" and
192+
not (part = ["Argument", "Parameter"] and pred = "source")
193+
or
194+
invalidIndexComponent(output, part)
195+
) and
190196
result = "Unrecognized output specification \"" + part + "\" in " + pred + " model."
191197
)
192198
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,16 @@ module Private {
10501050
not exists(interpretComponent(c))
10511051
}
10521052

1053+
/**
1054+
* Holds if token `part` of specification `spec` has an invalid index.
1055+
* E.g., `Argument[-1]`.
1056+
*/
1057+
predicate invalidIndexComponent(AccessPath spec, AccessPathToken part) {
1058+
part = spec.getToken(_) and
1059+
part.getName() = ["Parameter", "Argument"] and
1060+
AccessPath::parseInt(part.getArgumentList()) < 0
1061+
}
1062+
10531063
private predicate inputNeedsReference(AccessPathToken c) {
10541064
c.getName() = "Argument" or
10551065
inputNeedsReferenceSpecific(c)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,16 @@ module Private {
10501050
not exists(interpretComponent(c))
10511051
}
10521052

1053+
/**
1054+
* Holds if token `part` of specification `spec` has an invalid index.
1055+
* E.g., `Argument[-1]`.
1056+
*/
1057+
predicate invalidIndexComponent(AccessPath spec, AccessPathToken part) {
1058+
part = spec.getToken(_) and
1059+
part.getName() = ["Parameter", "Argument"] and
1060+
AccessPath::parseInt(part.getArgumentList()) < 0
1061+
}
1062+
10531063
private predicate inputNeedsReference(AccessPathToken c) {
10541064
c.getName() = "Argument" or
10551065
inputNeedsReferenceSpecific(c)

java/ql/integration-tests/all-platforms/kotlin/default-parameter-mad-flow/test.ext.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extensions:
33
pack: integrationtest-default-parameter-mad-flow
44
extensible: summaryModel
55
data:
6-
- ["", "ConstructorWithDefaults", True, "ConstructorWithDefaults", "(int,int)", "", "Argument[0]", "Argument[-1]", "taint", "manual"]
6+
- ["", "ConstructorWithDefaults", True, "ConstructorWithDefaults", "(int,int)", "", "Argument[0]", "Argument[this]", "taint", "manual"]
77
- ["", "LibKt", True, "topLevelWithDefaults", "(int,int)", "", "Argument[0]", "ReturnValue", "value", "manual"]
88
- ["", "LibKt", True, "extensionWithDefaults", "(String,int,int)", "", "Argument[1]", "ReturnValue", "value", "manual"]
99
- ["", "LibClass", True, "memberWithDefaults", "(int,int)", "", "Argument[0]", "ReturnValue", "value", "manual"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The Models as Data syntax for selecting the qualifier has been changed from `-1` to `this` (e.g. `Argument[-1]` is now written as `Argument[this]`).

0 commit comments

Comments
 (0)