Improve representation of implicit varargs arrays to more reliably filter out known flow steps.

This commit is contained in:
Max Schaefer
2024-02-06 14:42:16 +00:00
parent 525f27173d
commit 02547d3839
2 changed files with 7 additions and 10 deletions

View File

@@ -35,14 +35,10 @@ newtype TApplicationModeEndpoint =
arg = DataFlow::getInstanceArgument(call) and
not call instanceof ConstructorCall
} or
TImplicitVarargsArray(Call call, DataFlow::Node arg, int idx) {
TImplicitVarargsArray(Call call, DataFlow::ImplicitVarargsArray arg, int idx) {
AutomodelJavaUtil::isFromSource(call) and
exists(Argument argExpr |
arg.asExpr() = argExpr and
call.getArgument(idx) = argExpr and
argExpr.isVararg() and
not exists(int i | i < idx and call.getArgument(i).(Argument).isVararg())
)
call = arg.getCall() and
idx = call.getCallee().getVaragsParameterIndex()
} or
TMethodReturnValue(Call call) {
AutomodelJavaUtil::isFromSource(call) and

View File

@@ -40,11 +40,12 @@ class Test {
); // $ sourceModelCandidate=newInputStream(Path,OpenOption[]):ReturnValue
}
public static InputStream getInputStream(String openPath) throws Exception {
public static InputStream getInputStream(String openPath, String otherPath) throws Exception {
return Test.getInputStream( // the call is not a source candidate (argument to local call)
Paths.get(
openPath // $ negativeSinkExample=get(String,String[]):Argument[0] // modeled as a flow step
) // $ sourceModelCandidate=get(String,String[]):ReturnValue
openPath, // $ negativeSinkExample=get(String,String[]):Argument[0] // modeled as a flow step
otherPath
) // $ sourceModelCandidate=get(String,String[]):ReturnValue negativeSinkExample=get(String,String[]):Argument[1]
);
}