Commit Graph

47 Commits

Author SHA1 Message Date
Ethan Glasser-Camp
2b966460f6 Bug 1351678: Handle resolved conflicts correctly, r=kmag
The elements of the SyncResultObject#conflicts field are {local,
remote} pairs.  However, the elements of the SyncResultObject#resolved
field are just the resolutions, and trying to access "local" and
"remote" fields of those resolutions causes a crash. Add a test that
demonstrates the error, and then fix it.

MozReview-Commit-ID: LF0NBw5VKBC
2017-04-20 13:44:46 -04:00
Kris Maglione
50f77bbcb4 Bug 1333477: Part 2 - Remove "browser" environment from ESLint settings. r=aswan
MozReview-Commit-ID: LCxI6JVp7Xo
2017-03-12 14:16:13 -07:00
Ethan Glasser-Camp
d73b81655b Bug 1328974: Record metrics for chrome.storage.sync usage, r=bsmedberg,kmag
MozReview-Commit-ID: 7c2CHLuXxS6
2017-01-17 13:25:02 -05:00
Ethan Glasser-Camp
8e51fef619 Bug 1321570 - use dependency injection for fxAccounts, r=kmag
Get rid of the ugly hack where test code monkeypatches a singleton to
convince the rest of the ExtensionStorageSync code that a fake user is
logged in. Instead, take a handle to the fxAccounts service at
construction time. Test code can provide any kind of fxAccounts it
wants, including one that has a hard-coded user.

This provokes a bunch of changes:

- ExtensionStorageSync is now no longer a singleton, but a class. You
  have to instantiate it in order to do anything with it. A global
  instance extensionStorageSync is provided for use by Sync code as
  well as WebExtension code.

- CryptoCollection is now also a class, and each ExtensionStorageSync
  instance has its own CryptoCollection. This dependency should maybe
  also be injected, but for the time being it doesn't provide us any
  value to do so.

- Converting singletons with asynchronous methods to classes is a pain
  in the neck. We convert async method foo from `foo:
  Task.async(....)` to `async foo() { .... }`. While we're here,
  convert KeyRingEncryptionRemoteTransformer#decode to async/await to
  eliminate a need for `let self = this`.

- Update Sync code and WebExtension code to use extensionStorageSync.

- There's a cyclic dependency where CryptoCollection#sync depends on
  ExtensionStorageSync#_syncCollection which depends on
  CryptoCollection#getKeyRing. As a short-term hack, we now require an
  ExtensionStorageSync argument to CryptoCollection#sync.

- KeyRingEncryptionRemoteTransformer now takes a handle to fxAccounts
  on construction time as well. Because this is the only
  EncryptionRemoteTransformer subclass that accesses fxAccounts, we
  can get rid of the hack where the tests monkeypatch something in the
  EncryptionRemoteTransformer prototype.

- CollectionKeyEncryptionRemoteTransformer now takes a handle to a
  CryptoCollection, rather than relying on a global one.

- A bunch of methods that previously assumed access to fxAccounts now
  check if fxAccounts is present (i.e. if we're on Android). Strictly
  speaking, this isn't required by this change, but it helps make
  certain kinds of failure a little easier to diagnose.

- Update tests, including extracting a domain-specific helper method
  to hide the use of CollectionKeyEncryptionRemoteTransformer. We now
  no longer monkeypatch in our mock fxaService, but pass it to the
  test so that it can do whatever it wants with it. We also provide an
  ExtensionStorageSync instance for convenience. Access to the global
  cryptoCollection is now done through an ExtensionStorageSync
  instance.

To summarize, we've gone from a situation where a bunch of singletons
had implicit dependencies on other singletons in a shared global
namespace, to a situation where dependencies are provided explicitly
using method/constructor arguments. This highlights some of the
dependencies present:

- ExtensionStorageSync depends on CryptoCollection and fxAccounts if
  it needs to sync

- Every collection created via openCollection needs a handle to
  CryptoCollection so it can correctly create its remote transformers

- CryptoCollection needs a handle to fxAccounts so it can create its
  own remote transformer for its special collection

Most of this is only possible, or at least much easier, because we no
longer try to juggle Sqlite connections but just keep one around
forever.

However, please note:

- CryptoCollection needs a handle to ExtensionStorageSync to actually
  perform syncing logic because that's where we foolishly put the
  logic to make requests

- There's still a backing Sqlite store which is shared by everything

- There's still a singleton tracking contexts that opened extensions
  which we manage to try to clean contexts up correctly

MozReview-Commit-ID: DGIzyRTdYZ1
2017-01-10 16:44:01 -05:00
Ethan Glasser-Camp
447d4b287d Bug 1321570 - Move ExtensionStorageSync crypto out of services/sync, r=kmag
Since services/sync doesn't ship on Android, this meant
conditionally-defining some variables such as `cryptoCollection` and
`CollectionKeyEncryptionRemoteTransformer` depending on whether or not
we were on Android. However, none of these definitions really rely on
functionality that isn't present on Android (although you can't really
use them yet either). Move the dependency together with the dependant
code so we can simplify a bit. This lets us remove conditional uses of
`cryptoCollection` and `CollectionKeyEncryptionRemoteTransformer`.

Because the WebExtensions source directory has more stringent eslint
rules, we end up reformatting and commenting a bit in addition to
moving.

MozReview-Commit-ID: 2ddDeymYFNi
2017-02-13 15:06:02 -05:00
Ethan Glasser-Camp
3e4199a169 Bug 1333810: Hash record IDs during encryption, r=kmag,rnewman
This does a sha256 of record IDs, the same way we do for collection
IDs, during encryption.

The way we compute the new ID (using an overridden method) is a little
bit of a hack, but we use the new ID as part of the HMAC. This also
invalidates a previous assumption, which is that we kept record IDs
the same during decryption.

MozReview-Commit-ID: Gbzlo9OE1he
2017-01-31 13:09:38 -05:00
Ethan Glasser-Camp
622720b262 Bug 1333810: Redo hashing of collection ID, r=kmag,rnewman
This ties the collection ID used for a given extension to the "salts"
record. This blocks an attack where, given the user's ID, an attacker
could just hash all the extension IDs on addons.mozilla.org to
generate possible hashed collection IDs.

MozReview-Commit-ID: OABsOOMn2F
2017-01-30 19:07:02 -05:00
Ethan Glasser-Camp
cd9bfb54e8 Bug 1333810: Add salts to the keys record, r=kmag,rnewman
Because these need to be encrypted with kB like the keyring does, and
wiped at the same time as the keyring does, just smush them into the
keyring. Rename `ensureKeysFor` to `ensureCanSync`, but don't update
it to return the salts -- for now, we don't need that.

MozReview-Commit-ID: DOJxdx5ugKl
2017-01-30 16:03:59 -05:00
Ethan Glasser-Camp
a4f073ff89 Bug 1331467: Enable chrome.storage.sync by default, r=kmag
MozReview-Commit-ID: 76wXwJGobIt
2017-01-18 11:44:17 -05:00
Ryan VanderMeulen
4cd658dde1 Backed out changeset 442d75009799 (bug 1331467) for test_ext_storage_content.html failures. 2017-01-20 18:33:47 -05:00
Ethan Glasser-Camp
b68b961fb3 Bug 1331467: Enable chrome.storage.sync by default, r=kmag
MozReview-Commit-ID: 76wXwJGobIt
2017-01-18 11:44:17 -05:00
Mark Banner
ac52569fff Bug 1329614 - [eslint] Catch more cases of importing globals from 'var foo = Cu.import('...');'. r=jaws
MozReview-Commit-ID: 5NKHHb70YA6
2017-01-09 10:12:26 +00:00
Ethan Glasser-Camp
244ce12521 Bug 1319742 - UUIDs should be strings, not objects, r=markh
`generateUUID()` returns an `nsID`, which is not exactly the same as a
UUID. `nsID`s can be converted to strings using `toString()`, but if
you use `JSON.stringify()`, they become `{}`. Object comparison in JS
performs identity comparison, which would be useless even if the UUIDs
were sensible, which they aren't. As a result, trying to sync keyrings
always failed, because it always seemed like UUIDs had changed, even
when they hadn't.

Because it never occurred to me that UUIDs wouldn't be strings, I
never even wrote a test for this. Correct this, and fix the test.

Thanks to :vasilica_mihasca and :markh for reporting and diagnosing this.

MozReview-Commit-ID: EthxkFFwRbQ
2016-11-29 14:15:55 -05:00
Mark Hammond
60f8d65ee7 Bug 1320193 - remove trailing \n from log message. r=glasserc
MozReview-Commit-ID: LwdPOwXmS5i
2016-11-25 09:01:05 +11:00
Ethan Glasser-Camp
789a803a51 Bug 1317841 - Update version of kinto.js to v6.0.0, r=MattN
This major version of kinto.js released without a FirefoxStorage
adapter. Since Gecko is the only project with a need for this adapter
as well as the only one who can use it, that file moves to this repo
as a new kinto-storage-adapter.js. This file is mostly a copy of the
most recent FirefoxStorage.js, plus some other non-exported utility
functions copied from kinto.js to make it work.

This changes the export of the kinto-offline-client.js from a
`loadKinto` function which returns the Kinto class, to the actual
Kinto class itself, with the user expected to "hook up" the
adapter. It turns out that this doesn't change much in how we actually
use Kinto, since we were always previously explicitly selecting the
Kinto adapter.

This release of kinto.js also changes some of the build options
around, which changes the minified output of kinto-offline-client.js.

There are still some outstanding stylistic complaints about
FirefoxAdapter having to do with its _init static method which is
public and the fact that sometimes FirefoxAdapter manages its own
Sqlite connection and sometimes it doesn't. These will be addressed in
a future patch.

MozReview-Commit-ID: HF0oNCEDcFs
2016-11-15 19:38:53 -05:00
Ehsan Akhgari
51a8c23eb1 Bug 1318217 - Remove AppsUtils; r=baku 2016-11-17 12:08:13 -05:00
Ethan Glasser-Camp
1a7b41e0a8 Bug 1253740 - Try to build and function even on Android, r=kmag
MozReview-Commit-ID: 5NGXzNhHGUN
2016-11-07 12:13:08 -05:00
Ethan Glasser-Camp
57d1272373 Bug 1253740 - Handle password resets more correctly, r=markh
MozReview-Commit-ID: 1mSvbsYP9fV
2016-09-30 12:12:58 -04:00
Ethan Glasser-Camp
17e5ad725d Bug 1253740 - Define checkSyncKeyRing() which reuploads keys when passwords change, r=markh
MozReview-Commit-ID: B5Ptj4MGAC
2016-10-03 19:19:13 -04:00
Ethan Glasser-Camp
01011fd94d Bug 1253740 - Hash extension ID to obfuscate installed add-ons, r=bsilverberg,kmag
MozReview-Commit-ID: ASBrDxIq2lF
2016-07-28 12:20:42 -04:00
Ethan Glasser-Camp
32c03ceb3d Bug 1253740 - Introduce extensionIdToCollectionId, r=bsilverberg,kmag
MozReview-Commit-ID: 5nDVtleknyN
2016-07-27 16:16:09 -04:00
Ethan Glasser-Camp
1c16eba2cc Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs
2016-09-08 14:16:09 -04:00
Ethan Glasser-Camp
7f289b0749 Bug 1253740 - Introduce extension-storage engine with a sanity test, r=markh
Note that this "enables" the engine using a pref, even though it might
not be ready yet, so that the tests can pass.

MozReview-Commit-ID: AZ0TVERiQDU
2016-09-08 14:23:12 -04:00
Michiel de Jong
f4b60082d3 Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj
2016-08-11 18:16:37 -04:00
Wes Kocher
f17d46cc2b Backed out 9 changesets (bug 1253740) for xpcshell failures a=backout
Backed out changeset 903890f218dd (bug 1253740)
Backed out changeset 1b13fe394b66 (bug 1253740)
Backed out changeset e1312ab53299 (bug 1253740)
Backed out changeset 5b5338a2baeb (bug 1253740)
Backed out changeset d3d89d4e2d87 (bug 1253740)
Backed out changeset 96da5e6944b8 (bug 1253740)
Backed out changeset 4fbff333994f (bug 1253740)
Backed out changeset 653788e146f2 (bug 1253740)
Backed out changeset b98fa03d8c15 (bug 1253740)
2016-11-11 18:59:24 -08:00
Ethan Glasser-Camp
fe582dfcca Bug 1253740 - Try to build and function even on Android, r=kmag
MozReview-Commit-ID: 5NGXzNhHGUN
2016-11-07 12:13:08 -05:00
Ethan Glasser-Camp
377f8b2ad2 Bug 1253740 - Handle password resets more correctly, r=markh
MozReview-Commit-ID: 1mSvbsYP9fV
2016-09-30 12:12:58 -04:00
Ethan Glasser-Camp
9966c5b1d5 Bug 1253740 - Define checkSyncKeyRing() which reuploads keys when passwords change, r=markh
MozReview-Commit-ID: B5Ptj4MGAC
2016-10-03 19:19:13 -04:00
Ethan Glasser-Camp
1edddc87a9 Bug 1253740 - Hash extension ID to obfuscate installed add-ons, r=bsilverberg,kmag
MozReview-Commit-ID: ASBrDxIq2lF
2016-07-28 12:20:42 -04:00
Ethan Glasser-Camp
521d41e86d Bug 1253740 - Introduce extensionIdToCollectionId, r=bsilverberg,kmag
MozReview-Commit-ID: 5nDVtleknyN
2016-07-27 16:16:09 -04:00
Ethan Glasser-Camp
492b52f8a9 Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs
2016-09-08 14:16:09 -04:00
Ethan Glasser-Camp
a5715ea3a2 Bug 1253740 - Introduce extension-storage engine with a sanity test, r=markh
Note that this "enables" the engine using a pref, even though it might
not be ready yet, so that the tests can pass.

MozReview-Commit-ID: AZ0TVERiQDU
2016-09-08 14:23:12 -04:00
Michiel de Jong
a1fdb6f3ff Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj
2016-08-11 18:16:37 -04:00
Sebastian Hengst
35ad3e7e0a Backed out changeset 396333163897 (bug 1253740) for failing xpcshell /test_ext_storage.js on Android and Linux. r=backout on a CLOSED TREE 2016-11-02 16:42:22 +01:00
Sebastian Hengst
813b5b83be Backed out changeset 39e08d903b48 (bug 1253740) 2016-11-02 16:40:07 +01:00
Sebastian Hengst
5c978afde0 Backed out changeset d7e4e2a7c0a6 (bug 1253740) 2016-11-02 16:39:59 +01:00
Sebastian Hengst
7eb50b7d66 Backed out changeset 155b13cc953d (bug 1253740) 2016-11-02 16:39:55 +01:00
Sebastian Hengst
6828123d53 Backed out changeset b8bd9da79a5e (bug 1253740) 2016-11-02 16:39:51 +01:00
Sebastian Hengst
5275330c76 Backed out changeset 1042e602ba84 (bug 1253740) 2016-11-02 16:39:46 +01:00
Sebastian Hengst
641ba742e6 Backed out changeset a73da05c87ba (bug 1253740) 2016-11-02 16:39:42 +01:00
Ethan Glasser-Camp
297207debe Bug 1253740 - Handle password resets more correctly, r=markh
MozReview-Commit-ID: 1mSvbsYP9fV
2016-09-30 12:12:58 -04:00
Ethan Glasser-Camp
ca4e737184 Bug 1253740 - Define checkSyncKeyRing() which reuploads keys when passwords change, r=markh
MozReview-Commit-ID: B5Ptj4MGAC
2016-10-03 19:19:13 -04:00
Ethan Glasser-Camp
452b8dca85 Bug 1253740 - Hash extension ID to obfuscate installed add-ons, r=bsilverberg,kmag
MozReview-Commit-ID: ASBrDxIq2lF
2016-07-28 12:20:42 -04:00
Ethan Glasser-Camp
7adbcb683b Bug 1253740 - Introduce extensionIdToCollectionId, r=bsilverberg,kmag
MozReview-Commit-ID: 5nDVtleknyN
2016-07-27 16:16:09 -04:00
Ethan Glasser-Camp
26a598a5d7 Bug 1253740 - Add code that syncs and tests, r=bsilverberg,kmag,markh
MozReview-Commit-ID: 8pm2jG92hCs
2016-09-08 14:16:09 -04:00
Ethan Glasser-Camp
fc29a79469 Bug 1253740 - Introduce extension-storage engine with a sanity test, r=markh
Note that this "enables" the engine using a pref, even though it might
not be ready yet, so that the tests can pass.

MozReview-Commit-ID: AZ0TVERiQDU
2016-09-08 14:23:12 -04:00
Michiel de Jong
e5151fda43 Bug 1253740 - Implement storage.sync, r=bsilverberg,kmag
MozReview-Commit-ID: 5v9nYBTgekj
2016-08-11 18:16:37 -04:00