Skip to content

Commit

Permalink
Fix scan db reports for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwords committed Sep 25, 2024
1 parent 0047d6b commit 3abf23b
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 56 deletions.
12 changes: 6 additions & 6 deletions sql/beacon-only.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT s.fqdn) num_sites
FROM tracker t
JOIN tracking tr ON tr.tracker_id = t.id
JOIN site s ON s.id = tr.site_id
JOIN tracking_type tt ON tt.id = tr.tracking_type_id
JOIN scan ON scan.id = tr.scan_id
WHERE tt.name = "beacon"
AND scan.date > DATETIME("now", "-30 day")
WHERE tt.name = 'beacon'
AND scan.date > DATETIME('now', '-30 day')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan scan2 ON scan2.id = tr2.scan_id
LEFT JOIN tracking_type tt2 ON tt2.id = tr2.tracking_type_id
WHERE scan2.date > DATETIME("now", "-30 day")
AND (tt2.name != "beacon"
WHERE scan2.date > DATETIME('now', '-30 day')
AND (tt2.name != 'beacon'
OR tr2.tracking_type_id IS NULL)
GROUP BY t2.id
HAVING COUNT(tr2.site_id) > 2)
GROUP BY t.id
ORDER BY num_sites DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
8 changes: 4 additions & 4 deletions sql/chrome-only-30d.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT site.id) num_sites,
COUNT(DISTINCT s.id) num_scans
FROM tracker t
Expand All @@ -9,14 +9,14 @@ sqlite3 badger.sqlite3 -batch 'SELECT t.base,
JOIN site ON site.id = tr.site_id
WHERE s.browser_id = 2
AND s.daily_scan = 1
AND s.date > DATETIME("now", "-30 day")
AND s.date > DATETIME('now', '-30 day')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.browser_id != 2
AND s2.daily_scan = 1
AND s2.date > DATETIME("now", "-30 day"))
AND s2.date > DATETIME('now', '-30 day'))
GROUP BY t.id
ORDER BY num_sites DESC, num_scans DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
8 changes: 4 additions & 4 deletions sql/firefox-only-30d.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT site.id) num_sites,
COUNT(DISTINCT s.id) num_scans
FROM tracker t
Expand All @@ -9,14 +9,14 @@ sqlite3 badger.sqlite3 -batch 'SELECT t.base,
JOIN site ON site.id = tr.site_id
WHERE s.browser_id = 1
AND s.daily_scan = 1
AND s.date > DATETIME("now", "-30 day")
AND s.date > DATETIME('now', '-30 day')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.browser_id != 1
AND s2.daily_scan = 1
AND s2.date > DATETIME("now", "-30 day"))
AND s2.date > DATETIME('now', '-30 day'))
GROUP BY t.id
ORDER BY num_sites DESC, num_scans DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
10 changes: 5 additions & 5 deletions sql/gone-30d.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT site.id) num_sites,
COUNT(DISTINCT s.id) num_scans
FROM tracker t
JOIN tracking tr ON tr.tracker_id = t.id
JOIN scan s ON s.id = tr.scan_id
JOIN site ON site.id = tr.site_id
WHERE s.daily_scan = 1
AND s.date > DATETIME("now", "-12 month")
AND s.date <= DATETIME("now", "-30 day")
AND s.date > DATETIME('now', '-12 month')
AND s.date <= DATETIME('now', '-30 day')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.daily_scan = 1
AND s2.date > DATETIME("now", "-30 day"))
AND s2.date > DATETIME('now', '-30 day'))
GROUP BY t.id
ORDER BY num_sites DESC, num_scans DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
10 changes: 5 additions & 5 deletions sql/gone-yoy.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base, COUNT(DISTINCT site.id) num_sites, COUNT(DISTINCT s.id) num_scans
sqlite3 badger.sqlite3 -batch "SELECT t.base, COUNT(DISTINCT site.id) num_sites, COUNT(DISTINCT s.id) num_scans
FROM tracker t
JOIN tracking tr ON tr.tracker_id = t.id
JOIN scan s ON s.id = tr.scan_id
JOIN site ON site.id = tr.site_id
WHERE s.daily_scan = 1
AND s.date > DATETIME("now", "-24 month")
AND s.date <= DATETIME("now", "-12 month")
AND s.date > DATETIME('now', '-24 month')
AND s.date <= DATETIME('now', '-12 month')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.daily_scan = 1 AND s2.date > DATETIME("now", "-12 month"))
WHERE s2.daily_scan = 1 AND s2.date > DATETIME('now', '-12 month'))
GROUP BY t.id
ORDER BY num_sites DESC, num_scans DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
10 changes: 5 additions & 5 deletions sql/new-30d.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT site.id) num_sites,
COUNT(DISTINCT s.id) num_scans
FROM tracker t
JOIN tracking tr ON tr.tracker_id = t.id
JOIN scan s ON s.id = tr.scan_id
JOIN site ON site.id = tr.site_id
WHERE s.daily_scan = 1
AND s.date > DATETIME("now", "-30 day")
AND s.date > DATETIME('now', '-30 day')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.daily_scan = 1
AND s2.date > DATETIME("now", "-12 month")
AND s2.date <= DATETIME("now", "-30 day"))
AND s2.date > DATETIME('now', '-12 month')
AND s2.date <= DATETIME('now', '-30 day'))
GROUP BY t.id
ORDER BY num_sites DESC, num_scans DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
10 changes: 5 additions & 5 deletions sql/new-yoy.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT site.id) num_sites,
COUNT(DISTINCT s.id) num_scans
FROM tracker t
JOIN tracking tr ON tr.tracker_id = t.id
JOIN scan s ON s.id = tr.scan_id
JOIN site ON site.id = tr.site_id
WHERE s.daily_scan = 1
AND s.date > DATETIME("now", "-1 year")
AND s.date > DATETIME('now', '-1 year')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.daily_scan = 1
AND s2.date > DATETIME("now", "-2 year")
AND s2.date <= DATETIME("now", "-1 year"))
AND s2.date > DATETIME('now', '-2 year')
AND s2.date <= DATETIME('now', '-1 year'))
GROUP BY t.id
ORDER BY num_sites DESC, num_scans DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
8 changes: 4 additions & 4 deletions sql/noblocking-only-30d.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT site.id) num_sites,
COUNT(DISTINCT s.id) num_scans
FROM tracker t
Expand All @@ -15,8 +15,8 @@ sqlite3 badger.sqlite3 -batch 'SELECT t.base,
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.no_blocking = 0
AND s2.daily_scan = 1
AND s2.date > DATETIME("now", "-30 day"))
AND s.date > DATETIME("now", "-30 day")
AND s2.date > DATETIME('now', '-30 day'))
AND s.date > DATETIME('now', '-30 day')
GROUP BY t.id
ORDER BY num_sites DESC, num_scans DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
8 changes: 4 additions & 4 deletions sql/one-site-only-and-in-mdfp-30d.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash
#"/usr/bin/env bash

for line in $(sqlite3 badger.sqlite3 -batch -noheader 'SELECT tr.base, fqdn
for line in $(sqlite3 badger.sqlite3 -batch -noheader "SELECT tr.base, fqdn
FROM site
JOIN tracking t ON t.site_id = site.id
JOIN tracker tr ON tr.id = t.tracker_id
JOIN scan ON t.scan_id = scan.id
WHERE scan.date <= DATETIME("now", "-30 day")
WHERE scan.date <= DATETIME('now', '-30 day')
GROUP by tr.id
HAVING count(*) = 1
ORDER BY tr.base ASC'); do
ORDER BY tr.base ASC"); do

tracker="$(echo "$line" | cut -d '|' -f 1)"
if grep -q "$tracker" ../privacybadger/src/js/multiDomainFirstParties.js; then
Expand Down
12 changes: 6 additions & 6 deletions sql/pixelcookieshare-only.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT s.fqdn) num_sites
FROM tracker t
JOIN tracking tr ON tr.tracker_id = t.id
JOIN site s ON s.id = tr.site_id
JOIN tracking_type tt ON tt.id = tr.tracking_type_id
JOIN scan ON scan.id = tr.scan_id
WHERE tt.name = "pixelcookieshare"
AND scan.date > DATETIME("now", "-30 day")
WHERE tt.name = 'pixelcookieshare'
AND scan.date > DATETIME('now', '-30 day')
AND t.id NOT IN (SELECT t2.id
FROM tracker t2
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan scan2 ON scan2.id = tr2.scan_id
LEFT JOIN tracking_type tt2 ON tt2.id = tr2.tracking_type_id
WHERE scan2.date > DATETIME("now", "-30 day")
AND (tt2.name != "pixelcookieshare"
WHERE scan2.date > DATETIME('now', '-30 day')
AND (tt2.name != 'pixelcookieshare'
OR tr2.tracking_type_id IS NULL)
GROUP BY t2.id
HAVING COUNT(tr2.site_id) > 2)
GROUP BY t.id
ORDER BY num_sites DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t
8 changes: 4 additions & 4 deletions sql/sites-with-fingerprinters.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT s.fqdn AS site,
sqlite3 badger.sqlite3 -batch "SELECT s.fqdn AS site,
COUNT(*) num_records,
GROUP_CONCAT(DISTINCT t.base) AS fingerprinters
FROM site s
JOIN tracking tr ON tr.site_id = s.id
JOIN tracker t ON t.id = tr.tracker_id
JOIN tracking_type tt ON tt.id = tr.tracking_type_id
JOIN scan ON scan.id = tr.scan_id
WHERE tt.name = "canvas"
AND scan.date > DATETIME("now", "-30 day")
WHERE tt.name = 'canvas'
AND scan.date > DATETIME('now', '-30 day')
GROUP BY s.id
ORDER BY num_records DESC,
COUNT(DISTINCT t.base) DESC' | column -s '|' -t
COUNT(DISTINCT t.base) DESC" | column -s '|' -t
8 changes: 4 additions & 4 deletions sql/swarm-only-6m.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

sqlite3 badger.sqlite3 -batch 'SELECT t.base,
sqlite3 badger.sqlite3 -batch "SELECT t.base,
COUNT(DISTINCT site.id) num_sites,
COUNT(DISTINCT s.date) num_swarm_runs
FROM tracker t
Expand All @@ -13,8 +13,8 @@ sqlite3 badger.sqlite3 -batch 'SELECT t.base,
JOIN tracking tr2 ON tr2.tracker_id = t2.id
JOIN scan s2 ON s2.id = tr2.scan_id
WHERE s2.daily_scan = 1
AND s2.date > DATETIME("now", "-6 month"))
AND s.date > DATETIME("now", "-6 month")
AND s2.date > DATETIME('now', '-6 month'))
AND s.date > DATETIME('now', '-6 month')
GROUP BY t.id
ORDER BY num_sites DESC, num_swarm_runs DESC
LIMIT 30' | column -s '|' -t
LIMIT 30" | column -s '|' -t

0 comments on commit 3abf23b

Please sign in to comment.