Commit Graph

110 Commits

Author SHA1 Message Date
Mark Banner
7ea3c792f2 Bug 1758474 - Implement an ESLint rule to disallow passing {} as the target parameter for ChromeUtils.import. r=Gijs,mossop,perftest-reviewers,preferences-reviewers,sparky
Differential Revision: https://phabricator.services.mozilla.com/D140517
2022-03-11 16:41:29 +00:00
smolnar
19781d16c7 Backed out changeset 5018856d8fee (bug 1758474) for causing node eslint failure. CLOSED TREE 2022-03-10 11:58:45 +02:00
Mark Banner
de1754318e Bug 1758474 - Implement an ESLint rule to disallow passing {} as the target parameter for ChromeUtils.import. r=Gijs,mossop,perftest-reviewers,preferences-reviewers,sparky
Differential Revision: https://phabricator.services.mozilla.com/D140517
2022-03-10 09:25:28 +00:00
Barret Rennie
e7af55cb78 Bug 1745356 - Remove osfile.jsm from browser/components/attribution r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D133840
2021-12-25 20:59:24 +00:00
Barret Rennie
64954f7ded Bug 1745356 - Remove osfile.jsm from Mac Attribution r=mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D133838
2021-12-25 20:59:24 +00:00
Evgenia Kotovich
fad1ce4207 Bug 1733535 - Replace OS.File with IOUtils in the attribution code. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D128715
2021-10-25 08:38:52 +00:00
Norisz Fay
85ec9d324c Backed out changeset d63aab4e0688 (bug 1733535) for causing mochitest failures on browser_AttributionCode_telemetry.js CLOSED TREE 2021-10-22 16:32:43 +03:00
Evgenia Kotovich
af2f958525 Bug 1733535 - Replace OS.File with IOUtils in the attribution code. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D128715
2021-10-22 11:57:44 +00:00
Mark Banner
1817e82737 Bug 1602940 - Automated replacements to use Services.uuid. r=Gijs,necko-reviewers,preferences-reviewers,kershaw
Depends on D124391

Differential Revision: https://phabricator.services.mozilla.com/D124392
2021-09-06 09:53:52 +00:00
Kirk Steuber
7718339187 Bug 1677497 - Add support for the attribution parameter: dltoken r=nalexander,Mardak
Differential Revision: https://phabricator.services.mozilla.com/D100969
2021-01-20 01:08:43 +00:00
Ricky Stewart
31b8ca9716 Bug 1654103: Standardize on Black for Python code in mozilla-central.
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat.

5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-26 18:34:53 +00:00
Bogdan Tara
612312a64c Backed out 10 changesets (bug 1654103, bug 1672023, bug 1518999) for PanZoomControllerTest.touchEventForResult gv-junit failures CLOSED TREE
Backed out changeset ff3fb0b4a512 (bug 1672023)
Backed out changeset e7834b600201 (bug 1654103)
Backed out changeset 807893ca8069 (bug 1518999)
Backed out changeset 13e6b92440e9 (bug 1518999)
Backed out changeset 8b2ac5a6c98a (bug 1518999)
Backed out changeset 575748295752 (bug 1518999)
Backed out changeset 65f07ce7b39b (bug 1518999)
Backed out changeset 4bb80556158d (bug 1518999)
Backed out changeset 8ac8461d7bd7 (bug 1518999)
Backed out changeset e8ba13ee17f5 (bug 1518999)
2020-10-24 03:36:18 +03:00
Ricky Stewart
065d2eb893 Bug 1654103: Standardize on Black for Python code in mozilla-central. r=remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers,devtools-backward-compat-reviewers,jgilbert,preferences-reviewers,sylvestre,maja_zf,webcompat-reviewers,denschub,ntim,whimboo,sparky
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Make some ad-hoc manual updates to `testing/marionette/client/setup.py`, `testing/marionette/harness/setup.py`, and `testing/firefox-ui/harness/setup.py`, which have hard-coded regexes that break after the reformat.

5. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-23 20:40:42 +00:00
Dorel Luca
95b44c982f Backed out changeset 7558c8821a07 (bug 1654103) for multiple failures. CLOSED TREE 2020-10-22 03:51:06 +03:00
Ricky Stewart
43baed3c18 Bug 1654103: Standardize on Black for Python code in mozilla-central. r=remote-protocol-reviewers,marionette-reviewers,webdriver-reviewers,perftest-reviewers,devtools-backward-compat-reviewers,jgilbert,preferences-reviewers,sylvestre,maja_zf,webcompat-reviewers,denschub,ntim,whimboo,sparky
Allow-list all Python code in tree for use with the black linter, and re-format all code in-tree accordingly.

To produce this patch I did all of the following:

1. Make changes to tools/lint/black.yml to remove include: stanza and update list of source extensions.

2. Run ./mach lint --linter black --fix

3. Make some ad-hoc manual updates to python/mozbuild/mozbuild/test/configure/test_configure.py -- it has some hard-coded line numbers that the reformat breaks.

4. Add a set of exclusions to black.yml. These will be deleted in a follow-up bug (1672023).

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D94045
2020-10-21 21:27:27 +00:00
Nick Alexander
6eadb91247 Bug 1525076 - Part 4: Cache attribution code on macOS. r=mixedpuppy
Querying the macOS system quarantine database is relatively slow, so
we'd like to do it only once.  This is relevant because the Telemetry
subsystem causes the attribution data to be fetched relatively early
during startup.  By caching, we accept additional disk activity but
don't have to invoke an external process, query a database, etc.

We must make BROWSER_ATTRIBUTION_ERRORS histogram apply to macOS as
well as Windows.  We add error codes to capture macOS-specific
detalis.  And we push this out to a later cycle, since there's no
reason to revisit this immediately.

Differential Revision: https://phabricator.services.mozilla.com/D92695
2020-10-11 18:20:11 +00:00
Nick Alexander
11c100d5ee Bug 1525076 - Part 3: Add method to serialize attribution data. r=mixedpuppy
On Windows, we parse the attribution data as if it was the
`URL.search` parameter.  On macOS, we parse a URL slightly
differently: we parse it like `URL.searchParams` and we deduplicate
parameters.

For caching on macOS we need to serialize the parsed data.  We could
use either approach but we elect to write the code serialized as it
would be on Windows, since that is the one that is getting actively
tested in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D92694
2020-10-11 18:19:22 +00:00
Nick Alexander
100c897d26 Bug 1525076 - Part 2: Add AttributionCode.writeAttributionFile. r=mixedpuppy
The next step is to have the cached attribution file location vary
depending on the platform, and to have the tests run on additional
platforms.

Differential Revision: https://phabricator.services.mozilla.com/D84264
2020-10-11 18:19:04 +00:00
Nick Alexander
5e69ce9766 Bug 1525076 - Part 1: Fix macOS native getReferrerUrl by invoking system sqlite binary (from JS). r=mixedpuppy
The issue this is addresses is that
[`CFURLCopyResourcePropertyForKey`](https://searchfox.org/mozilla-central/rev/ea7f70dac1c5fd18400f6d2a92679777d4b21492/xpcom/io/CocoaFileUtils.mm#212)
does not return quarantine data when launched as a GUI App.  What
happens is that launching via the GUI requires the user to override
GateKeeper by going to Security & Privacy > Open Anyway.  Doing that
updates the GateKeeper flags, and then the macOS API denies access:
once the GK flags reach some state, quarantine information is not
returned.  This is not documented (as far as I can see) but moons ago,
[somebody else on the internet witnessed the same
thing](https://cocoa-dev.apple.narkive.com/kkYeAC8o/is-it-possible-to-read-your-own-quarantine-info-after-launch).

To work around, we run the system SQLite binary, to fish the relevant
information out of the per-user quarantine database.  (SQLite is
installed by default on all relevant macOS versions.)

The most significant security concern I see is whether we can trust
this binary (in /usr/bin/sqlite3). Some discussion within the
Install/Update team suggested that an attacker who could corrupt or
modify that binary already had write access to the disk, which is an
attack vector equal to a totally compromised Firefox. If we determine
that we can't use the system SQLite binary, then we could use
Firefox's compiled copy of SQLite, but we might see versioning
issues. The system SQLite binary feels more robust.

This is implemented as a JS component for convenience, mostly: there
is no API for capturing output from `nsIProcess`.  It would be
possible to maintain the existing XPCOM contract by renaming the
existing contract and adding a contract with a JS implementation that
passes through to the renamed implementation, but it doesn't seem
worth the effort.

In the next commits, we will generalize the existing caching mechanism
form Windows to also apply to macOS. This is mostly a performance
optimization, so that we sniff a single well-known location rather
than launching a process at each startup, although there is a
correctness argument here as well, since the quarantine database is
dynamic and the attribution URL could expire.

Differential Revision: https://phabricator.services.mozilla.com/D92693
2020-10-11 18:18:36 +00:00
Nick Alexander
39987ecf12 Bug 1525076 - Part 0: Test more scenarios on macOS; handle URI component encoding. r=mixedpuppy
The existing code handles Windows and macOS quite differently.  On
macOS, the tests were not as comprehensive; this patch brings them
level and makes the form of the attribution data uniform on Windows
and macOS.  In particular, attribution data fields will now be URI
coded, just as they are on Windows.

This will allow us to re-use the parsing machinery we have on Windows
when we cache attribution codes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D92692
2020-10-11 18:18:11 +00:00
Nick Alexander
7c8e2b37bb Bug 1525076 - Pre: Avoid a crash in CFRelease. r=mixedpuppy
A malformed URL returns null.  The subsequent call to
`CocoaFileUtils::AddQuarantineMetadataToFile` does handle null
correctly, so this just avoids a crash.

Differential Revision: https://phabricator.services.mozilla.com/D92691
2020-10-11 18:18:08 +00:00
Razvan Maries
a84b6385b0 Backed out 6 changesets (bug 1525076) for perma failures on browser_startup_mainthreadio.js. CLOSED TREE
Backed out changeset a425e504ae7e (bug 1525076)
Backed out changeset 5163df5430c1 (bug 1525076)
Backed out changeset 4313cfb9dfcb (bug 1525076)
Backed out changeset 9178ebc95da2 (bug 1525076)
Backed out changeset 7bde7f6ccbd8 (bug 1525076)
Backed out changeset 6c2c2e07b95f (bug 1525076)
2020-10-09 22:51:36 +03:00
Nick Alexander
ca42485113 Bug 1525076 - Part 4: Cache attribution code on macOS. r=mixedpuppy
Querying the macOS system quarantine database is relatively slow, so
we'd like to do it only once.  This is relevant because the Telemetry
subsystem causes the attribution data to be fetched relatively early
during startup.  By caching, we accept additional disk activity but
don't have to invoke an external process, query a database, etc.

We must make BROWSER_ATTRIBUTION_ERRORS histogram apply to macOS as
well as Windows.  We add error codes to capture macOS-specific
detalis.  And we push this out to a later cycle, since there's no
reason to revisit this immediately.

Differential Revision: https://phabricator.services.mozilla.com/D92695
2020-10-09 17:28:51 +00:00
Nick Alexander
c5125585cf Bug 1525076 - Part 3: Add method to serialize attribution data. r=mixedpuppy
On Windows, we parse the attribution data as if it was the
`URL.search` parameter.  On macOS, we parse a URL slightly
differently: we parse it like `URL.searchParams` and we deduplicate
parameters.

For caching on macOS we need to serialize the parsed data.  We could
use either approach but we elect to write the code serialized as it
would be on Windows, since that is the one that is getting actively
tested in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D92694
2020-10-09 17:28:48 +00:00
Nick Alexander
8d7760c5a7 Bug 1525076 - Part 2: Add AttributionCode.writeAttributionFile. r=mixedpuppy
The next step is to have the cached attribution file location vary
depending on the platform, and to have the tests run on additional
platforms.

Differential Revision: https://phabricator.services.mozilla.com/D84264
2020-10-09 17:28:46 +00:00
Nick Alexander
eb1a1d0a4d Bug 1525076 - Part 1: Fix macOS native getReferrerUrl by invoking system sqlite binary (from JS). r=mixedpuppy
The issue this is addresses is that
[`CFURLCopyResourcePropertyForKey`](https://searchfox.org/mozilla-central/rev/ea7f70dac1c5fd18400f6d2a92679777d4b21492/xpcom/io/CocoaFileUtils.mm#212)
does not return quarantine data when launched as a GUI App.  What
happens is that launching via the GUI requires the user to override
GateKeeper by going to Security & Privacy > Open Anyway.  Doing that
updates the GateKeeper flags, and then the macOS API denies access:
once the GK flags reach some state, quarantine information is not
returned.  This is not documented (as far as I can see) but moons ago,
[somebody else on the internet witnessed the same
thing](https://cocoa-dev.apple.narkive.com/kkYeAC8o/is-it-possible-to-read-your-own-quarantine-info-after-launch).

To work around, we run the system SQLite binary, to fish the relevant
information out of the per-user quarantine database.  (SQLite is
installed by default on all relevant macOS versions.)

The most significant security concern I see is whether we can trust
this binary (in /usr/bin/sqlite3). Some discussion within the
Install/Update team suggested that an attacker who could corrupt or
modify that binary already had write access to the disk, which is an
attack vector equal to a totally compromised Firefox. If we determine
that we can't use the system SQLite binary, then we could use
Firefox's compiled copy of SQLite, but we might see versioning
issues. The system SQLite binary feels more robust.

This is implemented as a JS component for convenience, mostly: there
is no API for capturing output from `nsIProcess`.  It would be
possible to maintain the existing XPCOM contract by renaming the
existing contract and adding a contract with a JS implementation that
passes through to the renamed implementation, but it doesn't seem
worth the effort.

In the next commits, we will generalize the existing caching mechanism
form Windows to also apply to macOS. This is mostly a performance
optimization, so that we sniff a single well-known location rather
than launching a process at each startup, although there is a
correctness argument here as well, since the quarantine database is
dynamic and the attribution URL could expire.

Differential Revision: https://phabricator.services.mozilla.com/D92693
2020-10-09 17:27:13 +00:00
Nick Alexander
2326bf8eb4 Bug 1525076 - Part 0: Test more scenarios on macOS; handle URI component encoding. r=mixedpuppy
The existing code handles Windows and macOS quite differently.  On
macOS, the tests were not as comprehensive; this patch brings them
level and makes the form of the attribution data uniform on Windows
and macOS.  In particular, attribution data fields will now be URI
coded, just as they are on Windows.

This will allow us to re-use the parsing machinery we have on Windows
when we cache attribution codes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D92692
2020-10-09 17:26:38 +00:00
Nick Alexander
efea8a8c7f Bug 1525076 - Pre: Avoid a crash in CFRelease. r=mixedpuppy
A malformed URL returns null.  The subsequent call to
`CocoaFileUtils::AddQuarantineMetadataToFile` does handle null
correctly, so this just avoids a crash.

Differential Revision: https://phabricator.services.mozilla.com/D92691
2020-10-09 17:26:23 +00:00
Razvan Maries
8cb537bb4d Backed out 6 changesets (bug 1525076) for ES Lint failure. CLOSED TREE
Backed out changeset 912fcc3cb274 (bug 1525076)
Backed out changeset 690d730341c6 (bug 1525076)
Backed out changeset 5dd08176812c (bug 1525076)
Backed out changeset 963c8d33d779 (bug 1525076)
Backed out changeset f7d26b270884 (bug 1525076)
Backed out changeset 95fd52531439 (bug 1525076)
2020-10-09 20:17:23 +03:00
Nick Alexander
d639721f77 Bug 1525076 - Part 4: Cache attribution code on macOS. r=mixedpuppy
Querying the macOS system quarantine database is relatively slow, so
we'd like to do it only once.  This is relevant because the Telemetry
subsystem causes the attribution data to be fetched relatively early
during startup.  By caching, we accept additional disk activity but
don't have to invoke an external process, query a database, etc.

We must make BROWSER_ATTRIBUTION_ERRORS histogram apply to macOS as
well as Windows.  We add error codes to capture macOS-specific
detalis.  And we push this out to a later cycle, since there's no
reason to revisit this immediately.

Differential Revision: https://phabricator.services.mozilla.com/D92695
2020-10-09 16:52:26 +00:00
Nick Alexander
72e12d93f7 Bug 1525076 - Part 3: Add method to serialize attribution data. r=mixedpuppy
On Windows, we parse the attribution data as if it was the
`URL.search` parameter.  On macOS, we parse a URL slightly
differently: we parse it like `URL.searchParams` and we deduplicate
parameters.

For caching on macOS we need to serialize the parsed data.  We could
use either approach but we elect to write the code serialized as it
would be on Windows, since that is the one that is getting actively
tested in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D92694
2020-10-09 16:51:48 +00:00
Nick Alexander
f321c177e1 Bug 1525076 - Part 2: Add AttributionCode.writeAttributionFile. r=mixedpuppy
The next step is to have the cached attribution file location vary
depending on the platform, and to have the tests run on additional
platforms.

Differential Revision: https://phabricator.services.mozilla.com/D84264
2020-10-09 16:51:41 +00:00
Nick Alexander
be45f40052 Bug 1525076 - Part 1: Fix macOS native getReferrerUrl by invoking system sqlite binary (from JS). r=mixedpuppy
The issue this is addresses is that
[`CFURLCopyResourcePropertyForKey`](https://searchfox.org/mozilla-central/rev/ea7f70dac1c5fd18400f6d2a92679777d4b21492/xpcom/io/CocoaFileUtils.mm#212)
does not return quarantine data when launched as a GUI App.  What
happens is that launching via the GUI requires the user to override
GateKeeper by going to Security & Privacy > Open Anyway.  Doing that
updates the GateKeeper flags, and then the macOS API denies access:
once the GK flags reach some state, quarantine information is not
returned.  This is not documented (as far as I can see) but moons ago,
[somebody else on the internet witnessed the same
thing](https://cocoa-dev.apple.narkive.com/kkYeAC8o/is-it-possible-to-read-your-own-quarantine-info-after-launch).

To work around, we run the system SQLite binary, to fish the relevant
information out of the per-user quarantine database.  (SQLite is
installed by default on all relevant macOS versions.)

The most significant security concern I see is whether we can trust
this binary (in /usr/bin/sqlite3). Some discussion within the
Install/Update team suggested that an attacker who could corrupt or
modify that binary already had write access to the disk, which is an
attack vector equal to a totally compromised Firefox. If we determine
that we can't use the system SQLite binary, then we could use
Firefox's compiled copy of SQLite, but we might see versioning
issues. The system SQLite binary feels more robust.

This is implemented as a JS component for convenience, mostly: there
is no API for capturing output from `nsIProcess`.  It would be
possible to maintain the existing XPCOM contract by renaming the
existing contract and adding a contract with a JS implementation that
passes through to the renamed implementation, but it doesn't seem
worth the effort.

In the next commits, we will generalize the existing caching mechanism
form Windows to also apply to macOS. This is mostly a performance
optimization, so that we sniff a single well-known location rather
than launching a process at each startup, although there is a
correctness argument here as well, since the quarantine database is
dynamic and the attribution URL could expire.

Differential Revision: https://phabricator.services.mozilla.com/D92693
2020-10-09 16:51:39 +00:00
Nick Alexander
993a6837c1 Bug 1525076 - Part 0: Test more scenarios on macOS; handle URI component encoding. r=mixedpuppy
The existing code handles Windows and macOS quite differently.  On
macOS, the tests were not as comprehensive; this patch brings them
level and makes the form of the attribution data uniform on Windows
and macOS.  In particular, attribution data fields will now be URI
coded, just as they are on Windows.

This will allow us to re-use the parsing machinery we have on Windows
when we cache attribution codes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D92692
2020-10-09 16:51:36 +00:00
Nick Alexander
695713ed3f Bug 1525076 - Pre: Avoid a crash in CFRelease. r=mixedpuppy
A malformed URL returns null.  The subsequent call to
`CocoaFileUtils::AddQuarantineMetadataToFile` does handle null
correctly, so this just avoids a crash.

Differential Revision: https://phabricator.services.mozilla.com/D92691
2020-10-09 16:50:30 +00:00
Cosmin Sabou
51278a36a5 Backed out 6 changesets (bug 1525076) for OSX xpcshell failures on test_ASRouterTargeting_attribution. CLOSED TREE
Backed out changeset 25fd5f2e276e (bug 1525076)
Backed out changeset 4f2c3fe9ee78 (bug 1525076)
Backed out changeset e7e05723ceae (bug 1525076)
Backed out changeset d0c81fd932c7 (bug 1525076)
Backed out changeset c1629391c635 (bug 1525076)
Backed out changeset e6b09ef2a26c (bug 1525076)
2020-10-09 07:39:32 +03:00
Nick Alexander
ba34c2e0cd Bug 1525076 - Part 4: Cache attribution code on macOS. r=mixedpuppy
Querying the macOS system quarantine database is relatively slow, so
we'd like to do it only once.  This is relevant because the Telemetry
subsystem causes the attribution data to be fetched relatively early
during startup.  By caching, we accept additional disk activity but
don't have to invoke an external process, query a database, etc.

We must make BROWSER_ATTRIBUTION_ERRORS histogram apply to macOS as
well as Windows.  We add error codes to capture macOS-specific
detalis.  And we push this out to a later cycle, since there's no
reason to revisit this immediately.

Differential Revision: https://phabricator.services.mozilla.com/D92695
2020-10-08 21:54:16 +00:00
Nick Alexander
0ef0aabf15 Bug 1525076 - Part 3: Add method to serialize attribution data. r=mixedpuppy
On Windows, we parse the attribution data as if it was the
`URL.search` parameter.  On macOS, we parse a URL slightly
differently: we parse it like `URL.searchParams` and we deduplicate
parameters.

For caching on macOS we need to serialize the parsed data.  We could
use either approach but we elect to write the code serialized as it
would be on Windows, since that is the one that is getting actively
tested in the wild.

Differential Revision: https://phabricator.services.mozilla.com/D92694
2020-10-08 21:30:09 +00:00
Nick Alexander
ba282a56de Bug 1525076 - Part 2: Add AttributionCode.writeAttributionFile. r=mixedpuppy
The next step is to have the cached attribution file location vary
depending on the platform, and to have the tests run on additional
platforms.

Differential Revision: https://phabricator.services.mozilla.com/D84264
2020-10-08 21:54:49 +00:00
Nick Alexander
87ec636101 Bug 1525076 - Part 1: Fix macOS native getReferrerUrl by invoking system sqlite binary (from JS). r=mixedpuppy
The issue this is addresses is that
[`CFURLCopyResourcePropertyForKey`](https://searchfox.org/mozilla-central/rev/ea7f70dac1c5fd18400f6d2a92679777d4b21492/xpcom/io/CocoaFileUtils.mm#212)
does not return quarantine data when launched as a GUI App.  What
happens is that launching via the GUI requires the user to override
GateKeeper by going to Security & Privacy > Open Anyway.  Doing that
updates the GateKeeper flags, and then the macOS API denies access:
once the GK flags reach some state, quarantine information is not
returned.  This is not documented (as far as I can see) but moons ago,
[somebody else on the internet witnessed the same
thing](https://cocoa-dev.apple.narkive.com/kkYeAC8o/is-it-possible-to-read-your-own-quarantine-info-after-launch).

To work around, we run the system SQLite binary, to fish the relevant
information out of the per-user quarantine database.  (SQLite is
installed by default on all relevant macOS versions.)

The most significant security concern I see is whether we can trust
this binary (in /usr/bin/sqlite3). Some discussion within the
Install/Update team suggested that an attacker who could corrupt or
modify that binary already had write access to the disk, which is an
attack vector equal to a totally compromised Firefox. If we determine
that we can't use the system SQLite binary, then we could use
Firefox's compiled copy of SQLite, but we might see versioning
issues. The system SQLite binary feels more robust.

This is implemented as a JS component for convenience, mostly: there
is no API for capturing output from `nsIProcess`.  It would be
possible to maintain the existing XPCOM contract by renaming the
existing contract and adding a contract with a JS implementation that
passes through to the renamed implementation, but it doesn't seem
worth the effort.

In the next commits, we will generalize the existing caching mechanism
form Windows to also apply to macOS. This is mostly a performance
optimization, so that we sniff a single well-known location rather
than launching a process at each startup, although there is a
correctness argument here as well, since the quarantine database is
dynamic and the attribution URL could expire.

Differential Revision: https://phabricator.services.mozilla.com/D92693
2020-10-08 21:29:35 +00:00
Nick Alexander
2be713287f Bug 1525076 - Part 0: Test more scenarios on macOS; handle URI component encoding. r=mixedpuppy
The existing code handles Windows and macOS quite differently.  On
macOS, the tests were not as comprehensive; this patch brings them
level and makes the form of the attribution data uniform on Windows
and macOS.  In particular, attribution data fields will now be URI
coded, just as they are on Windows.

This will allow us to re-use the parsing machinery we have on Windows
when we cache attribution codes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D92692
2020-10-08 21:29:12 +00:00
Nick Alexander
edc6ce5f1d Bug 1525076 - Pre: Avoid a crash in CFRelease. r=mixedpuppy
A malformed URL returns null.  The subsequent call to
`CocoaFileUtils::AddQuarantineMetadataToFile` does handle null
correctly, so this just avoids a crash.

Differential Revision: https://phabricator.services.mozilla.com/D92691
2020-10-08 21:29:00 +00:00
Andrei Oprea
e2f56d0415 Bug 1621402 - Add telemetry to capture failures to read attribution data r=janerik,mixedpuppy
Differential Revision: https://phabricator.services.mozilla.com/D67163
2020-03-24 18:32:57 +00:00
Ed Lee
d663021fa5 Bug 1595063 - Support user agent attribution codes r=mixedpuppy,nanj
Add "ua" and increase allowed length for attribution codes. Allows asrouter devtools to set all keys.

Differential Revision: https://phabricator.services.mozilla.com/D57906
2019-12-24 17:04:10 +00:00
Shane Caraveo
2cb2c12685 Bug 1515172 support funnel attributes in attribution code r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D37668
2019-07-22 22:06:46 +00:00
Coroiu Cristina
89a5cf760f Backed out changeset cee7b065455b (bug 1515172) for xpcshell failures at browser/components/attribution/test/xpcshell/test_AttributionCode.js ona CLOSED TREE 2019-07-19 21:29:56 +03:00
Shane Caraveo
c8845636ac Bug 1515172 support funnel attributes in attribution code r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D37668
2019-07-19 17:10:09 +00:00
Dave Townsend
a3813bc96c Bug 1514437: Correctly encode the strings passed through nsIMacAttributionService. r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D37317
2019-07-15 15:19:20 +00:00
Victor Porof
8eb72fd3fc Bug 1561435 - Format browser/components/, a=automatic-formatting
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D36042
2019-07-05 09:53:32 +02:00
Mark Banner
d5029e0dae Bug 1415265 - Remove now unnecessary .eslintrc.js files or entries. r=mossop
Differential Revision: https://phabricator.services.mozilla.com/D23850
2019-03-28 09:38:14 +00:00