Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02547d3

Browse files
author
Max Schaefer
committed
Improve representation of implicit varargs arrays to more reliably filter out known flow steps.
1 parent 525f271 commit 02547d3

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

java/ql/automodel/src/AutomodelApplicationModeCharacteristics.qll

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@ newtype TApplicationModeEndpoint =
3535
arg = DataFlow::getInstanceArgument(call) and
3636
not call instanceof ConstructorCall
3737
} or
38-
TImplicitVarargsArray(Call call, DataFlow::Node arg, int idx) {
38+
TImplicitVarargsArray(Call call, DataFlow::ImplicitVarargsArray arg, int idx) {
3939
AutomodelJavaUtil::isFromSource(call) and
40-
exists(Argument argExpr |
41-
arg.asExpr() = argExpr and
42-
call.getArgument(idx) = argExpr and
43-
argExpr.isVararg() and
44-
not exists(int i | i < idx and call.getArgument(i).(Argument).isVararg())
45-
)
40+
call = arg.getCall() and
41+
idx = call.getCallee().getVaragsParameterIndex()
4642
} or
4743
TMethodReturnValue(Call call) {
4844
AutomodelJavaUtil::isFromSource(call) and

java/ql/automodel/test/AutomodelApplicationModeExtraction/Test.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ public static InputStream getInputStream(Path openPath) throws Exception {
4040
); // $ sourceModelCandidate=newInputStream(Path,OpenOption[]):ReturnValue
4141
}
4242

43-
public static InputStream getInputStream(String openPath) throws Exception {
43+
public static InputStream getInputStream(String openPath, String otherPath) throws Exception {
4444
return Test.getInputStream( // the call is not a source candidate (argument to local call)
4545
Paths.get(
46-
openPath // $ negativeSinkExample=get(String,String[]):Argument[0] // modeled as a flow step
47-
) // $ sourceModelCandidate=get(String,String[]):ReturnValue
46+
openPath, // $ negativeSinkExample=get(String,String[]):Argument[0] // modeled as a flow step
47+
otherPath
48+
) // $ sourceModelCandidate=get(String,String[]):ReturnValue negativeSinkExample=get(String,String[]):Argument[1]
4849
);
4950
}
5051

0 commit comments

Comments
 (0)