Python path: None title crashes the loop; bad privacy rule action crashes; invalid privacy rules fail open

Aperta
#180 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, python
Ambito
desktop

Direzione di ricerca

Start in main.py at heartbeat_loop: the transform_window call sits outside the try, and both it and research_filter.transform assume a string title. Reproduce with the three snippets, then read printAppStatus.jxa (only undefined is mapped, not null), compile_privacy_rules (the unhashable action), and the swift branch that refuses to start when rules are configured — that branch is the model for failing closed. Done means non-string titles are coerced, invalid rules are skipped without crashing, and a maintainer has answered whether main() should exit when len(compiled) < len(raw).

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Three crash/fail-open cases in the Python path. Each is reproduced on master 76b3f6f with the snippet shown.

1. A None title crashes the loop. transform_window runs outside the try in heartbeat_loop (main.py), so an exception there ends the watcher.

transform_window({"app": "Finder", "title": None}, exclude_titles=[re.compile("x")])  # TypeError
research_filter.transform({"app": "Google Chrome", "title": None}, {"a": "b"})        # AttributeError

printAppStatus.jxa only replaces title === undefined. An AXTitle that is null would pass through as "title": null. I haven't confirmed that on a Mac, so treat the input source as plausible; the crash itself is certain. A likely fix is to also map null in the JXA, and/or coerce a non-string title to "" before the transforms.

2. A non-string privacy action crashes at startup instead of being skipped. The docstring promises invalid rules are "skipped with an error log":

compile_privacy_rules([{"pattern": "x", "action": ["drop"]}])  # TypeError: unhashable type: 'list'

3. An invalid privacy rule fails open. A rule with a bad regex (e.g. a stray () or an unknown action is logged and skipped, and the watcher then sends unfiltered titles on Linux, Windows and jxa/applescript. The swift branch refuses to start when any rule is configured "so titles are not leaked". An invalid exclude_titles regex also exits (try_compile_regex). Should main() exit when len(compiled) < len(raw)? That is a behaviour change, so I'm asking rather than opening a PR.

Lingua principale
Python
Stelle
133
Fork
92
Merge medio
5g 3h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ActivityWatch/aw-watcher-window

Tutte le issue di ActivityWatch/aw-watcher-window

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.