audit: fix cookie expiry/partition fidelity and profile-safety gaps

- Cookie stream: moz_cookies.expiry is milliseconds, but CDP expects
  seconds. The old code imported 52 already-expired cookies in the real
  profile and gave every remaining cookie a ~55,000-year expiry; convert
  units before comparing/sending, and skip session cookies that cannot
  survive the temporary Chromium session.
- Dashboard cookies: request partitionKey:{} for Chrome as well as Firefox
  (Chrome also omits CHIPS cookies otherwise), keep hasCrossSiteAncestor,
  omit the "unspecified" SameSite attribute for older targets, and never
  fall back to an arbitrary cookie store when importing.
- Profile safety: resolve symlinks before cp -a (a symlinked --firefox-profile
  was copied as a symlink and Firefox then opened the original profile),
  detect Chromium's dangling SingletonLock symlink with lstat, check Firefox's
  .parentlock/open descriptors via /proc instead of an optional fuser, refuse
  Firefox-looking Chromium targets and root/home, keep the OS password store
  for existing Chromium profiles, and clean the sensitive profile clone on
  SIGINT/SIGTERM.
- Exporter: never write through a dangling output symlink (O_EXCL|O_NOFOLLOW),
  refuse to export while Firefox holds the profile lock, and canonicalise
  origins so one odd origin cannot make the importer reject the whole bundle.
- Revert formatting-only manifest changes; align tools/README with the code
  (IndexedDB is supported, Node.js 22.12+, lock/symlink/password-store and
  key-generator limitations) and add regression tests for all of the above.
This commit is contained in:
souta
2026-10-23 20:54:18 +09:00
parent 1b617cef84
commit 7fb8ef7509
26 changed files with 1021 additions and 210 deletions
+16 -12
View File
@@ -1,8 +1,10 @@
name: Unit tests
on:
push:
branches: [main, feat/profile-storage-migration]
branches: [main]
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
@@ -14,24 +16,26 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Python dependencies
run: python3 -m pip install cryptography
- name: Python tests
run: python3 -m unittest discover -s tests -p 'test_*.py'
- name: Browser API mock tests
run: node tests/test_storage_browser.cjs
- name: Profile safety tests
run: node tests/test_profile_safety.cjs
- name: IndexedDB codec tests
run: node tests/test_indexeddb_codec.cjs
- name: IndexedDB path tests
run: node tests/test_indexeddb_paths.cjs
- name: Python syntax
run: python3 -m py_compile tools/list_firefox_idb_origins.py tools/firefox_localstorage.py tools/firefox_cookie_stream.py
run: python3 -m py_compile tools/*.py tests/*.py
- name: JavaScript syntax
run: |
node --check chrome/dashboard.js
node --check firefox/dashboard.js
node --check tools/chromium_localstorage_import.cjs
node --check tests/e2e_cross_browser.cjs
node --check tools/indexeddb_migrate.cjs
node --check tools/indexeddb_codec.js
node --check tests/e2e_indexeddb.cjs
node --check tools/chromium_cookie_import.cjs
node --check tests/e2e_cookie_cli.cjs
for file in tools/*.cjs tools/*.js tests/*.cjs chrome/dashboard.js firefox/dashboard.js; do
node --check "$file"
done
- name: CLI help
run: node tools/chromium_localstorage_import.cjs --help
run: |
node tools/chromium_localstorage_import.cjs --help
node tools/indexeddb_migrate.cjs --help