refactor(prefs): single-source-of-truth Firefox prefs dict + obsolescence verifier in update.py#1201
Draft
vringar wants to merge 1 commit into
Draft
refactor(prefs): single-source-of-truth Firefox prefs dict + obsolescence verifier in update.py#1201vringar wants to merge 1 commit into
vringar wants to merge 1 commit into
Conversation
…erifier; run it in update.py Consolidate OpenWPM's static Firefox default prefs into module-level PRIVACY_PREFS / OPTIMIZE_PREFS dicts in configure_firefox.py, the single source of truth. optimize_prefs() now iterates OPTIMIZE_PREFS; privacy() keeps its dynamic (browser_params-dependent) values inline but its pref names are tracked in PRIVACY_PREFS. Move datadir/verify_obsolete_prefs.py -> scripts/verify_obsolete_prefs.py and refactor it to import those same dicts (no hardcoded pref list) so the setter and the obsolescence verifier are structurally interlocked and cannot drift. Wire the verifier into scripts/update.py: after the Firefox bump it probes the installed Firefox for any pref OpenWPM sets that is no longer recognized and prints a non-fatal WARNING block.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix/obsolete-firefox-prefs #1201 +/- ##
==============================================================
- Coverage 61.87% 61.40% -0.48%
==============================================================
Files 40 40
Lines 3892 3842 -50
==============================================================
- Hits 2408 2359 -49
+ Misses 1484 1483 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes OpenWPM's default Firefox preferences a single source-of-truth that both
the setter (
configure_firefox.py) and the obsolescence verifier read,so the two are structurally interlocked and cannot drift. Wires the verifier
into
scripts/update.pyso every dependency/Firefox update auto-checks theprefs we set for obsolescence.
What changed
1. Prefs consolidated into dicts (single source of truth)
openwpm/deploy_browsers/configure_firefox.pynow defines two module-leveldicts:
OPTIMIZE_PREFS: dict[str, bool | int | str]— the 54 staticspeed/telemetry/safebrowsing/update prefs, with the original comment grouping
preserved.
optimize_prefs()is nowfor name, value in OPTIMIZE_PREFS.items(): fo.set_preference(name, value).PRIVACY_PREFS: dict[str, bool | int | str]— the privacy pref names(
privacy.donottrackheader.enabled,network.cookie.cookieBehavior). Theseprefs' values are dynamic (computed from
browser_params), soprivacy()still sets them inline/conditionally; only the names live in the dict so the
verifier can probe them.
Behavior is identical — same prefs, same values, same ordering (privacy
then optimize), and
browser_params.prefsstill override last. Verified bymock-capturing the new
optimize_prefs()output and diffing it against thepre-refactor source: 54/54 optimize prefs match on name+value, privacy
set_preferencecalls byte-identical, andPRIVACY_PREFScovers exactly theprivacy pref names.
2. Verifier moved + interlocked
datadir/verify_obsolete_prefs.py→scripts/verify_obsolete_prefs.py. Itnow imports
PRIVACY_PREFSandOPTIMIZE_PREFSand probes their.keys()— no hardcoded/copied pref list. It keeps the Firefoxdefault-branch probe (
getDefaultBranch('').getPrefType) and the honestcaveat: a default-branch absence is a strong-but-not-absolute signal, so
INVALID prefs are reported as review candidates, not auto-removed. Takes
FIREFOX_BINARYfrom the environment.3. Wired into
scripts/update.pyAfter the Firefox bump step (
firefox_version.update_if_needed()),check_obsolete_firefox_prefs()runsscripts/verify_obsolete_prefs.pyagainst the installed Firefox (
firefox-bin/firefox-bin, or$FIREFOX_BINARY)and prints a clear WARNING block listing any pref that now probes obsolete.
Fully non-fatal: a missing binary, a launch failure, or obsolete prefs only
warn — the update is never blocked.
Verification
from openwpm.deploy_browsers.configure_firefox import PRIVACY_PREFS, OPTIMIZE_PREFS→2 54import openwpm.deploy_browsers.deploy_firefoximports cleanlyscripts/verify_obsolete_prefs.pyimports and builds a 56-pref list (privacy-first, no dupes)update.pyskip path exercised (non-fatal when no binary present)A full crawl was not run (browser env-blocked); the static "same prefs" proof
is the key check.