require the file to be non-empty

This commit is contained in:
Erik Krogh Kristensen 2020-02-20 14:34:50 +01:00
Родитель b1cbfce50b
Коммит b2ccec28e0
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -69,6 +69,8 @@ class UselessCat extends DataFlow::CallNode {
this = candidate and
// We can create an equivalent `fs.readFile` call.
exists(createReadFileCall(this)) and
// There is a file to read, and not just a pair of quotes.
candidate.getFileArgument().length() >= 3 and
// wildcards, pipes, redirections, and multiple files are OK.
// (The multiple files detection relies on the fileArgument not containing spaces anywhere)
not candidate.getFileArgument().regexpMatch(".*(\\*|\\||>|<| ).*") and