Skip to content

Commit

Permalink
Fix scan db queries for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwords committed Sep 12, 2024
1 parent ec58061 commit 605a43d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions search_log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi
show_trackers_by_site() {
local query_results
query_results=$(sqlite3 badger.sqlite3 -batch \
'SELECT site.fqdn "site", scan.daily_scan, GROUP_CONCAT(DISTINCT tr.base) FROM tracking t JOIN site ON site.id = t.site_id JOIN tracker tr ON tr.id = t.tracker_id JOIN scan ON scan.id = t.scan_id WHERE scan.date > DATETIME("now", "-30 day") AND site.fqdn LIKE "%'"$1"'%" GROUP BY site.fqdn, scan.daily_scan')
"SELECT site.fqdn AS site, scan.daily_scan, GROUP_CONCAT(DISTINCT tr.base) FROM tracking t JOIN site ON site.id = t.site_id JOIN tracker tr ON tr.id = t.tracker_id JOIN scan ON scan.id = t.scan_id WHERE scan.date > DATETIME('now', '-30 day') AND site.fqdn LIKE '%$1%' GROUP BY site.fqdn, scan.daily_scan")
if [ -n "$query_results" ]; then
echo "Recent trackers on matching site domains:"
echo "$query_results" | column -s "|" -t
Expand All @@ -28,7 +28,7 @@ show_trackers_by_site() {
show_sites_by_tracker() {
local query_results
query_results=$(sqlite3 badger.sqlite3 -batch \
'SELECT tr.base "tracker", scan.daily_scan, GROUP_CONCAT(DISTINCT site.fqdn) FROM tracking t JOIN site ON site.id = t.site_id JOIN tracker tr ON tr.id = t.tracker_id JOIN scan ON scan.id = t.scan_id WHERE scan.date > DATETIME("now", "-30 day") AND tr.base LIKE "%'"$1"'%" GROUP BY tr.base, scan.daily_scan')
"SELECT tr.base AS tracker, scan.daily_scan, GROUP_CONCAT(DISTINCT site.fqdn) FROM tracking t JOIN site ON site.id = t.site_id JOIN tracker tr ON tr.id = t.tracker_id JOIN scan ON scan.id = t.scan_id WHERE scan.date > DATETIME('now', '-30 day') AND tr.base LIKE '%$1%' GROUP BY tr.base, scan.daily_scan")
if [ -n "$query_results" ]; then
echo "Recent site domains with matching trackers:"
echo "$query_results" | column -s "|" -t
Expand All @@ -39,7 +39,7 @@ show_sites_by_tracker() {
show_most_recent_matches() {
local query_results num_results
query_results=$(sqlite3 badger.sqlite3 -batch -noheader \
'SELECT tr.base, scan.date, b.name, GROUP_CONCAT(site.fqdn), GROUP_CONCAT(DISTINCT tt.name) FROM tracking t JOIN tracker tr ON t.tracker_id = tr.id JOIN scan ON scan.id = t.scan_id JOIN browser b ON b.id = scan.browser_id JOIN site ON site.id = t.site_id LEFT JOIN tracking_type tt ON tt.id = t.tracking_type_id WHERE scan.daily_scan = 1 AND tr.base LIKE "%'"$1"'%" GROUP BY scan.date ORDER BY scan.date DESC')
"SELECT tr.base, scan.date, b.name, GROUP_CONCAT(site.fqdn), GROUP_CONCAT(DISTINCT tt.name) FROM tracking t JOIN tracker tr ON t.tracker_id = tr.id JOIN scan ON scan.id = t.scan_id JOIN browser b ON b.id = scan.browser_id JOIN site ON site.id = t.site_id LEFT JOIN tracking_type tt ON tt.id = t.tracking_type_id WHERE scan.daily_scan = 1 AND tr.base LIKE '%$1%' GROUP BY scan.date ORDER BY scan.date DESC")
if [ -z "$query_results" ]; then
printf "No daily scan matches in badger.sqlite3\n\n"
else
Expand Down

0 comments on commit 605a43d

Please sign in to comment.