Skip to content

Commit 8d133f8

Browse files
author
Stephan Brandauer
committed
Java: replace getArgIndex by getMaDInput
1 parent 902a585 commit 8d133f8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

java/ql/automodel/src/AutomodelApplicationModeCharacteristics.qll

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ newtype TApplicationModeEndpoint =
4444
abstract private class ApplicationModeEndpoint extends TApplicationModeEndpoint {
4545
abstract Call getCall();
4646

47-
abstract int getArgIndex();
47+
abstract string getMaDInput();
4848

4949
abstract Top asTop();
5050

@@ -66,7 +66,11 @@ class ExplicitArgument extends ApplicationModeEndpoint, TExplicitArgument {
6666

6767
override Call getCall() { result = call }
6868

69-
override int getArgIndex() { this.asTop() = call.getArgument(result) }
69+
private int getArgIndex() { this.asTop() = call.getArgument(result) }
70+
71+
override string getMaDInput() {
72+
result = "Argument[" + this.getArgIndex() + "]"
73+
}
7074

7175
override Top asTop() { result = arg.asExpr() }
7276

@@ -85,7 +89,7 @@ class InstanceArgument extends ApplicationModeEndpoint, TInstanceArgument {
8589

8690
override Call getCall() { result = call }
8791

88-
override int getArgIndex() { result = -1 }
92+
override string getMaDInput() { result = "Argument[this]" }
8993

9094
override Top asTop() { if exists(arg.asExpr()) then result = arg.asExpr() else result = call }
9195

@@ -114,7 +118,9 @@ class ImplicitVarargsArray extends ApplicationModeEndpoint, TImplicitVarargsArra
114118

115119
override Call getCall() { result = call }
116120

117-
override int getArgIndex() { result = idx }
121+
override string getMaDInput() {
122+
result = "Argument[" + idx + "]"
123+
}
118124

119125
override Top asTop() { result = this.getCall() }
120126

@@ -135,7 +141,7 @@ class MethodCall extends ApplicationModeEndpoint, TMethodCall {
135141

136142
override Call getCall() { result = call }
137143

138-
override int getArgIndex() { result = -1 }
144+
override string getMaDInput() { result = "Argument[this]" }
139145

140146
override Top asTop() { result = call }
141147

@@ -208,7 +214,7 @@ module ApplicationCandidatesImpl implements SharedCharacteristics::CandidateSig
208214
ApplicationModeGetCallable::getCallable(e).hasQualifiedName(package, type, name) and
209215
signature = ExternalFlow::paramsString(ApplicationModeGetCallable::getCallable(e)) and
210216
ext = "" and
211-
input = AutomodelJavaUtil::getArgumentForIndex(e.getArgIndex())
217+
input = e.getMaDInput()
212218
}
213219

214220
/**
@@ -267,7 +273,7 @@ class ApplicationModeMetadataExtractor extends string {
267273
) {
268274
exists(Callable callable |
269275
e.getCall().getCallee() = callable and
270-
input = AutomodelJavaUtil::getArgumentForIndex(e.getArgIndex()) and
276+
input = e.getMaDInput() and
271277
package = callable.getDeclaringType().getPackage().getName() and
272278
// we're using the erased types because the MaD convention is to not specify type parameters.
273279
// Whether something is or isn't a sink doesn't usually depend on the type parameters.

0 commit comments

Comments
 (0)