Bug 1531354 - P5. Safe Browsing test entries are directly stored in LookupCache. r=gcp

Create test entries via update introduces performance overhead.
We can store them directly in LookupCache and do not save test entries
to disk.

Differential Revision: https://phabricator.services.mozilla.com/D34576
This commit is contained in:
dlee
2019-06-29 19:05:41 +00:00
parent 7a8ac63eb7
commit f59bb40e5d
35 changed files with 228 additions and 212 deletions

View File

@@ -306,9 +306,12 @@ static const struct {
{"goog-passwordwhite-proto", CSD_WHITELIST}, // 8
// For testing purpose.
{"test-phish-proto", SOCIAL_ENGINEERING_PUBLIC}, // 2
{"test-unwanted-proto", UNWANTED_SOFTWARE}, // 3
{"test-passwordwhite-proto", CSD_WHITELIST}, // 8
{"moztest-phish-proto", SOCIAL_ENGINEERING_PUBLIC}, // 2
{"test-phish-proto", SOCIAL_ENGINEERING_PUBLIC}, // 2
{"moztest-unwanted-proto", UNWANTED_SOFTWARE}, // 3
{"test-unwanted-proto", UNWANTED_SOFTWARE}, // 3
{"moztest-passwordwhite-proto", CSD_WHITELIST}, // 8
{"test-passwordwhite-proto", CSD_WHITELIST}, // 8
};
NS_IMETHODIMP
@@ -344,7 +347,8 @@ nsUrlClassifierUtils::GetProvider(const nsACString& aTableName,
nsACString& aProvider) {
MutexAutoLock lock(mProviderDictLock);
nsCString* provider = nullptr;
if (StringBeginsWith(aTableName, NS_LITERAL_CSTRING("test"))) {
if (IsTestTable(aTableName)) {
aProvider = NS_LITERAL_CSTRING(TESTING_TABLE_PROVIDER_NAME);
} else if (mProviderDict.Get(aTableName, &provider)) {
aProvider = provider ? *provider : EmptyCString();
@@ -1087,3 +1091,18 @@ bool nsUrlClassifierUtils::SpecialEncode(const nsACString& url,
bool nsUrlClassifierUtils::ShouldURLEscape(const unsigned char c) const {
return c <= 32 || c == '%' || c >= 127;
}
// moztest- tables are built-in created in LookupCache, they contain hardcoded
// url entries in it. moztest tables don't support updates.
// static
bool nsUrlClassifierUtils::IsMozTestTable(const nsACString& aTableName) {
return StringBeginsWith(aTableName, NS_LITERAL_CSTRING("moztest-"));
}
// test- tables are used by testcases and can add custom test entries
// through update API.
// static
bool nsUrlClassifierUtils::IsTestTable(const nsACString& aTableName) {
return IsMozTestTable(aTableName) ||
StringBeginsWith(aTableName, NS_LITERAL_CSTRING("test"));
}