mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Java: fix 'matches' false branch
This commit is contained in:
@@ -684,16 +684,33 @@ public class Test {
|
||||
// branch = false
|
||||
{
|
||||
String source = (String) source();
|
||||
if (source.matches(".*[\\./\\\\].*")) {
|
||||
sink(source); // $ hasTaintFlow
|
||||
} else {
|
||||
sink(source); // Safe
|
||||
}
|
||||
}
|
||||
{
|
||||
String source = (String) source();
|
||||
if (source.matches(".+[\\./\\\\].+")) {
|
||||
sink(source); // $ hasTaintFlow
|
||||
} else {
|
||||
sink(source); // Safe
|
||||
}
|
||||
}
|
||||
{
|
||||
String source = (String) source();
|
||||
// does not match whole string
|
||||
if (source.matches("[\\./\\\\]+")) {
|
||||
sink(source); // $ hasTaintFlow
|
||||
} else {
|
||||
sink(source); // $ Safe
|
||||
sink(source); // $ hasTaintFlow
|
||||
}
|
||||
}
|
||||
{
|
||||
String source = (String) source();
|
||||
// not a complete sanitizer since it doesn't protect against absolute path injection
|
||||
if (source.matches("[\\.]+")) {
|
||||
if (source.matches(".+[\\.].+")) {
|
||||
sink(source); // $ hasTaintFlow
|
||||
} else {
|
||||
sink(source); // $ hasTaintFlow
|
||||
|
||||
Reference in New Issue
Block a user