Commit Graph

989 Commits

Author SHA1 Message Date
dimi
b19db734bc Bug 1311933 - P1. Use integer as the key of safebrowsing cache. r=francois
In Bug 1323953, we always send 4-bytes prefix for completion and the prefix is also
used as the key to store cache result from gethash request.
Since it is always 4-bytes, we could convert it to integer for simplicity.

MozReview-Commit-ID: Lkvrg0wvX5Z
2017-04-11 16:07:26 +08:00
DimiL
fc56bf5630 Bug 1311935 - P4. GTest for safebrowsing v4 caching. r=francois
MozReview-Commit-ID: ExR5NJUvzNg
2017-04-07 14:31:04 +08:00
dimi
bb15dc150d Bug 1311935 - P3. Implement safebrowsing v4 caching logic. r=francois
LookupCacheV4::Has implements safebrowsing v4 caching logic.
1. Check if fullhash match any prefix in local database:
  - If not, the URL is safe.
2. Check if prefix is in the cache(prefix is always the first 4-byte of
   the fullhash, Bug 1323953):
  - If not, send fullhash request
3. Check if fullhash is in the positive cache:
  - If fullhash is found and it is not expired, the URL is not safe.
  - If fullhash is found and it is expired, send fullhash request.
4. If fullhash is not found, check negative cache expired time:
  - If negative cache time is not expired, the URL is safe.
  - If negative cache time is expired, send fullhash request.

MozReview-Commit-ID: GRX7CP8ig49
2017-04-10 14:21:08 +08:00
dimi
5b1a0ff5b5 Bug 1311935 - P2. Process fullHashes.find response. r=francois
This patch includes following changes:

1. nsUrlClassifierHashCompleter.js
   nsUrlClassifierHashCompleter.idl
   - Add completionV4 interface for hashCompleter to pass response data to
     DB service.
   - Process response data includes negative cache duration, matched full
     hashes and cache duration for each match. Full matches are passed through
     nsIFullHashMatch interface.
   - Change _requests.responses from array contains matched fullhashes to
     dictionary so that it can store additional information likes negative cache
     duration.
2. nsUrlClassifierDBService.cpp
   - Implement CompletionV4 interface, store response data to CacheResultV4
     object. Expired duration to expired time is handled here.
   - Add CacheResultToTableUpdate function to convert V2 & V4 cache result
     to TableUpdate object.
3. LookupCache.h
   - Extend CacheResult to CacheResultV2 and CacheResultV4 so we can store
     response data in CompletionV2 and CompletionV4.
4. HashStore.h
   - Add API and member variable in TableUpdateV4 to store response data.
     TableUpdate object is used by DB service to pass update data or gethash
     response to Classifier, so we need to extend TableUpdateV4 to be able
     to store fullHashes.find response.
6. Entry.h
   - Define the structure about how we cache fullHashes.find response.

MozReview-Commit-ID: FV4yAl2SAc6
2017-04-11 11:50:48 +08:00
DimiL
c1a8a088db Bug 1311935 - P1. Make ActiveTables() work for safebrowsing v4. r=francois
This patch fixes that Classifier::ActiveTables doesn't return v4 tables.

Classifier::mActiveTablesCache is generated by scanning safebrowsing directory.
We use Classifier::ScanStoreDir to do the work, but it will ignore subdirectory.
Since v4 tables are stored in subdirectory 'google4', mActiveTablesCache doesn't
include v4 tables.

Fix this issue by checking subdirectory recursively in ScanStoreDir.

MozReview-Commit-ID: I6pa6e4bFND
2017-04-07 14:30:11 +08:00
Iris Hsiao
cd018fd494 Backed out 4 changesets (bug 1311935) for causing assertion crash by developer's request
Backed out changeset 27e624cd9479 (bug 1311935)
Backed out changeset 4c0381ab0990 (bug 1311935)
Backed out changeset 73587838ef16 (bug 1311935)
Backed out changeset a5a6c0f79733 (bug 1311935)
2017-04-11 11:04:54 +08:00
DimiL
6e67fcdbfd Bug 1311935 - P4. GTest for safebrowsing v4 caching. r=francois
MozReview-Commit-ID: ExR5NJUvzNg
2017-04-07 14:31:04 +08:00
dimi
3a7526678a Bug 1311935 - P3. Implement safebrowsing v4 caching logic. r=francois
LookupCacheV4::Has implements safebrowsing v4 caching logic.
1. Check if fullhash match any prefix in local database:
  - If not, the URL is safe.
2. Check if prefix is in the cache(prefix is always the first 4-byte of
   the fullhash, Bug 1323953):
  - If not, send fullhash request
3. Check if fullhash is in the positive cache:
  - If fullhash is found and it is not expired, the URL is not safe.
  - If fullhash is found and it is expired, send fullhash request.
4. If fullhash is not found, check negative cache expired time:
  - If negative cache time is not expired, the URL is safe.
  - If negative cache time is expired, send fullhash request.

MozReview-Commit-ID: GRX7CP8ig49
2017-04-10 14:21:08 +08:00
dimi
5856f89d1f Bug 1311935 - P2. Process fullHashes.find response. r=francois
This patch includes following changes:

1. nsUrlClassifierHashCompleter.js
   nsUrlClassifierHashCompleter.idl
   - Add completionV4 interface for hashCompleter to pass response data to
     DB service.
   - Process response data includes negative cache duration, matched full
     hashes and cache duration for each match. Full matches are passed through
     nsIFullHashMatch interface.
   - Change _requests.responses from array contains matched fullhashes to
     dictionary so that it can store additional information likes negative cache
     duration.
2. nsUrlClassifierDBService.cpp
   - Implement CompletionV4 interface, store response data to CacheResultV4
     object. Expired duration to expired time is handled here.
   - Add CacheResultToTableUpdate function to convert V2 & V4 cache result
     to TableUpdate object.
3. LookupCache.h
   - Extend CacheResult to CacheResultV2 and CacheResultV4 so we can store
     response data in CompletionV2 and CompletionV4.
4. HashStore.h
   - Add API and member variable in TableUpdateV4 to store response data.
     TableUpdate object is used by DB service to pass update data or gethash
     response to Classifier, so we need to extend TableUpdateV4 to be able
     to store fullHashes.find response.
6. Entry.h
   - Define the structure about how we cache fullHashes.find response.

MozReview-Commit-ID: KgR1NASl7GC
2017-04-10 16:20:09 +08:00
DimiL
c4fc0215be Bug 1311935 - P1. Make ActiveTables() work for safebrowsing v4. r=francois
This patch fixes that Classifier::ActiveTables doesn't return v4 tables.

Classifier::mActiveTablesCache is generated by scanning safebrowsing directory.
We use Classifier::ScanStoreDir to do the work, but it will ignore subdirectory.
Since v4 tables are stored in subdirectory 'google4', mActiveTablesCache doesn't
include v4 tables.

Fix this issue by checking subdirectory recursively in ScanStoreDir.

MozReview-Commit-ID: I6pa6e4bFND
2017-04-07 14:30:11 +08:00
Joel Maher
d2be399571 Bug 1351067 - add BUG_COMPONENT to toolkit/* files. r=myk,enndeakin,mossop
MozReview-Commit-ID: 8mv5Oed68JL
2017-04-09 05:43:43 -04:00
Sebastian Hengst
50a41bb8e6 Backed out changeset 2f185f0d9e26 (bug 1311935) for failing browser_trackingUI_6.js. r=backout 2017-04-07 19:06:18 +02:00
Sebastian Hengst
ac6f4701fe Backed out changeset fc8099c8f98a (bug 1311935) 2017-04-07 19:05:42 +02:00
Sebastian Hengst
95f06a1763 Backed out changeset a4e571cb610a (bug 1311935) 2017-04-07 19:05:38 +02:00
Sebastian Hengst
1274e1391e Backed out changeset 18a286ccf1be (bug 1311935) 2017-04-07 19:05:33 +02:00
DimiL
6b0a7aba9b Bug 1311935 - P4. GTest for safebrowsing v4 caching. r=francois
MozReview-Commit-ID: ExR5NJUvzNg
2017-04-07 14:31:04 +08:00
"unknown@unknown.com"
33c89e1ef8 Bug 1311935 - P3. Implement safebrowsing v4 caching logic. r=francois
LookupCacheV4::Has implements safebrowsing v4 caching logic.
1. Check if fullhash match any prefix in local database:
  - If not, the URL is safe.
2. Check if prefix is in the cache(prefix is always the first 4-byte of
   the fullhash, Bug 1323953):
  - If not, send fullhash request
3. Check if fullhash is in the positive cache:
  - If fullhash is found and it is not expired, the URL is not safe.
  - If fullhash is found and it is expired, send fullhash request.
4. If fullhash is not found, check negative cache expired time:
  - If negative cache time is not expired, the URL is safe.
  - If negative cache time is expired, send fullhash request.

MozReview-Commit-ID: HFpqaOGOtUa
2017-04-07 14:30:28 +08:00
dimi
b3df2a0280 Bug 1311935 - P2. Process fullHashes.find response. r=francois
This patch includes following changes:

1. nsUrlClassifierHashCompleter.js
   nsUrlClassifierHashCompleter.idl
   - Add completionV4 interface for hashCompleter to pass response data to
     DB service.
   - Process response data includes negative cache duration, matched full
     hashes and cache duration for each match. Full matches are passed through
     nsIFullHashMatch interface.
   - Change _requests.responses from array contains matched fullhashes to
     dictionary so that it can store additional information likes negative cache
     duration.
2. nsUrlClassifierDBService.cpp
   - Implement CompletionV4 interface, store response data to CacheResultV4
     object. Expired duration to expired time is handled here.
   - Add CacheResultToTableUpdate function to convert V2 & V4 cache result
     to TableUpdate object.
3. LookupCache.h
   - Extend CacheResult to CacheResultV2 and CacheResultV4 so we can store
     response data in CompletionV2 and CompletionV4.
4. HashStore.h
   - Add API and member variable in TableUpdateV4 to store response data.
     TableUpdate object is used by DB service to pass update data or gethash
     response to Classifier, so we need to extend TableUpdateV4 to be able
     to store fullHashes.find response.
6. Entry.h
   - Define the structure about how we cache fullHashes.find response.

MozReview-Commit-ID: 8pUJITn8c1n
2017-04-07 16:56:08 +08:00
DimiL
6032ace43b Bug 1311935 - P1. Make ActiveTables() work for safebrowsing v4. r=francois
This patch fixes that Classifier::ActiveTables doesn't return v4 tables.

Classifier::mActiveTablesCache is generated by scanning safebrowsing directory.
We use Classifier::ScanStoreDir to do the work, but it will ignore subdirectory.
Since v4 tables are stored in subdirectory 'google4', mActiveTablesCache doesn't
include v4 tables.

Fix this issue by checking subdirectory recursively in ScanStoreDir.

MozReview-Commit-ID: I6pa6e4bFND
2017-04-07 14:30:11 +08:00
Henry Chang
7141f6bb42 Bug 1343425 - Supports nsIURIClassifier.asyncClassifyLocalWithTables. r=baku
We add a new "on-off" protocol PURLClassifierLocal which calls
nsIURIClassifier.asyncClassifyLocalWithTables on construction and
calls back on destruction. Pretty much the same design as PURLClassifier.

In order to avoid code duplication, the actor implementation is templatized
and |MaybeInfo| in PURLClassifier.ipdl is moved around.

Test case is included and the custom event target is not in place for labelling.
The custom event target will be done in Bug 1353701.

MozReview-Commit-ID: IdHYgdnBV7S
2017-04-07 14:15:16 +08:00
Henry Chang
4543c61a48 Bug 1339050 - Asynchronously apply safebrowsing DB update. r=francois,gcp
A new function Classifier::AsyncApplyUpdates() is implemented for async update.
Besides, all public Classifier interfaces become "worker thread only" and
we remove DBServiceWorker::ApplyUpdatesBackground/Foreground.

In DBServiceWorker::FinishUpdate, instead of calling Classifier::ApplyUpdates,
we call Classifier::AsyncApplyUpdates and install a callback for notifying
the update observer when update is finished. The callback will occur on the
caller thread (i.e. worker thread.)

As for the shutdown issue, when the main thread is notified to shut down,
we at first *synchronously* dispatch an event to the worker thread to
shut down the update thread. After getting synchronized with all other
threads, we send last two events "CancelUpdate" and "CloseDb" to notify
dangling update (i.e. BeginUpdate is called but FinishUpdate isn't)
and do cleanup work.

MozReview-Commit-ID: DXZvA2eFKlc
2017-04-06 07:07:56 +08:00
Thomas Nguyen
75c7b4139d Bug 1336903 - Add telemetry probes to track Safe Browsing server response time r=francois
The probes keep track of V2 and V4 server response to update and getHash
request. The probes are keyed by provider

MozReview-Commit-ID: 3Uxjm6H77lE
2017-03-24 15:41:23 +08:00
Kirk Steuber
fada0072b5 Bug 1350381 - Change Flash blocking to allow the setting "Ask to Activate" to control CTA of unknown documents. r=qdot
Previously, we operated under the understanding that with Flash blocking activated, non-whitelisted documents would be set to CTA. We are changing that such that now, documents will only be CTA'ed if Flash is set to "Ask to Activate".

Flash blocking will now behave according to the following chart:

User Setting   Flash block   Whitelisted sites   Blacklisted sites    Unlisted sites
"Never ..."    Off           Deny                Deny                 Deny
"Ask ..."      Off           Ask                 Ask                  Ask
"Always ..."   Off           Allow               Allow                Allow
"Never ..."    On            Deny                Deny                 Deny
"Ask ..."      On            Allow               Deny                 Ask
"Always ..."   On            Allow               Deny                 Allow

This patch also completely reworks the flash blocking testing. Test data and most code remains consolidated, but will be run in multiple different tests. This avoids having to extend the timeout for Flash block testing to an extremely long length. The new Flash block testing additionally tests each of the six cases (rows) in the table above.

MozReview-Commit-ID: 5aPGUEiUiCv
2017-03-24 14:15:02 -07:00
dimi
fa1cdd079d Bug 1350798 - Ignore v4 completion too early will cause telemetry::URLCLASSIFIER_MATCH_RESULT gets wrong results. r=francois
Enable safebrowsing v4 completion but ignore the result by checking preference in
nsUrlClassifierLookupCallback::Completion may cause telemetry measure incorrect match
result since v4 completions will always be ignored.

So in this patch we move the preference check after telemetry is measured and then we
ignore the result.

MozReview-Commit-ID: J29JitvW3Lc
2017-03-28 09:09:57 +08:00
Carsten "Tomcat" Book
97bcba5d10 Merge mozilla-central to autoland 2017-03-23 13:59:20 +01:00
dimi
703eec0632 Bug 1338033 - Remove URLCLASSIFIER_PREFIX_MATCH. r=francois
URLCLASSIFIER_PREFIX_MATCH is replaced by URLCLASSIFIER_FULL_MATCH(Bug 1311931)
so it should be removed.

MozReview-Commit-ID: 4F1B07bGwRP
2017-03-22 17:27:11 +08:00
Sébastien Blin
aa1cd88356 Bug 1298321 - Refactor tests related to getHash. r=francois 2017-01-17 07:03:00 -05:00
Mark Banner
ec9074e132 Bug 1347712 - Change the testing configurations into ESLint configurations within eslint-plugin-mozilla - automatically update .eslintrc.js test config files for new config locations. r=jaws
MozReview-Commit-ID: LH0CQOPfoe6
2017-03-20 12:36:37 +01:00
Thomas Nguyen
77b3b0ad21 Bug 1345569 - Get blocked info from content when clicking report false deceiptive site from xul browser. r=francois
MozReview-Commit-ID: GXkbjfOrnHX
2017-03-20 14:43:08 +08:00
Henry Chang
7f0e427cd5 Bug 1348626 - Retry when isPinged() failed to avoid false alarm. r=francois
MozReview-Commit-ID: BOdJZReICxZ
2017-03-19 15:52:25 +08:00
dimi
2039871388 Bug 1346196 - URLCLASSIFIER_UPDATE_REMOTE_STATUS2 records values using empty keys. r=francois
mTelemetryProvider might be empty if |CancelUpdate| is called during update.
In that scenario, the call flow will look like:
CancelUpdate -> UpdateError -> DownloadDone -> set mTelemetryProvider to empty ->
OnStartRequest -> record telemetry with empty key.

So in this patch, move mTelemetryProvider.Truncate() to OnStopRequest.

MozReview-Commit-ID: JDgNUqR4SKa
2017-03-16 14:42:46 +08:00
Henry Chang
c3c42fecfb Bug 1347657 - Use array entry as value instead of reference to avoid being invalidated by realloc. r=francois
nsTArray::AppendElement may cause memory reallocation if out of capacity.
In nsUrlClassifierStreamUpdater::FetchNextRequest(), we take the reference of
the first element of mPendingRequests and pass its member as reference to
DownloadUpdate(), where mPendingRequests.AppendElement will be called.
If the AppendElement in DownloadUpdate() causes realloc, the reference
becomes dangling.

The most efficient fix is to "move" the reference's (i.e. request)
member variables to DownloadUpdate() but I think in this case we can just
take the value from the array and pass it around with no given that the
array element contains simply a couple of strings and pointers.

MozReview-Commit-ID: KEZ5d3l3HoI
2017-03-16 15:19:45 +08:00
Henry Chang
6d4717a54c Bug 1345922 - Avoid concurrent update and take the failed beginUpdate into account. r=francois
MozReview-Commit-ID: IfRIazBvAyl
2017-03-10 00:47:26 +08:00
Kirk Steuber
82f36355d4 Bug 1345611 - Change behavior of subdocument Flash blocking to be Third-Party Flash blocking r=bsmedberg,qdot
The previous implementation regarding to the Flash Blocking Subdocument list blocked all subdocuments that matched the list. This patch changes that so that subdocuments are only blocked if they are on the Subdocument Block List and also are loaded in a Third-Party context.

The changes to cert8.db and key3.db add the https certificate for subdocument.example.com so that testing can verify that a scheme mismatch between the document and its parent results in a third-party classification.

MozReview-Commit-ID: IXnA4iPzB4y
2017-03-10 10:50:21 -08:00
Henry Chang
b1b06f3fe9 Bug 1346757 - Change the downloadError callback timing. r=francois
MozReview-Commit-ID: JleLPltEBOw
2017-03-13 21:16:07 +08:00
Thomas Nguyen
23421961ee Bug 1343416 - Use LCG when generating noise entries for Safe Browsing completions r=gcp
MozReview-Commit-ID: FxQH2haAcrf
2017-03-09 10:59:52 +08:00
Carsten "Tomcat" Book
41c5179adf Merge mozilla-central to autoland 2017-03-08 17:04:17 +01:00
Benjamin Smedberg
4c9ad8511e Bug 1344908 - Build flash-block-lists.rst into the generated documentation, r=bytesized
MozReview-Commit-ID: AdHUGjNXQjL
2017-03-06 17:11:44 -05:00
Thomas Nguyen
72ec8b5761 Bug 1339006 - Specify event target if we run nsIURIClassifier.clasify() from content process.r=ehsan, r=gcp
MozReview-Commit-ID: BztjVMlQngi
2017-03-08 11:06:36 +08:00
Wes Kocher
b589990f5f Merge inbound to central, a=merge
MozReview-Commit-ID: 96co4Bbby7W
2017-03-07 16:40:44 -08:00
Florian Quèze
0b17fc5d60 Bug 1344711 - hand cleanup of cases that were ignored by the script to remove try blocks around get*Pref calls, r=jaws. 2017-03-07 15:29:48 +01:00
Henry Chang
75d7890222 Bug 1339760 - Split update process to background/foreground and run background on update thread **synchronously**. r=francois,gcp
MozReview-Commit-ID: J0phPC1nWsf
2017-02-22 17:25:26 +08:00
David Major
b1e362f6f7 Bug 1344615: Remove nsXPCOMStrings.{h,cpp} r=bsmedberg
These are now dead code.

MozReview-Commit-ID: AClU0Qx3kmN
2017-03-06 17:52:54 +13:00
Carsten "Tomcat" Book
dc21916166 merge mozilla-inbound to mozilla-central a=merge 2017-03-02 14:02:48 +01:00
Thomas Nguyen
c68b0c13e5 Bug 1341514 - Using the valid update url provider in test. r=gcp
MozReview-Commit-ID: 50NcRd2e9hB
2017-03-02 00:07:53 +08:00
Wes Kocher
93580c6796 Merge m-c to autoland, a=merge
MozReview-Commit-ID: 8dvpEkAL5Vh
2017-02-27 13:39:07 -08:00
Wes Kocher
8ba52721c8 Merge inbound to central, a=merge
MozReview-Commit-ID: F0XvCKnh8H7
2017-02-27 13:34:55 -08:00
Thomas Nguyen
a1f79aa942 Bug 1331139 - Sync safebrowsing.proto from Chromium. r=francois
MozReview-Commit-ID: KWi8wWhqCcr
2017-02-27 12:18:50 +08:00
Thomas Nguyen
d107e3566b Bug 1331139 - Enable download protection for V4 lists. r=francois
MozReview-Commit-ID: 8IHKGvXQjPt
2017-02-27 12:18:33 +08:00
Henry Chang
73fc8b0a2d Bug 1342397 - Properly reset stuff when failing to create LookupCache for update. r=gcp
MozReview-Commit-ID: 1ecI2lFIj2U
2017-02-25 00:22:39 +08:00