Hello, I'm facing a false positive in path traversal with the following code :
public String doSomething(ArgType arg1, SinkType sink1) {
if (!Util.isValidFilename(sink1.getFilename())) {
throw new ServiceException();
}
Path testPath = Paths.get(sink1.getFilename());
isValidFilename definition :
static boolean isValidFilename(String filename) {
if (filename.contains("/") || filename.contains("\\")) {
return false;
}
return true;
}
}
basically the isValidFilename method doesn't cut the flow when it reaches Util.isValidFilename(sink1.getFilename()). Do you know how I can add some customizations to PathSanitizer so that it takes into consideration this case.
I have tried things like
class ContainsSanitizer extends PathInjectionSanitizer {
ContainsSanitizer() {
exists(MethodCall ma|
ma.getMethod().getName() = "contains" and ma = this.asExpr() and isDisallowedWord(ma.getArgument(0)) )
}
}
this doesn't work as well.
Appreciate any pointers
Hello, I'm facing a false positive in path traversal with the following code :
isValidFilename definition :
basically the isValidFilename method doesn't cut the flow when it reaches
Util.isValidFilename(sink1.getFilename()). Do you know how I can add some customizations to PathSanitizer so that it takes into consideration this case.I have tried things like
this doesn't work as well.
Appreciate any pointers