Lucas Rodriguez
12/20/2024, 6:26 PMfile
query:
SELECT * FROM file WHERE file.path LIKE '/usr/local/Caskroom/jd-gui/%%' AND file.path LIKE '/%.app';
It seems the first LIKE
does the directory walk, and the second LIKE
performs string matching? (I thought osquery would combine the two `LIKE`s somehow and then do the directory walk)
Am not saying this is a bug, just checking if I'm understanding the behavior of the table.FG
12/20/2024, 8:07 PM--planner
argument to possibly gain some insight, i would personally change that last clause to match on file.filename not file.path, maybe that will work for you?FG
12/20/2024, 8:13 PMSELECT * FROM file WHERE file.path LIKE '/Applications/%' AND file.path LIKE "%.app/" LIMIT 5;
Lucas Rodriguez
12/23/2024, 10:59 AM--planner
The thing is that they query works and I'm trying to understand why 🙂. Maybe I got it wrong that whenever you use LIKE
on path it would do directory traversal, but seems that only one is being used for traversing (AFAICS).Lucas Rodriguez
12/23/2024, 1:27 PMLIKE
is used first by osquery code to generate the paths AND then by the sqlite engine which will do string matching as usual. The second LIKE doesn't generate any results/paths (no .apps
in /
) but then it's useful for filtering just .app
s returned by the first LIKE
that does recursive search.FG
12/23/2024, 1:58 PM