Commit Graph

219 Commits

Author SHA1 Message Date
Sebastian Hengst
09a5305d26 Backed out changeset 44635c073692 (bug 1345058) on suspicion of causing intermittent xpcshell failures in toolkit/components/url-classifier/tests/unit/test_bug1274685_unowned_list.js on OS X. r=backout 2017-05-19 13:13:18 +02:00
Henry Chang
53df2ddfd9 Bug 1345058 - Asynchronously decide if a flash document should be blocked. r=baku,bytesized
Technically speaking, we use the new async API 'nsIURIClassifier.asyncClassifyLocalWithTables'
to replace the old sync API. However, since we cannot guarantee the async call will be done when
we neet its result, we need a sync call as a fallback in this case. This is a sub-optimal
solution and we will be investigating if there's a better solution if the sync call
is used too frequently.

MozReview-Commit-ID: L1uQ2eaYr1e
2017-05-10 15:32:34 +08:00
DimiL
769f299a32 Bug 1333328 - Remove mTableFreshness and gFreshnessGuarantee. r=francois
Functions and Preference related to mTableFreshness and gFreshnessGuarantee
could be removed since we will no longer require them.

MozReview-Commit-ID: IAa0UHLSQ56
2017-05-04 11:13:21 +08:00
DimiL
a0b8501692 Bug 1333328 - Refactor cache miss handling mechanism for V2. r=francois
In this patch, we will make Safebrowsing V2 caching use the same algorithm as V4.
So we remove "mMissCache" for negative caching and TableFresness check for
positive caching.

But Safebrowsing V2 doesn't contain negative/positive cache duration information in
gethash response. So we hard-code a fixed value, 15 minutes, as cache duration.
In this way, we can sync the mechanism we handle caching for V2 and V4.

An extra effort for V2 here is that we need to manually record prefixes misses
because we won't get any response for those prefixes(implemented in
nsUrlClassifierLookupCallback::CacheMisses).
2017-05-04 09:38:14 +08:00
Thomas Nguyen
9ca7549a71 Bug 1351472 - Skip AddNoise if the table is unknown or disallowed to getHash r=francois
MozReview-Commit-ID: GMWs2UpiyiP
2017-04-28 15:26:54 +08:00
DimiL
141d7020a5 Bug 1358324 - The URLCLASSIFIER_MATCH_THREAT_TYPE_RESULT probe doesn't seem to be working correctly. r=francois
mResults is lookupResultArray which is created when we find matched prefix in the database.
mCacheResults stores response of gethash request.

We record threat type match telemetry only when completion is found in both V2 and V4,
that is we got one confirmed result for V2 and one for V4. And then we could record threat
types by iterating through mCacheResultsArray.

But if one of lookupResult is from cache, for example, completion is found in 'goog-malware-proto',
then we won't trigger a gethash request for it because it is in the cache.
In this scenario, mCacheResults will not have results from V4 so when we try to record
threat types we won't find V4 ones.

In this patch we only record telemetry when gethash is sent for both V2 and V4. This may limit
the usefulness of that probe a little bit, but we shouldn't make the code less efficient just
to be able to measure telemetry better.

MozReview-Commit-ID: Ib8SGUaxb4c
2017-04-21 15:09:44 +08:00
Thomas Nguyen
87c03bcdea Bug 1353853 - Cache preferences when doing channel classify r=francois
We will cache all preferences which will be read during classifing channel
- Store them into static variables nsUrlClassifierDBService
- Use a singleton class to manage/update preferrences in nsChannelClassifier

MozReview-Commit-ID: GvyBI3rVpYh
2017-04-18 17:00:27 +08:00
dimi
af40c9d725 Bug 1356067 - Fix memory leak in nsUrlClassifierLookupCallback::CompletionV4. r=francois
MozReview-Commit-ID: 67ANYHWIRX0
2017-04-13 15:39:30 +08:00
dimi
80b83c117c Bug 1311933 - P2. Add telemetry to measure if completion match type is the same for v2 and v4. r=francois
When full match is found in both v2 and v4, the threat types returned should also be the same.
If threat types are different, the telemetry record this by setting a bit flags which indicates
what threat types are being returned.

If threat types are the same, this telemetry will record 0.

MozReview-Commit-ID: Laz77yoCg00
2017-04-12 09:11:18 +08:00
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
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
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
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
Sebastian Hengst
ac6f4701fe Backed out changeset fc8099c8f98a (bug 1311935) 2017-04-07 19:05:42 +02: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
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
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
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
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
Henry Chang
7330f247a6 Bug 1341506 - Part 2: Add telemetry for AsyncClassifyLocalWithTables. r=francois
MozReview-Commit-ID: 14QG0AdxbE5
2017-02-24 00:14:11 +08:00
Henry Chang
40c00b3543 Bug 1341506 - Part 1: Implement and use nsIURIClassifier.asyncClassifyLocalWithTables. r=Ehsan,francois
MozReview-Commit-ID: 8dvYM4o2Xxw
2017-03-01 11:27:51 +08:00
Dimi Lee
7545e85763 Bug 1335974 - Add more error codes to URLCLASSIFIER_UPDATE_ERROR. r=francois
MozReview-Commit-ID: AAd6Yu0AuUO
2017-02-22 16:25:04 +08:00
Dimi Lee
5375a9f0e5 Bug 1311931 - Add telemetry to measure full match rate for v2 and v4. r=francois
MozReview-Commit-ID: H9jAR82rgDh
2017-02-23 23:07:13 +08:00
Thomas Nguyen
6ca9c778d6 Bug 1288633 - Add more information when an URL matches Safe Browsing list. r=dragana,francois
MozReview-Commit-ID: 6u0dUOB838F
2017-02-21 09:46:36 +08:00
Tom Tromey
a4b717ab39 Bug 1060419 - make log_print use Printf.h, r=froydnj
MozReview-Commit-ID: BIZ1GQEZ1vs
2016-12-15 20:16:31 -07:00
Tom Tromey
48da5b7de4 Bug 1060419 - remove unneeded includes of prprf.h, r=froydnj
MozReview-Commit-ID: JifhpA3oOeH
2016-12-09 10:00:01 -10:00
Francois Marier
93a6db0a84 Bug 1334616 - Add telemetry probe to monitor ClassifyLocalWithTables() perf. r=gcp
MozReview-Commit-ID: LfKovwAX9Ov
2017-02-03 20:56:05 +08:00
Phil Ringnalda
99db7d0422 Backed out changeset 2e9eab35d1ea (bug 1334616) for bustage
CLOSED TREE
2017-02-06 22:04:16 -08:00
Francois Marier
173cf1fe01 Bug 1334616 - Add telemetry probe to monitor ClassifyLocalWithTables() perf. r=gcp
MozReview-Commit-ID: LfKovwAX9Ov
2017-02-03 20:56:05 +08:00
Francois Marier
8ab3e4bd30 Bug 1336376 - Expand the range of values for URLCLASSIFIER_LOOKUP_TIME. r=bsmedberg
MozReview-Commit-ID: 9zh8mldBS7k
2017-02-03 20:30:08 +08:00
Henry Chang
7bb28e53f9 Bug 1323953 - Send 4-byte prefix for both v2/v4 tables. r=francois
MozReview-Commit-ID: 1jlBdSQARNg
2017-02-07 10:56:12 +08:00
Wes Kocher
785ad4f15f Backed out changeset 3a6b42b3d233 (bug 1336376) for build failures a=backout CLOSED TREE
MozReview-Commit-ID: L3oVRVqNDKj
2017-02-06 18:36:24 -08:00
Thomas Nguyen
8306f6ac3b Bug 1336005 - Add null check when releasing and shutting down background thread r=francois
MozReview-Commit-ID: HKlQLqQH2c9
2017-02-07 10:06:21 +08:00
Francois Marier
3714472b99 Bug 1336376 - Expand the range of values for URLCLASSIFIER_LOOKUP_TIME. r=bsmedberg
MozReview-Commit-ID: 9zh8mldBS7k
2017-02-03 20:30:08 +08:00
Dimi Lee
1859178ca5 Bug 1332770 - Fix the google4 provider is showing up as other in some telemetry pings. r=francois
MozReview-Commit-ID: KbpYAnf6qxd
2017-01-27 18:02:36 +08:00
Dimi Lee
45dd73df16 Bug 1333257 - Only cache V2 misses when doing Safe Browsing lookups. r=francois
MozReview-Commit-ID: 6kvM6z5OnPw
2017-01-26 11:36:52 +08:00
dimi
9cac186808 Bug 1328821 - hash completion request for v4 should not depend on table freshness. r=francois,henry
MozReview-Commit-ID: EIjDrnj1I4S
2017-01-17 08:33:08 +08:00
Henry Chang
29a04b7790 Bug 1331534 - Temporarily ignore v4 hash completion result. r=francois
MozReview-Commit-ID: 9P68EP5CWG4
2017-01-18 16:49:57 +08:00
Thomas Nguyen
433f1d4821 Bug 1324820 - Make sure we resume the channel if there's no classifier callback r=gcp
MozReview-Commit-ID: 35jBJb1Q8Rz
2017-01-12 18:07:22 +08:00
DimiL
3cb66c6aee Bug 1311910 - Add telemetry to measure update error and update timeout rate for V2 and V4. r=francois,henry
MozReview-Commit-ID: JL4aZrUOGH7
2016-12-19 09:43:02 +08:00
Henry Chang
b9d5f5080f Bug 1312339 - LookupResult to support variable length partial hash. r=francois
MozReview-Commit-ID: DKwNCNKJAW
2016-12-16 14:34:32 +08:00
Henry Chang
eff83f87c8 Bug 1276826 - Part 2. Send gethash request and handle gethash response for v4. r=francois
MozReview-Commit-ID: 6fIbN6a6gHI
2016-11-28 14:55:36 +08:00
Kershaw Chang
faad0ac53b Bug 1141814 - Part 1: Enable to update TP list if TP is disabled. r=francois 2016-11-30 23:12:00 -05:00
Kirk Steuber
3f451e0c48 Bug 1321377 - When called from the content process, ClassifyLocalWithTables should return failure instead of causing an IPC error r=Ehsan,francois
MozReview-Commit-ID: B1RemxGRSKB
2016-11-30 10:57:48 -08:00
Kirk Steuber
845ef3d6da Bug 1319571 - Change the output format of nsUrlClassifierDBService::ClassifyLocalWithTables from comma separated string to an array of strings r=francois
MozReview-Commit-ID: TXln2EQnZS
2016-11-29 13:04:43 -08:00
Thomas Nguyen
7064eed520 Bug 1315386 - Make Safe Browsing code more shutdown-aware. r=francois,gcp.
MozReview-Commit-ID: ATCVfh5YLZl
2016-11-25 16:02:37 +08:00
Ehsan Akhgari
45bfeafc80 Bug 1318768 - Part 3: Make nsIURIClassifier::ClassifyLocalWithTables() usable in the content process; r=gcp,baku 2016-11-22 08:17:34 -05:00
Ehsan Akhgari
4dfc942bf0 Bug 1318768 - Part 2: Make nsIURIClassifier::Classify() available in the content process; r=gcp,baku 2016-11-22 08:17:26 -05:00