9001-FSDG-sync-remote-settings-with-local-dump.patch 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045
  1. From 7d313f93cebc14b7eb6fc1654b60a143b5cd7f52 Mon Sep 17 00:00:00 2001
  2. From: grizzlyuser <grizzlyuser@protonmail.com>
  3. Date: Wed, 30 Dec 2020 17:20:39 +0200
  4. Subject: [PATCH 01/13] Point to local omni.ja files, not remote server
  5. This patch series tries to remove any network communication with Remote
  6. Settings [1], which can be used by Mozilla to silently push data to client
  7. browsers. This data can include references to nonfree software, for example,
  8. to search engines or other websites that contain nonfree JavaScript code.
  9. Without this patching, it would be hard to make sure the browser does not
  10. violate paragraph 4 of [2]: "Programs in the system should not suggest
  11. installing nonfree plugins, documentation, and so on."
  12. Changes in the current patch:
  13. First of all, replace every occurrence of Remote Settings server domain name
  14. with URIs that point to built-in local files within omni.ja.
  15. Some links to json files may point to non-existing files, but that's OK
  16. because it's better than leave them point to Remote Settings server.
  17. If necessary, missing files can be added later.
  18. [1] https://remote-settings.readthedocs.io/en/latest/introduction.html
  19. [2] https://www.gnu.org/distros/free-system-distribution-guidelines.en.html#license-rules
  20. ---
  21. .../components/ASRouterAdmin/ASRouterAdmin.jsx | 2 +-
  22. .../newtab/data/content/activity-stream.bundle.js | 2 +-
  23. services/settings/Utils.jsm | 2 +-
  24. .../periodic-updates/scripts/periodic_file_updates.sh | 2 +-
  25. .../backgroundtasks/BackgroundTask_message.sys.mjs | 4 ++--
  26. toolkit/components/search/SearchUtils.sys.mjs | 8 ++++----
  27. toolkit/components/search/docs/DefaultSearchEngines.rst | 2 +-
  28. .../components/search/docs/SearchEngineConfiguration.rst | 2 +-
  29. toolkit/modules/AppConstants.sys.mjs | 4 ++--
  30. toolkit/mozapps/defaultagent/RemoteSettings.cpp | 2 +-
  31. 10 files changed, 15 insertions(+), 15 deletions(-)
  32. diff --git a/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx b/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
  33. index 17155bb4ba..859560e25b 100644
  34. --- a/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
  35. +++ b/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
  36. @@ -1237,7 +1237,7 @@ export class ASRouterAdminInner extends React.PureComponent {
  37. <a
  38. className="providerUrl"
  39. target="_blank"
  40. - href="https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/nimbus-desktop-experiments/records"
  41. + href="resource://app/defaults/settings/main/nimbus-desktop-experiments.json"
  42. rel="noopener noreferrer"
  43. >
  44. nimbus-desktop-experiments
  45. diff --git a/browser/components/newtab/data/content/activity-stream.bundle.js b/browser/components/newtab/data/content/activity-stream.bundle.js
  46. index 159e948352..5cbe5ac2c2 100644
  47. --- a/browser/components/newtab/data/content/activity-stream.bundle.js
  48. +++ b/browser/components/newtab/data/content/activity-stream.bundle.js
  49. @@ -1593,7 +1593,7 @@ class ASRouterAdminInner extends (external_React_default()).PureComponent {
  50. label = /*#__PURE__*/external_React_default().createElement("span", null, "remote settings (", /*#__PURE__*/external_React_default().createElement("a", {
  51. className: "providerUrl",
  52. target: "_blank",
  53. - href: "https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/nimbus-desktop-experiments/records",
  54. + href: "resource://app/defaults/settings/main/nimbus-desktop-experiments.json",
  55. rel: "noopener noreferrer"
  56. }, "nimbus-desktop-experiments"), ")");
  57. }
  58. diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm
  59. index 50114dfbbc..9d957283da 100644
  60. --- a/services/settings/Utils.jsm
  61. +++ b/services/settings/Utils.jsm
  62. @@ -101,7 +101,7 @@ var Utils = {
  63. : AppConstants.REMOTE_SETTINGS_SERVER_URL;
  64. },
  65. - CHANGES_PATH: "/buckets/monitor/collections/changes/changeset",
  66. + CHANGES_PATH: "/monitor/changes",
  67. /**
  68. * Logger instance.
  69. diff --git a/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh b/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh
  70. index b88ee476da..440615e4e1 100755
  71. --- a/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh
  72. +++ b/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh
  73. @@ -286,7 +286,7 @@ function compare_suffix_lists {
  74. }
  75. function compare_remote_settings_files {
  76. - REMOTE_SETTINGS_SERVER="https://firefox.settings.services.mozilla.com/v1"
  77. + REMOTE_SETTINGS_SERVER="resource://app/defaults/settings"
  78. # 1. List remote settings collections from server.
  79. echo "INFO: fetch remote settings list from server"
  80. diff --git a/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs b/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs
  81. index dbbfa53d39..11b93b07f2 100644
  82. --- a/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs
  83. +++ b/toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs
  84. @@ -19,8 +19,8 @@
  85. // environment variables still apply.
  86. //
  87. // --stage: use stage Remote Settings
  88. -// (`https://settings-cdn.stage.mozaws.net/v1`) rather than production
  89. -// (`https://firefox.settings.services.mozilla.com/v1`)
  90. +// (`resource://app/defaults/settings/`) rather than production
  91. +// (`resource://app/defaults/settings/`)
  92. //
  93. // --preview: enable Remote Settings and Experiment previews.
  94. //
  95. diff --git a/toolkit/components/search/SearchUtils.sys.mjs b/toolkit/components/search/SearchUtils.sys.mjs
  96. index 65581754e8..4e7ccf48e4 100644
  97. --- a/toolkit/components/search/SearchUtils.sys.mjs
  98. +++ b/toolkit/components/search/SearchUtils.sys.mjs
  99. @@ -150,13 +150,13 @@ export var SearchUtils = {
  100. ENGINES_URLS: {
  101. "prod-main":
  102. - "https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/search-config/records",
  103. + "resource://app/defaults/settings/main/search-config.json",
  104. "prod-preview":
  105. - "https://firefox.settings.services.mozilla.com/v1/buckets/main-preview/collections/search-config/records",
  106. + "resource://app/defaults/settings/main/search-config.json",
  107. "stage-main":
  108. - "https://settings.stage.mozaws.net/v1/buckets/main/collections/search-config/records",
  109. + "resource://app/defaults/settings/main/search-config.json",
  110. "stage-preview":
  111. - "https://settings.stage.mozaws.net/v1/buckets/main-preview/collections/search-config/records",
  112. + "resource://app/defaults/settings/main/search-config.json",
  113. },
  114. // The following constants are left undocumented in nsISearchService.idl
  115. diff --git a/toolkit/components/search/docs/DefaultSearchEngines.rst b/toolkit/components/search/docs/DefaultSearchEngines.rst
  116. index 3dfe68abb1..26d5f18a7b 100644
  117. --- a/toolkit/components/search/docs/DefaultSearchEngines.rst
  118. +++ b/toolkit/components/search/docs/DefaultSearchEngines.rst
  119. @@ -99,4 +99,4 @@ is updated.
  120. .. _configuration schema: SearchConfigurationSchema.html
  121. .. _remote settings: /services/settings/index.html
  122. -.. _search-default-override-allowlist bucket: https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/search-default-override-allowlist/records
  123. +.. _search-default-override-allowlist bucket: resource://app/defaults/settings/main/search-default-override-allowlist.json
  124. diff --git a/toolkit/components/search/docs/SearchEngineConfiguration.rst b/toolkit/components/search/docs/SearchEngineConfiguration.rst
  125. index c782f9f7c3..4d773d27c5 100644
  126. --- a/toolkit/components/search/docs/SearchEngineConfiguration.rst
  127. +++ b/toolkit/components/search/docs/SearchEngineConfiguration.rst
  128. @@ -68,5 +68,5 @@ related. As a result several situations may occur:
  129. .. _JSON schema: https://json-schema.org/
  130. .. _stored in mozilla-central: https://searchfox.org/mozilla-central/source/toolkit/components/search/schema/
  131. .. _Search Configuration Schema: SearchConfigurationSchema.html
  132. -.. _viewed live: https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/search-config/records
  133. +.. _viewed live: resource://app/defaults/settings/main/search-config.json
  134. .. _Normandy: /toolkit/components/normandy/normandy/services.html
  135. diff --git a/toolkit/modules/AppConstants.sys.mjs b/toolkit/modules/AppConstants.sys.mjs
  136. index 59ba540c6d..2b9ff5796b 100644
  137. --- a/toolkit/modules/AppConstants.sys.mjs
  138. +++ b/toolkit/modules/AppConstants.sys.mjs
  139. @@ -416,9 +416,9 @@ export var AppConstants = Object.freeze({
  140. REMOTE_SETTINGS_SERVER_URL:
  141. #ifdef MOZ_THUNDERBIRD
  142. - "https://thunderbird-settings.thunderbird.net/v1",
  143. + "resource://app/defaults/settings",
  144. #else
  145. - "https://firefox.settings.services.mozilla.com/v1",
  146. + "resource://app/defaults/settings",
  147. #endif
  148. REMOTE_SETTINGS_VERIFY_SIGNATURE:
  149. diff --git a/toolkit/mozapps/defaultagent/RemoteSettings.cpp b/toolkit/mozapps/defaultagent/RemoteSettings.cpp
  150. index 667d9fc628..b2bf628f29 100644
  151. --- a/toolkit/mozapps/defaultagent/RemoteSettings.cpp
  152. +++ b/toolkit/mozapps/defaultagent/RemoteSettings.cpp
  153. @@ -23,7 +23,7 @@ extern "C" {
  154. HRESULT IsAgentRemoteDisabledRust(const char* szUrl, DWORD* lpdwDisabled);
  155. }
  156. -#define PROD_ENDPOINT "https://firefox.settings.services.mozilla.com/v1"
  157. +#define PROD_ENDPOINT "resource://app/defaults/settings"
  158. #define PROD_BID "main"
  159. #define PROD_CID "windows-default-browser-agent"
  160. #define PROD_ID "state"
  161. --
  162. 2.39.0
  163. From 233227d0f2da317fe71a643b1c54d623f56f5d84 Mon Sep 17 00:00:00 2001
  164. From: grizzlyuser <grizzlyuser@protonmail.com>
  165. Date: Wed, 30 Dec 2020 17:34:08 +0200
  166. Subject: [PATCH 02/13] Remove polling triggered by push broadcasts
  167. When initialized, remote-settings.js adds a listener to push broadcasts,
  168. that let Remote Settings server send push messages to trigger polling
  169. for changes from the client side. This is not needed for local-only
  170. setup. Remove the record from broadcast-listeners.json file stored in
  171. the user profile, so that it doesn't get picked up by push broadcast
  172. service.
  173. ---
  174. dom/push/PushBroadcastService.sys.mjs | 13 +++++++++++++
  175. services/settings/remote-settings.js | 11 ++---------
  176. 2 files changed, 15 insertions(+), 9 deletions(-)
  177. diff --git a/dom/push/PushBroadcastService.sys.mjs b/dom/push/PushBroadcastService.sys.mjs
  178. index cca80fee6c..c83b0f77d7 100644
  179. --- a/dom/push/PushBroadcastService.sys.mjs
  180. +++ b/dom/push/PushBroadcastService.sys.mjs
  181. @@ -170,6 +170,19 @@ export var BroadcastService = class {
  182. }
  183. }
  184. + async deleteListener(broadcastId) {
  185. + await this.initializePromise;
  186. +
  187. + if (this.jsonFile.data.listeners.hasOwnProperty(broadcastId)) {
  188. + console.info(
  189. + "deleteListener: deleting listener",
  190. + broadcastId
  191. + );
  192. + delete this.jsonFile.data.listeners[broadcastId];
  193. + this.jsonFile.saveSoon();
  194. + }
  195. + }
  196. +
  197. /**
  198. * Call the listeners of the specified broadcasts.
  199. *
  200. diff --git a/services/settings/remote-settings.js b/services/settings/remote-settings.js
  201. index c479de2a17..f797df533a 100644
  202. --- a/services/settings/remote-settings.js
  203. +++ b/services/settings/remote-settings.js
  204. @@ -582,11 +582,7 @@ function remoteSettingsFunction() {
  205. moduleURI: __URI__,
  206. symbolName: "remoteSettingsBroadcastHandler",
  207. };
  208. - lazy.pushBroadcastService.addListener(
  209. - BROADCAST_ID,
  210. - currentVersion,
  211. - moduleInfo
  212. - );
  213. + lazy.pushBroadcastService.deleteListener(BROADCAST_ID);
  214. };
  215. return remoteSettings;
  216. @@ -606,9 +602,6 @@ var remoteSettingsBroadcastHandler = {
  217. `Push notification received (version=${version} phase=${phase})`
  218. );
  219. - return RemoteSettings.pollChanges({
  220. - expectedTimestamp: version,
  221. - trigger: isStartup ? "startup" : "broadcast",
  222. - });
  223. + return;
  224. },
  225. };
  226. --
  227. 2.39.0
  228. From c4bd08fa8614bcf212975f4c0b3555437e8a8d59 Mon Sep 17 00:00:00 2001
  229. From: grizzlyuser <grizzlyuser@protonmail.com>
  230. Date: Wed, 30 Dec 2020 17:41:54 +0200
  231. Subject: [PATCH 03/13] Remove timer that triggers polling for changes
  232. That is not needed for local-only setup.
  233. ---
  234. services/settings/components.conf | 9 +--------
  235. services/settings/servicesSettings.manifest | 4 ----
  236. 2 files changed, 1 insertion(+), 12 deletions(-)
  237. diff --git a/services/settings/components.conf b/services/settings/components.conf
  238. index 9a737802ee..25109415a7 100644
  239. --- a/services/settings/components.conf
  240. +++ b/services/settings/components.conf
  241. @@ -4,11 +4,4 @@
  242. # License, v. 2.0. If a copy of the MPL was not distributed with this
  243. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  244. -Classes = [
  245. - {
  246. - 'cid': '{5e756573-234a-49ea-bbe4-59ec7a70657d}',
  247. - 'contract_ids': ['@mozilla.org/services/settings;1'],
  248. - 'jsm': 'resource://services-settings/RemoteSettingsComponents.jsm',
  249. - 'constructor': 'RemoteSettingsTimer',
  250. - },
  251. -]
  252. +Classes = []
  253. diff --git a/services/settings/servicesSettings.manifest b/services/settings/servicesSettings.manifest
  254. index 3bfed26ea4..807eb220ec 100644
  255. --- a/services/settings/servicesSettings.manifest
  256. +++ b/services/settings/servicesSettings.manifest
  257. @@ -1,7 +1,3 @@
  258. # Register resource aliases
  259. resource services-settings resource://gre/modules/services-settings/
  260. -# Schedule polling of remote settings changes
  261. -# (default 24H, max 72H)
  262. -# see syntax https://searchfox.org/mozilla-central/rev/cc280c4be94ff8cf64a27cc9b3d6831ffa49fa45/toolkit/components/timermanager/UpdateTimerManager.jsm#155
  263. -category update-timer RemoteSettingsComponents @mozilla.org/services/settings;1,getService,services-settings-poll-changes,services.settings.poll_interval,86400,259200
  264. --
  265. 2.39.0
  266. From b106c8b4e919e1d6c42f66bb07461c63848ebb2b Mon Sep 17 00:00:00 2001
  267. From: grizzlyuser <grizzlyuser@protonmail.com>
  268. Date: Wed, 30 Dec 2020 17:47:41 +0200
  269. Subject: [PATCH 04/13] Utils: fetch timestamps of each collection locally
  270. Utils.CHANGES_PATH points to
  271. services/settings/dumps/monitor/changes
  272. which will be generated later by JSON processing script. Fetch the
  273. timestamps from that file and mock response headers to not confuse any
  274. code that expects them.
  275. ---
  276. browser/installer/package-manifest.in | 1 +
  277. services/settings/Utils.jsm | 28 ++++++++++++++++++++---
  278. services/settings/dumps/monitor/moz.build | 8 +++++++
  279. services/settings/dumps/moz.build | 1 +
  280. 4 files changed, 35 insertions(+), 3 deletions(-)
  281. create mode 100644 services/settings/dumps/monitor/moz.build
  282. diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
  283. index 9229a0bd0e..565a7b7508 100644
  284. --- a/browser/installer/package-manifest.in
  285. +++ b/browser/installer/package-manifest.in
  286. @@ -263,6 +263,7 @@
  287. @RESPATH@/browser/defaults/settings/last_modified.json
  288. @RESPATH@/browser/defaults/settings/blocklists
  289. @RESPATH@/browser/defaults/settings/main
  290. +@RESPATH@/browser/defaults/settings/monitor
  291. @RESPATH@/browser/defaults/settings/security-state
  292. ; Warning: changing the path to channel-prefs.js can cause bugs (Bug 756325)
  293. diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm
  294. index 9d957283da..abdd0a53fa 100644
  295. --- a/services/settings/Utils.jsm
  296. +++ b/services/settings/Utils.jsm
  297. @@ -370,7 +370,7 @@ var Utils = {
  298. async fetchLatestChanges(serverUrl, options = {}) {
  299. const { expectedTimestamp, lastEtag = "", filters = {} } = options;
  300. - let url = serverUrl + Utils.CHANGES_PATH;
  301. + let url = Utils.SERVER_URL + Utils.CHANGES_PATH;
  302. const params = {
  303. ...filters,
  304. _expected: expectedTimestamp ?? 0,
  305. @@ -385,7 +385,21 @@ var Utils = {
  306. .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)
  307. .join("&");
  308. }
  309. - const response = await Utils.fetch(url);
  310. + const rawResponse = await fetch(url);
  311. + const responseDate = new Date().toUTCString();
  312. +
  313. + const headers = new Headers();
  314. + headers.set("Date", responseDate);
  315. + headers.set("Last-Modified", responseDate);
  316. + headers.set("Content-Type", "application/json");
  317. +
  318. + const responseAttributes = {
  319. + status: rawResponse.status,
  320. + statusText: rawResponse.statusText,
  321. + headers,
  322. + };
  323. +
  324. + const response = new Response(rawResponse.body, responseAttributes);
  325. if (response.status >= 500) {
  326. throw new Error(`Server error ${response.status} ${response.statusText}`);
  327. @@ -420,7 +434,15 @@ var Utils = {
  328. }
  329. }
  330. - const { changes = [], timestamp } = payload;
  331. + const { timestamp } = payload;
  332. + const { bucket, collection } = filters;
  333. + if (!bucket || !collection) {
  334. + throw new Error('Unable to fetch latest change without bucket or collection');
  335. + }
  336. + const change = payload.changes.find(
  337. + change => change.bucket === bucket && change.collection === collection
  338. + ) ?? { last_modified: 0, bucket, collection };
  339. + const changes = [change];
  340. let serverTimeMillis = Date.parse(response.headers.get("Date"));
  341. // Since the response is served via a CDN, the Date header value could have been cached.
  342. diff --git a/services/settings/dumps/monitor/moz.build b/services/settings/dumps/monitor/moz.build
  343. new file mode 100644
  344. index 0000000000..d3d017fda5
  345. --- /dev/null
  346. +++ b/services/settings/dumps/monitor/moz.build
  347. @@ -0,0 +1,8 @@
  348. +# This Source Code Form is subject to the terms of the Mozilla Public
  349. +# License, v. 2.0. If a copy of the MPL was not distributed with this
  350. +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
  351. +
  352. +FINAL_TARGET_FILES.defaults.settings.monitor += ["changes"]
  353. +
  354. +if CONFIG["MOZ_BUILD_APP"] == "browser":
  355. + DIST_SUBDIR = "browser"
  356. diff --git a/services/settings/dumps/moz.build b/services/settings/dumps/moz.build
  357. index f407580bfa..53e9d8b45e 100644
  358. --- a/services/settings/dumps/moz.build
  359. +++ b/services/settings/dumps/moz.build
  360. @@ -5,6 +5,7 @@
  361. DIRS += [
  362. "blocklists",
  363. "main",
  364. + "monitor",
  365. "security-state",
  366. ]
  367. --
  368. 2.39.0
  369. From bd6216d755e4d1c1c8ebba4123732b0b2358101c Mon Sep 17 00:00:00 2001
  370. From: grizzlyuser <grizzlyuser@protonmail.com>
  371. Date: Wed, 30 Dec 2020 17:52:10 +0200
  372. Subject: [PATCH 05/13] Utils: disable offline checking
  373. Since only local data is read now, it should always return false for the
  374. current and any future code that relies on it.
  375. ---
  376. services/settings/Utils.jsm | 10 ----------
  377. 1 file changed, 10 deletions(-)
  378. diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm
  379. index abdd0a53fa..2cc3ba917b 100644
  380. --- a/services/settings/Utils.jsm
  381. +++ b/services/settings/Utils.jsm
  382. @@ -184,16 +184,6 @@ var Utils = {
  383. * @return {bool} Whether network is down or not.
  384. */
  385. get isOffline() {
  386. - try {
  387. - return (
  388. - Services.io.offline ||
  389. - lazy.CaptivePortalService.state ==
  390. - lazy.CaptivePortalService.LOCKED_PORTAL ||
  391. - !lazy.gNetworkLinkService.isLinkUp
  392. - );
  393. - } catch (ex) {
  394. - log.warn("Could not determine network status.", ex);
  395. - }
  396. return false;
  397. },
  398. --
  399. 2.39.0
  400. From 237ecd7acdd299b2f89787e4f5f50bb5cc4d970c Mon Sep 17 00:00:00 2001
  401. From: grizzlyuser <grizzlyuser@protonmail.com>
  402. Date: Wed, 30 Dec 2020 17:56:02 +0200
  403. Subject: [PATCH 06/13] Refactor hashing logic to a separate function
  404. It is used instead of internal signature validation mechanism, for
  405. integrity checking of the locally cached data.
  406. ---
  407. services/settings/RemoteSettingsWorker.jsm | 4 ++++
  408. services/settings/SharedUtils.jsm | 9 +++++++--
  409. 2 files changed, 11 insertions(+), 2 deletions(-)
  410. diff --git a/services/settings/RemoteSettingsWorker.jsm b/services/settings/RemoteSettingsWorker.jsm
  411. index 57754f0a2b..0ae0c8762a 100644
  412. --- a/services/settings/RemoteSettingsWorker.jsm
  413. +++ b/services/settings/RemoteSettingsWorker.jsm
  414. @@ -191,6 +191,10 @@ class Worker {
  415. // task on the current thread instead of the worker thread.
  416. return lazy.SharedUtils.checkContentHash(buffer, size, hash);
  417. }
  418. +
  419. + async getContentHash(bytes) {
  420. + return lazy.SharedUtils.getContentHash(bytes);
  421. + }
  422. }
  423. // Now, first add a shutdown blocker. If that fails, we must have
  424. diff --git a/services/settings/SharedUtils.jsm b/services/settings/SharedUtils.jsm
  425. index 9804e80c91..de67b0fb6f 100644
  426. --- a/services/settings/SharedUtils.jsm
  427. +++ b/services/settings/SharedUtils.jsm
  428. @@ -23,11 +23,16 @@ var SharedUtils = {
  429. return false;
  430. }
  431. // Has expected content?
  432. + const hashStr = await this.getContentHash(bytes);
  433. + return hashStr == hash;
  434. + },
  435. +
  436. + async getContentHash(bytes) {
  437. const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
  438. const hashBytes = new Uint8Array(hashBuffer);
  439. const toHex = b => b.toString(16).padStart(2, "0");
  440. - const hashStr = Array.from(hashBytes, toHex).join("");
  441. - return hashStr == hash;
  442. +
  443. + return Array.from(hashBytes, toHex).join("");
  444. },
  445. /**
  446. --
  447. 2.39.0
  448. From afc7c3a747931dbd1ed02b5bc2af2fd29b607875 Mon Sep 17 00:00:00 2001
  449. From: grizzlyuser <grizzlyuser@protonmail.com>
  450. Date: Wed, 30 Dec 2020 18:05:02 +0200
  451. Subject: [PATCH 07/13] Client: Fetch and hash records from local dump
  452. Read the records from local dumps. See [1] for details on how to prepare
  453. custom dumps). Records are cached in the local IndexedDB, and the client
  454. updates cached records each time there's a change. Also it verifies
  455. integrity of the data. Then the list of current / created / updated /
  456. deleted records is generated and emitted to every registered listener.
  457. Change upstream signature validation mechanism to a simpler one.
  458. Otherwise, it'd be necessary to sign local records, which is redundant,
  459. because the application package should be signed already by the distro.
  460. Instead of signature property from metadata records, json_dump_metadata
  461. has been introduced. It contains the checksum of the records and size in
  462. bytes. Also added app_build_id property for version checking and updates
  463. of cached data.
  464. Although it's possible to disable integrity checking via preference, it
  465. seems to be not a good idea, because the logic that detects invalid
  466. local data relies on it. In the context of local-only setup, data that
  467. has been received from real Remote Settings server will not contain the
  468. custom metadata, and thus will be considered invalid and then discarded,
  469. while the client gets a chance to gracefully inform registered listeners
  470. about these changes so that they can discard the data received before
  471. the upgrade to local-only setup.
  472. [1] https://firefox-source-docs.mozilla.org/services/common/services/RemoteSettings.html#initial-data
  473. ---
  474. services/settings/RemoteSettingsClient.jsm | 66 +++++++++-------------
  475. 1 file changed, 28 insertions(+), 38 deletions(-)
  476. diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
  477. index 1d42fc98ff..c8a0898367 100644
  478. --- a/services/settings/RemoteSettingsClient.jsm
  479. +++ b/services/settings/RemoteSettingsClient.jsm
  480. @@ -692,11 +692,9 @@ class RemoteSettingsClient extends EventEmitter {
  481. // If the data is up-to-date but don't have metadata (records loaded from dump),
  482. // we fetch them and validate the signature immediately.
  483. - if (this.verifySignature && lazy.ObjectUtils.isEmpty(localMetadata)) {
  484. + if (this.verifySignature && lazy.ObjectUtils.isEmpty(localMetadata?.json_dump_metadata)) {
  485. lazy.console.debug(`${this.identifier} pull collection metadata`);
  486. - const metadata = await this.httpClient().getData({
  487. - query: { _expected: expectedTimestamp },
  488. - });
  489. + const { metadata } = await this._fetchChangeset(expectedTimestamp);
  490. await this.db.importChanges(metadata);
  491. // We don't bother validating the signature if the dump was just loaded. We do
  492. // if the dump was loaded at some other point (eg. from .get()).
  493. @@ -959,38 +957,28 @@ class RemoteSettingsClient extends EventEmitter {
  494. * @returns {Promise}
  495. */
  496. async _validateCollectionSignature(records, timestamp, metadata) {
  497. - if (!metadata?.signature) {
  498. + if (!metadata?.json_dump_metadata) {
  499. throw new MissingSignatureError(this.identifier);
  500. }
  501. - if (!this._verifier) {
  502. - this._verifier = Cc[
  503. - "@mozilla.org/security/contentsignatureverifier;1"
  504. - ].createInstance(Ci.nsIContentSignatureVerifier);
  505. - }
  506. -
  507. - // This is a content-signature field from an autograph response.
  508. const {
  509. - signature: { x5u, signature },
  510. + json_dump_metadata: { hash, size },
  511. } = metadata;
  512. - const certChain = await (await lazy.Utils.fetch(x5u)).text();
  513. // Merge remote records with local ones and serialize as canonical JSON.
  514. const serialized = await lazy.RemoteSettingsWorker.canonicalStringify(
  515. records,
  516. timestamp
  517. );
  518. - lazy.console.debug(`${this.identifier} verify signature using ${x5u}`);
  519. + lazy.console.debug(`${this.identifier} verify signature using size ${size} and hash ${hash}`);
  520. if (
  521. - !(await this._verifier.asyncVerifyContentSignature(
  522. - serialized,
  523. - "p384ecdsa=" + signature,
  524. - certChain,
  525. - this.signerName,
  526. - lazy.Utils.CERT_CHAIN_ROOT_IDENTIFIER
  527. + !(await lazy.RemoteSettingsWorker.checkContentHash(
  528. + new TextEncoder().encode(serialized),
  529. + size,
  530. + hash
  531. ))
  532. ) {
  533. - throw new InvalidSignatureError(this.identifier, x5u);
  534. + throw new InvalidSignatureError(this.identifier);
  535. }
  536. }
  537. @@ -1160,24 +1148,26 @@ class RemoteSettingsClient extends EventEmitter {
  538. * @param since timestamp of last sync (optional)
  539. */
  540. async _fetchChangeset(expectedTimestamp, since) {
  541. - const client = this.httpClient();
  542. - const {
  543. - metadata,
  544. - timestamp: remoteTimestamp,
  545. - changes: remoteRecords,
  546. - } = await client.execute(
  547. - {
  548. - path: `/buckets/${this.bucketName}/collections/${this.collectionName}/changeset`,
  549. - },
  550. - {
  551. - query: {
  552. - _expected: expectedTimestamp,
  553. - _since: since,
  554. - },
  555. - }
  556. + const { data } = await lazy.SharedUtils.loadJSONDump(
  557. + this.bucketName,
  558. + this.collectionName
  559. );
  560. + const remoteRecords = data ?? [];
  561. +
  562. + const serialized = await lazy.RemoteSettingsWorker.canonicalStringify(
  563. + remoteRecords,
  564. + expectedTimestamp
  565. + );
  566. + const bytes = new TextEncoder().encode(serialized);
  567. + const metadata = {
  568. + app_build_id: Services.appinfo.appBuildID,
  569. + json_dump_metadata: {
  570. + hash: await lazy.RemoteSettingsWorker.getContentHash(bytes),
  571. + size: bytes.length,
  572. + },
  573. + }
  574. return {
  575. - remoteTimestamp,
  576. + remoteTimestamp: expectedTimestamp,
  577. metadata,
  578. remoteRecords,
  579. };
  580. --
  581. 2.39.0
  582. From 3f0d975225fb9d786eb8b4ae303f49f96f8d91e1 Mon Sep 17 00:00:00 2001
  583. From: grizzlyuser <grizzlyuser@protonmail.com>
  584. Date: Wed, 30 Dec 2020 18:42:56 +0200
  585. Subject: [PATCH 08/13] Client: start deferred sync on get() or on()
  586. The users of the RemoteSettingsClient.jsm can receive records from it in
  587. two ways: by calling get(), and by subscribing to events by calling
  588. on().
  589. So hook a deferred sync whenever something calls these methods. Because
  590. multiple of those calls can be made quite early and in very short time,
  591. set up a deferred task that will be armed only when needed and only once
  592. in a second. When the task is running it first checks if the local data
  593. came from the dump of the current app build, and no-ops if true. If
  594. false, it triggers a sync. Then adds a flag if the client has been
  595. correctly synchronized with the dump, so that no metadata checking
  596. occurs during the session.
  597. ---
  598. services/settings/RemoteSettingsClient.jsm | 27 +++++++++++++++++++++-
  599. 1 file changed, 26 insertions(+), 1 deletion(-)
  600. diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
  601. index c8a0898367..4b35ad0eef 100644
  602. --- a/services/settings/RemoteSettingsClient.jsm
  603. +++ b/services/settings/RemoteSettingsClient.jsm
  604. @@ -22,6 +22,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
  605. ClientEnvironmentBase:
  606. "resource://gre/modules/components-utils/ClientEnvironment.jsm",
  607. Database: "resource://services-settings/Database.jsm",
  608. + DeferredTask: "resource://gre/modules/DeferredTask.jsm",
  609. IDBHelpers: "resource://services-settings/IDBHelpers.jsm",
  610. KintoHttpClient: "resource://services-common/kinto-http-client.js",
  611. ObjectUtils: "resource://gre/modules/ObjectUtils.jsm",
  612. @@ -32,6 +33,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
  613. });
  614. const TELEMETRY_COMPONENT = "remotesettings";
  615. +const DEFERRED_SYNC_DELAY_MILLISECONDS = 1000;
  616. XPCOMUtils.defineLazyGetter(lazy, "console", () => lazy.Utils.log);
  617. @@ -324,6 +326,11 @@ class RemoteSettingsClient extends EventEmitter {
  618. this._lastCheckTimePref = lastCheckTimePref;
  619. this._verifier = null;
  620. this._syncRunning = false;
  621. + this._deferredSync = new lazy.DeferredTask(async () => {
  622. + if (!this._syncRunning && !(await this._isSynced())) {
  623. + await this.sync();
  624. + }
  625. + }, DEFERRED_SYNC_DELAY_MILLISECONDS);
  626. // This attribute allows signature verification to be disabled, when running tests
  627. // or when pulling data from a dev server.
  628. @@ -353,6 +360,11 @@ class RemoteSettingsClient extends EventEmitter {
  629. this.db.identifier = this.identifier;
  630. }
  631. + on(event, callback) {
  632. + super.on(event, callback);
  633. + this._deferredSync.arm();
  634. + }
  635. +
  636. get identifier() {
  637. return `${this.bucketName}/${this.collectionName}`;
  638. }
  639. @@ -426,6 +438,10 @@ class RemoteSettingsClient extends EventEmitter {
  640. let lastModified = forceSync ? null : await this.db.getLastModified();
  641. let hasLocalData = lastModified !== null;
  642. + if (!(await this._isSynced())) {
  643. + throw new MissingSignatureError(this.identifier);
  644. + }
  645. +
  646. if (forceSync) {
  647. if (!this._importingPromise) {
  648. this._importingPromise = (async () => {
  649. @@ -541,7 +557,10 @@ class RemoteSettingsClient extends EventEmitter {
  650. // No need to verify signature on JSON dumps.
  651. // If local DB cannot be read, then we don't even try to do anything,
  652. // we return results early.
  653. - return this._filterEntries(data);
  654. + const filtered = this._filterEntries(data);
  655. + this._deferredSync.arm();
  656. +
  657. + return filtered;
  658. }
  659. lazy.console.debug(
  660. @@ -581,6 +600,12 @@ class RemoteSettingsClient extends EventEmitter {
  661. return final;
  662. }
  663. + async _isSynced() {
  664. + this._synced ||=
  665. + Services.appinfo.appBuildID === (await this.db?.getMetadata())?.app_build_id;
  666. + return this._synced;
  667. + }
  668. +
  669. /**
  670. * Synchronize the local database with the remote server.
  671. *
  672. --
  673. 2.39.0
  674. From 137f0c81f37356fb97e7037ee64c2fa65ed242ea Mon Sep 17 00:00:00 2001
  675. From: grizzlyuser <grizzlyuser@protonmail.com>
  676. Date: Wed, 30 Dec 2020 18:53:51 +0200
  677. Subject: [PATCH 09/13] Client: deep compare records if timestamps match
  678. When the list of current / updated / deleted records is generated, their
  679. modification timestamps are compared to detect the updates.
  680. Although in practice this is unlikely to happen, in theory the
  681. timestamp of some older record received from Remote Settings can match
  682. with the modified record in the dump. Although JSON processing script
  683. makes sure to add unique timestamps to each of the modified records,
  684. it's still possible to update dumps manually and simply forget to update
  685. timestamps. So serialize the records and compare them as strings to be
  686. on the safe side. This should happen only once after upgrading to each
  687. new version of the application, so is not likely to introduce any
  688. noticeable performance issues.
  689. ---
  690. services/settings/RemoteSettingsClient.jsm | 6 +++++-
  691. 1 file changed, 5 insertions(+), 1 deletion(-)
  692. diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
  693. index 4b35ad0eef..a8ce913d8e 100644
  694. --- a/services/settings/RemoteSettingsClient.jsm
  695. +++ b/services/settings/RemoteSettingsClient.jsm
  696. @@ -19,6 +19,7 @@ const { Downloader } = ChromeUtils.import(
  697. const lazy = {};
  698. XPCOMUtils.defineLazyModuleGetters(lazy, {
  699. + CanonicalJSON: "resource://gre/modules/CanonicalJSON.jsm",
  700. ClientEnvironmentBase:
  701. "resource://gre/modules/components-utils/ClientEnvironment.jsm",
  702. Database: "resource://services-settings/Database.jsm",
  703. @@ -1148,7 +1149,10 @@ class RemoteSettingsClient extends EventEmitter {
  704. const old = oldById.get(r.id);
  705. if (old) {
  706. oldById.delete(r.id);
  707. - if (r.last_modified != old.last_modified) {
  708. + if (
  709. + r.last_modified != old.last_modified ||
  710. + lazy.CanonicalJSON.stringify(r) != lazy.CanonicalJSON.stringify(old)
  711. + ) {
  712. syncResult.updated.push({ old, new: r });
  713. }
  714. } else {
  715. --
  716. 2.39.0
  717. From 3e1e4c19780fd84fd0fdeaaa222239b4572fb251 Mon Sep 17 00:00:00 2001
  718. From: grizzlyuser <grizzlyuser@protonmail.com>
  719. Date: Wed, 30 Dec 2020 19:01:39 +0200
  720. Subject: [PATCH 10/13] Client: delete more data on cleanup
  721. When the client detects the local data is invalid (i.e. it came from
  722. real Remote Settings and can have unwanted records), delete not only
  723. the records, but also the attachments that came with them, because they
  724. too can be problematic. And last check time preference, because it's not
  725. useful anyway when remote-settings.js doesn't do any polling for changes.
  726. Note that attachments should be deleted before the records, because the
  727. logic gets the data about the attachments from those records.
  728. ---
  729. services/settings/RemoteSettingsClient.jsm | 12 +++++++++---
  730. 1 file changed, 9 insertions(+), 3 deletions(-)
  731. diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
  732. index a8ce913d8e..19883607f2 100644
  733. --- a/services/settings/RemoteSettingsClient.jsm
  734. +++ b/services/settings/RemoteSettingsClient.jsm
  735. @@ -261,7 +261,7 @@ class AttachmentDownloader extends Downloader {
  736. allRecords
  737. .filter(r => !!r.attachment)
  738. .map(r =>
  739. - Promise.all([this.deleteDownloaded(r), this.deleteFromDisk(r)])
  740. + Promise.all([this.deleteDownloaded(r), this.deleteFromDisk(r), this.deleteCached(r.id)])
  741. )
  742. );
  743. }
  744. @@ -1108,7 +1108,7 @@ class RemoteSettingsClient extends EventEmitter {
  745. // Signature failed, clear local DB because it contains
  746. // bad data (local + remote changes).
  747. lazy.console.debug(`${this.identifier} clear local data`);
  748. - await this.db.clear();
  749. + await this._clearAll();
  750. // Local data was tampered, throw and it will retry from empty DB.
  751. lazy.console.error(`${this.identifier} local data was corrupted`);
  752. throw new CorruptedDataError(this.identifier);
  753. @@ -1130,7 +1130,7 @@ class RemoteSettingsClient extends EventEmitter {
  754. // _importJSONDump() only clears DB if dump is available,
  755. // therefore do it here!
  756. if (imported < 0) {
  757. - await this.db.clear();
  758. + await this._clearAll();
  759. }
  760. }
  761. }
  762. @@ -1170,6 +1170,12 @@ class RemoteSettingsClient extends EventEmitter {
  763. return syncResult;
  764. }
  765. + async _clearAll() {
  766. + await this.attachments.deleteAll();
  767. + await this.db.clear();
  768. + Services.prefs.clearUserPref(this.lastCheckTimePref);
  769. + }
  770. +
  771. /**
  772. * Fetch information from changeset endpoint.
  773. *
  774. --
  775. 2.39.0
  776. From 8da7335ac9baa4f524293ec810af7b360009ec19 Mon Sep 17 00:00:00 2001
  777. From: grizzlyuser <grizzlyuser@protonmail.com>
  778. Date: Wed, 30 Dec 2020 19:07:56 +0200
  779. Subject: [PATCH 11/13] Client: remove comparison of collection timestamps
  780. In case if the cached data that came from real Remote Settings server
  781. (before the upgrade to local-only setup) has collection timestamp, that
  782. is newer than the packaged local dump, then this comparison logic can
  783. lead to early return of old data, skipping the integrity checking and
  784. necessary cleanup. So remove the checks.
  785. ---
  786. services/settings/RemoteSettingsClient.jsm | 5 -----
  787. 1 file changed, 5 deletions(-)
  788. diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
  789. index 19883607f2..8b4420943f 100644
  790. --- a/services/settings/RemoteSettingsClient.jsm
  791. +++ b/services/settings/RemoteSettingsClient.jsm
  792. @@ -1050,14 +1050,9 @@ class RemoteSettingsClient extends EventEmitter {
  793. updated: [],
  794. deleted: [],
  795. };
  796. - // If data wasn't changed, return empty sync result.
  797. - // This can happen when we update the signature but not the data.
  798. lazy.console.debug(
  799. `${this.identifier} local timestamp: ${localTimestamp}, remote: ${remoteTimestamp}`
  800. );
  801. - if (localTimestamp && remoteTimestamp < localTimestamp) {
  802. - return syncResult;
  803. - }
  804. await this.db.importChanges(metadata, remoteTimestamp, remoteRecords, {
  805. clear: retry,
  806. --
  807. 2.39.0
  808. From 5b40750eb05b0eb230ec44f0f5640ecc8d5e3b47 Mon Sep 17 00:00:00 2001
  809. From: grizzlyuser <grizzlyuser@protonmail.com>
  810. Date: Wed, 30 Dec 2020 19:15:44 +0200
  811. Subject: [PATCH 12/13] Attachments: load only from dump and drop cached
  812. ---
  813. services/settings/Attachments.jsm | 37 +++++++------------------------
  814. 1 file changed, 8 insertions(+), 29 deletions(-)
  815. diff --git a/services/settings/Attachments.jsm b/services/settings/Attachments.jsm
  816. index 67a1f32261..6ff0a3b7c6 100644
  817. --- a/services/settings/Attachments.jsm
  818. +++ b/services/settings/Attachments.jsm
  819. @@ -151,9 +151,10 @@ class Downloader {
  820. retries,
  821. checkHash,
  822. attachmentId = record?.id,
  823. - fallbackToCache = false,
  824. fallbackToDump = false,
  825. } = options || {};
  826. + const fallbackToCache = false;
  827. +
  828. if (!attachmentId) {
  829. // Check for pre-condition. This should not happen, but it is explicitly
  830. // checked to avoid mixing up attachments, which could be dangerous.
  831. @@ -204,6 +205,7 @@ class Downloader {
  832. const newBuffer = await this.downloadAsBytes(record, {
  833. retries,
  834. checkHash,
  835. + dumpInfo,
  836. });
  837. const blob = new Blob([newBuffer]);
  838. // Store in cache but don't wait for it before returning.
  839. @@ -237,7 +239,7 @@ class Downloader {
  840. }
  841. try {
  842. - return { ...(await cacheInfo.getResult()), _source: "cache_fallback" };
  843. + await this.cacheImpl.delete(attachmentId);
  844. } catch (e) {
  845. // Failed to read from cache, e.g. IndexedDB unusable.
  846. console.error(e);
  847. @@ -300,7 +302,7 @@ class Downloader {
  848. * @returns {String} the absolute file path to the downloaded attachment.
  849. */
  850. async downloadToDisk(record, options = {}) {
  851. - const { retries = 3 } = options;
  852. + const retries = 0;
  853. const {
  854. attachment: { filename, size, hash },
  855. } = record;
  856. @@ -359,33 +361,10 @@ class Downloader {
  857. */
  858. async downloadAsBytes(record, options = {}) {
  859. const {
  860. - attachment: { location, hash, size },
  861. - } = record;
  862. -
  863. - const remoteFileUrl = (await this._baseAttachmentsURL()) + location;
  864. + dumpInfo = new LazyRecordAndBuffer(() => this._readAttachmentDump(attachmentId))
  865. + } = options;
  866. - const { retries = 3, checkHash = true } = options;
  867. - let retried = 0;
  868. - while (true) {
  869. - try {
  870. - const buffer = await this._fetchAttachment(remoteFileUrl);
  871. - if (!checkHash) {
  872. - return buffer;
  873. - }
  874. - if (
  875. - await lazy.RemoteSettingsWorker.checkContentHash(buffer, size, hash)
  876. - ) {
  877. - return buffer;
  878. - }
  879. - // Content is corrupted.
  880. - throw new Downloader.BadContentError(location);
  881. - } catch (e) {
  882. - if (retried >= retries) {
  883. - throw e;
  884. - }
  885. - }
  886. - retried++;
  887. - }
  888. + return (await dumpInfo.getResult()).buffer;
  889. }
  890. /**
  891. --
  892. 2.39.0
  893. From cac0e35f9b818570f37681ee7cd12071e8e5d747 Mon Sep 17 00:00:00 2001
  894. From: grizzlyuser <grizzlyuser@protonmail.com>
  895. Date: Wed, 30 Dec 2020 19:22:20 +0200
  896. Subject: [PATCH 13/13] Disable CRLite entirely for now
  897. It's designed to fetch the data from Remote Settings. One of the main
  898. selling points is that new revocations can be pushed to the clients
  899. within minutes. That won't work with local-only setup. Although (some?)
  900. of the JSON dumps for it are in place, obviously the updates won't
  901. happen that fast.
  902. Disable the preference right in the source code, so that the patch fails
  903. to apply when the upstream decides to set it to fully enforcing mode
  904. by default.
  905. The solution with CRLite is up for discussion. If necessary, it's
  906. possible to make clients for blessed collections to communicate to real
  907. Remote Settings server. For example, for collections related to
  908. certificate revocations.
  909. ---
  910. modules/libpref/init/StaticPrefList.yaml | 2 +-
  911. security/manager/ssl/nsNSSComponent.cpp | 1 +
  912. 2 files changed, 2 insertions(+), 1 deletion(-)
  913. diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
  914. index fca74af174..d05d118e58 100644
  915. --- a/modules/libpref/init/StaticPrefList.yaml
  916. +++ b/modules/libpref/init/StaticPrefList.yaml
  917. @@ -13250,7 +13250,7 @@
  918. # 3: Consult CRLite and enforce "Not Revoked" results, but defer to OCSP for "Revoked".
  919. - name: security.pki.crlite_mode
  920. type: RelaxedAtomicUint32
  921. - value: 3
  922. + value: 0
  923. mirror: always
  924. - name: security.tls.version.min
  925. diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp
  926. index 5844ffecfd..6084ffc93c 100644
  927. --- a/security/manager/ssl/nsNSSComponent.cpp
  928. +++ b/security/manager/ssl/nsNSSComponent.cpp
  929. @@ -1430,6 +1430,7 @@ void nsNSSComponent::setValidationOptions(
  930. CRLiteMode defaultCRLiteMode = CRLiteMode::Disabled;
  931. CRLiteMode crliteMode =
  932. static_cast<CRLiteMode>(StaticPrefs::security_pki_crlite_mode());
  933. + // Adding a comment just in case so that the patch breaks as soon as any surrounding lines get changed
  934. switch (crliteMode) {
  935. case CRLiteMode::Disabled:
  936. case CRLiteMode::TelemetryOnly:
  937. --
  938. 2.39.0