MozillaSecurity/prefpicker

GitHub: MozillaSecurity/prefpicker

一款用于管理和生成 Firefox prefs.js 配置文件的 Python 工具,通过 YAML 模板简化模糊测试中的浏览器偏好设置管理。

Stars: 13 | Forks: 7

# PrefPicker [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/01fca22c6c025957.svg)](https://github.com/MozillaSecurity/prefpicker/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/MozillaSecurity/prefpicker/branch/master/graph/badge.svg)](https://codecov.io/gh/MozillaSecurity/prefpicker) [![Matrix](https://img.shields.io/badge/chat-%23fuzzing-green?logo=matrix)](https://matrix.to/#/#fuzzing:mozilla.org) [![PyPI](https://img.shields.io/pypi/v/prefpicker)](https://pypi.org/project/prefpicker) 用于管理和生成在测试 Firefox 时使用的 prefs.js 文件。此工具旨在简化我们 fuzzing 工具所使用的 prefs 的使用和跟踪。通过修改模板文件,可以创建自定义的 prefs.js 文件,而无需维护一个大部分内容重复的单独 prefs 文件版本。 ## YAML 模板结构 模板文档由 variants、prefs 和 values 组成。 _**pref**_ 是将被添加到 prefs.js 文件中的 preference 名称。这是一个不带引号的字符串。 有效的 prefs 可以在 [all.js](https://hg.mozilla.org/mozilla-central/file/tip/modules/libpref/init/all.js) 或 [StaticPrefList.yml](https://hg.mozilla.org/mozilla-central/file/tip/modules/libpref/init/StaticPrefList.yaml) 中找到。 __**review_on_close**__ 是可选的。它是一个相关的 Bugzilla ID 列表,用于帮助避免出现过时的条目。当列表中的所有 bug 都被关闭时,该条目将被审查,并在合适的情况下被移除。 _**value**_ 可以是 `bool`、`int`、`string` 或 `null`。可以添加多个潜在的值。 当存在多个值时,在生成输出时会随机选择其中一个。 使用 `null` 值会将该 pref 从 prefs.js 文件中排除(作为浏览器默认值)。 _**variant**_ 是要使用的值的子集,用于替代默认值。 除非指定了 variant,否则将使用默认 variant。 内置了一些机制来帮助保持文件的条理性: - 所有 prefs 必须有一个默认 variant - 所有 variants 必须在 variant 列表中定义 - variant 列表中的所有 variants 必须被使用 - 所有 variants 必须是一个列表并包含值 ``` # example.yml variant: # list of extra variants, default is implied - alt # name of variant pref: pref.name: # unquoted name of the pref used in prefs.js review_on_close: # optional - 123456 variants: default: # variant definition, default is required - 0 # potential value alt: # extra optional variant - 1 # if multiple values are defined one is chosen randomly - null # null is a special case meaning exclude the pref ``` ## 更新模板和添加 Prefs Prefs 位于 [template](/src/prefpicker/templates) 目录下的 `.yml` 文件中。 只应添加准备好进行测试的 prefs。 在向模板添加 pref 时,鼓励添加提供理由的注释,并指向 Bugzilla 中的 bug 以提供更多上下文。 如果 pref 尚不存在,并且仅用于非默认 variants,则必须向默认 variant 添加一个 `null` 条目。 ## 快速设置 使用 pip 安装 prefpicker。 ``` pip install prefpicker ``` ## 示例 使用内置的 [模板](/src/prefpicker/templates) 生成最新的 `prefs.js` 文件。 ``` prefpicker browser-fuzzing.yml prefs.js ``` 或者使用 `webrender` variant 从自定义模板生成 `prefs.js` 文件: ``` user@machine:~/prefpicker$ prefpicker custom/template.yml ~/Desktop/prefs.js --variant webrender Loading 'template.yml'... Loaded 255 prefs and 5 variants Generating 'prefs.js' using variant 'webrender'... Done. ``` 生成的 `prefs.js` 文件即可用于 Firefox。它看起来会像这样: ``` // Generated with PrefPicker @ 2020-02-08 00:50:29 UTC // Variant 'webrender' /// ... snip user_pref("fuzzing.enabled", true); /// ... snip // 'gfx.webrender.all' defined by variant 'webrender' user_pref("gfx.webrender.all", true); /// ... snip ```
标签:Firefox, Python, 无后门, 测试工具, 逆向工具