If I'm doing `select * from shell_history` on a sc...
# sql
z
If I'm doing
select * from shell_history
on a schedule, does that read the whole
.bash_history
every time, or does it diff it in some way?
s
It would be the whole thing unless you filter on the time column
z
filter?
s
Use a
WHERE
clause
z
how would you be able to diff time in a sql statement?
s
For example, to get the events for the past hour:
select * from shell_history where time > strftime('%s', 'now', '-1 hour');
See here for SQLite’s date functions https://www.sqlite.org/lang_datefunc.html
z
thank you, I'll look into this
looks like this is a non-starter because
time
in
shell_history
is reliant on history timestamps enabled
Copy code
osquery> select * from users cross join shell_history on shell_history.uid = users.uid where time > strftime('%s', 'now', '-1 minutes');
doesn't return any results (when there should be.
s
Didn’t realize bash didn’t include a timestamp by default. Too used to zsh I guess 🙂
z
yeah, I turned it on in my bash shell, so it seemingly only works a little bit.