Commit 7199db19 authored by Varun Khaneja's avatar Varun Khaneja Committed by Commit Bot

Setup code for syncing the high confidence allowlist

The list is currently not being requested because the backend doesn't
support it yet.

Bug: 966646, 963165
Change-Id: I8533d5da79c8e88a5d15285c3ee3610551d47bc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1650510
Commit-Queue: Varun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarCarlos IL <carlosil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670311}
parent e32d705e
......@@ -87,6 +87,7 @@ std::string GetThreatTypeStringForInterstitial(
case safe_browsing::SB_THREAT_TYPE_SUSPICIOUS_SITE:
case safe_browsing::SB_THREAT_TYPE_ENTERPRISE_PASSWORD_REUSE:
case safe_browsing::SB_THREAT_TYPE_APK_DOWNLOAD:
case safe_browsing::SB_THREAT_TYPE_HIGH_CONFIDENCE_ALLOWLIST:
NOTREACHED();
break;
}
......
......@@ -212,6 +212,7 @@ SecurityStateTabHelper::GetMaliciousContentStatus() const {
case safe_browsing::SB_THREAT_TYPE_BLOCKED_AD_POPUP:
case safe_browsing::SB_THREAT_TYPE_SUSPICIOUS_SITE:
case safe_browsing::SB_THREAT_TYPE_APK_DOWNLOAD:
case safe_browsing::SB_THREAT_TYPE_HIGH_CONFIDENCE_ALLOWLIST:
// These threat types are not currently associated with
// interstitials, and thus resources with these threat types are
// not ever whitelisted or pending whitelisting.
......
......@@ -39,10 +39,6 @@ source_set("safe_browsing") {
deps = [
":features",
":ping_manager",
# TODO(vakh): This is here temporarily until we start actually using the
# proto. If it isn't a DEP, it isn't built.
":realtimeapi_proto",
"//base:base",
"//base:i18n",
"//components/safe_browsing/common:common",
......
......@@ -114,6 +114,7 @@ ClientSafeBrowsingReportRequest::ReportType GetReportTypeFromSBThreatType(
case SB_THREAT_TYPE_API_ABUSE:
case SB_THREAT_TYPE_SUBRESOURCE_FILTER:
case SB_THREAT_TYPE_CSD_WHITELIST:
case SB_THREAT_TYPE_HIGH_CONFIDENCE_ALLOWLIST:
case DEPRECATED_SB_THREAT_TYPE_URL_PASSWORD_PROTECTION_PHISHING:
// Gated by SafeBrowsingBlockingPage::ShouldReportThreatDetails.
NOTREACHED() << "We should not send report for threat type: "
......
......@@ -168,6 +168,7 @@ static_library("v4_local_database_manager") {
":v4_update_protocol_manager",
"//base",
"//components/safe_browsing:webui_proto",
"//components/safe_browsing/realtime:policy_engine",
"//content/public/browser",
"//crypto",
"//net",
......
......@@ -20,6 +20,7 @@
#include "base/strings/string_tokenizer.h"
#include "base/task/post_task.h"
#include "components/safe_browsing/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/realtime/policy_engine.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/sha2.h"
......@@ -63,6 +64,8 @@ ListInfos GetListInfos() {
#endif
const bool kSyncAlways = true;
const bool kSyncNever = false;
const bool kSyncRealTimeLookupList =
RealTimePolicyEngine::CanFetchAllowlist();
return ListInfos({
ListInfo(kSyncAlways, "IpMalware.store", GetIpMalwareId(),
SB_THREAT_TYPE_UNUSED),
......@@ -92,6 +95,9 @@ ListInfos GetListInfos() {
ListInfo(kSyncOnlyOnChromeBuilds, "UrlSuspiciousSite.store",
GetUrlSuspiciousSiteId(), SB_THREAT_TYPE_SUSPICIOUS_SITE),
ListInfo(kSyncNever, "", GetChromeUrlApiId(), SB_THREAT_TYPE_API_ABUSE),
ListInfo(kSyncRealTimeLookupList, "UrlHighConfidenceAllowlist.store",
GetUrlHighConfidenceAllowlistId(),
SB_THREAT_TYPE_HIGH_CONFIDENCE_ALLOWLIST),
});
// NOTE(vakh): IMPORTANT: Please make sure that the server already supports
// any list before adding it to this list otherwise the prefix updates break
......
......@@ -157,6 +157,11 @@ ListIdentifier GetUrlCsdWhitelistId() {
return ListIdentifier(GetCurrentPlatformType(), URL, CSD_WHITELIST);
}
ListIdentifier GetUrlHighConfidenceAllowlistId() {
return ListIdentifier(GetCurrentPlatformType(), URL,
HIGH_CONFIDENCE_ALLOWLIST);
}
ListIdentifier GetUrlMalwareId() {
return ListIdentifier(GetCurrentPlatformType(), URL, MALWARE_THREAT);
}
......
......@@ -163,6 +163,9 @@ enum SBThreatType {
// Off-market APK file downloaded, which could be potentially dangerous.
SB_THREAT_TYPE_APK_DOWNLOAD,
// Match found in the local high-confidence allowlist.
SB_THREAT_TYPE_HIGH_CONFIDENCE_ALLOWLIST,
};
using SBThreatTypeSet = base::flat_set<SBThreatType>;
......@@ -219,6 +222,7 @@ ListIdentifier GetIpMalwareId();
ListIdentifier GetUrlBillingId();
ListIdentifier GetUrlCsdDownloadWhitelistId();
ListIdentifier GetUrlCsdWhitelistId();
ListIdentifier GetUrlHighConfidenceAllowlistId();
ListIdentifier GetUrlMalBinId();
ListIdentifier GetUrlMalwareId();
ListIdentifier GetUrlSocEngId();
......
......@@ -51,6 +51,10 @@ const base::Feature kPasswordProtectionForSignedInUsers{
"SafeBrowsingPasswordProtectionForSignedInUsers",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kRealTimeUrlLookupFetchAllowlist{
"SafeBrowsingRealTimeUrlLookupFetchAllowlist",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSuspiciousSiteTriggerQuotaFeature{
"SafeBrowsingSuspiciousSiteTriggerQuota", base::FEATURE_ENABLED_BY_DEFAULT};
......@@ -87,6 +91,7 @@ constexpr struct {
{&kCommittedSBInterstitials, true},
{&kForceUseAPDownloadProtection, false},
{&kPasswordProtectionForSignedInUsers, true},
{&kRealTimeUrlLookupFetchAllowlist, true},
{&kSuspiciousSiteTriggerQuotaFeature, true},
{&kThreatDomDetailsTagAndAttributeFeature, false},
{&kTriggerThrottlerDailyQuotaFeature, false},
......
......@@ -49,6 +49,10 @@ extern const base::Feature kPasswordProtectionForSignedInUsers;
// Controls the daily quota for the suspicious site trigger.
extern const base::Feature kSuspiciousSiteTriggerQuotaFeature;
// Controls whether the high confidence allowlist for real time URL lookup be
// fetched.
extern const base::Feature kRealTimeUrlLookupFetchAllowlist;
// Specifies which non-resource HTML Elements to collect based on their tag and
// attributes. It's a single param containing a comma-separated list of pairs.
// For example: "tag1,id,tag1,height,tag2,foo" - this will collect elements with
......
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
static_library("policy_engine") {
sources = [
"policy_engine.cc",
"policy_engine.h",
]
deps = [
"//base:base",
"//components/safe_browsing:features",
"//components/safe_browsing:realtimeapi_proto",
]
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/safe_browsing/realtime/policy_engine.h"
#include "base/feature_list.h"
#include "components/safe_browsing/features.h"
namespace safe_browsing {
// static
bool RealTimePolicyEngine::CanFetchAllowlist() {
return base::FeatureList::IsEnabled(kRealTimeUrlLookupFetchAllowlist);
}
} // namespace safe_browsing
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SAFE_BROWSING_REALTIME_POLICY_ENGINE_H_
#define COMPONENTS_SAFE_BROWSING_REALTIME_POLICY_ENGINE_H_
namespace safe_browsing {
// This class implements the logic to decide whether the real time lookup
// feature is enabled for a given user/profile.
class RealTimePolicyEngine {
private:
RealTimePolicyEngine() = delete;
~RealTimePolicyEngine() = delete;
public:
// Can the high confidence allowlist be sync'd?
static bool CanFetchAllowlist();
}; // class RealTimePolicyEngine
} // namespace safe_browsing
#endif // COMPONENTS_SAFE_BROWSING_REALTIME_POLICY_ENGINE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment