Commit ec6c7d8f authored by Yusuf Ozuysal's avatar Yusuf Ozuysal Committed by Chromium LUCI CQ

Revert "[CodeInclusion] Improve terminology in subresource_filter"

This reverts commit a2873758.

Reason for revert: Broke compile on https://ci.chromium.org/ui/p/chromium/builders/ci/Cast%20Audio%20Linux/95633/overview

Original change's description:
> [CodeInclusion] Improve terminology in subresource_filter
>
> Removing all but one case of master/slave/whitelist/blacklist in
> subresource_filter directories. The remaining case involves a change to
> safe browsing.
>
>
> Bug: 1160252
> Change-Id: I6aba50a767072ef4a9abb0bacf463712a27f7058
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597012
> Reviewed-by: Charlie Harrison <csharrison@chromium.org>
> Reviewed-by: Reilly Grant <reillyg@chromium.org>
> Commit-Queue: Josh Karlin <jkarlin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#842231}

TBR=reillyg@chromium.org,jkarlin@chromium.org,csharrison@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Ie3140e9aae06c95e265a8367d87975f9ed0eb005
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1160252
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622665Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Yusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842233}
parent 0e3b40e1
......@@ -370,7 +370,7 @@ IN_PROC_BROWSER_TEST_F(SubresourceFilterBrowserTest,
proto::UrlRule rule = testing::CreateSuffixRule("included_script.html");
proto::UrlRule allowlist_rule = testing::CreateSuffixRule(kAllowlistedDomain);
allowlist_rule.set_anchor_right(proto::ANCHOR_TYPE_NONE);
allowlist_rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
allowlist_rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
ASSERT_NO_FATAL_FAILURE(SetRulesetWithRules({rule, allowlist_rule}));
ui_test_utils::NavigateToURL(browser(), url);
......
......@@ -180,7 +180,7 @@ scoped_refptr<ConfigurationList> GetAndSetActivateConfigurations(
// Feature and variation parameter definitions -------------------------------
// The primary toggle to enable/disable the Safe Browsing Subresource Filter.
// The master toggle to enable/disable the Safe Browsing Subresource Filter.
extern const base::Feature kSafeBrowsingSubresourceFilter;
// Enables the blocking of ads on sites that are abusive.
......
......@@ -74,7 +74,7 @@ bool RulesetIndexer::AddUrlRule(const proto::UrlRule& rule) {
if (!offset.o)
return false;
if (rule.semantics() == proto::RULE_SEMANTICS_BLOCKLIST) {
if (rule.semantics() == proto::RULE_SEMANTICS_BLACKLIST) {
blocklist_.IndexUrlRule(offset);
} else {
const auto* flat_rule = flatbuffers::GetTemporaryPointer(builder_, offset);
......@@ -150,7 +150,7 @@ LoadPolicy IndexedRulesetMatcher::GetLoadPolicyForResourceLoad(
if (!rule)
return LoadPolicy::ALLOW;
return rule->options() & url_pattern_index::flat::OptionFlag_IS_ALLOWLIST
return rule->options() & url_pattern_index::flat::OptionFlag_IS_WHITELIST
? LoadPolicy::EXPLICITLY_ALLOW
: LoadPolicy::DISALLOW;
}
......
......@@ -72,14 +72,14 @@ class SubresourceFilterIndexedRulesetTest : public ::testing::Test {
bool AddSimpleAllowlistRule(base::StringPiece url_pattern) {
auto rule = MakeUrlRule(UrlPattern(url_pattern, testing::kSubstring));
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
return AddUrlRule(rule);
}
bool AddSimpleAllowlistRule(base::StringPiece url_pattern,
int32_t activation_types) {
auto rule = MakeUrlRule(UrlPattern(url_pattern, testing::kSubstring));
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
rule.clear_element_types();
rule.set_activation_types(activation_types);
return AddUrlRule(rule);
......
......@@ -27,7 +27,7 @@ proto::UrlRule CreateSubstringRule(base::StringPiece substring) {
proto::UrlRule CreateSuffixRule(base::StringPiece suffix) {
proto::UrlRule rule;
rule.set_semantics(proto::RULE_SEMANTICS_BLOCKLIST);
rule.set_semantics(proto::RULE_SEMANTICS_BLACKLIST);
rule.set_source_type(proto::SOURCE_TYPE_ANY);
rule.set_element_types(proto::ELEMENT_TYPE_ALL);
rule.set_url_pattern_type(proto::URL_PATTERN_TYPE_SUBSTRING);
......@@ -39,7 +39,7 @@ proto::UrlRule CreateSuffixRule(base::StringPiece suffix) {
proto::UrlRule CreateAllowlistSuffixRule(base::StringPiece suffix) {
proto::UrlRule rule;
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
rule.set_source_type(proto::SOURCE_TYPE_ANY);
rule.set_element_types(proto::ELEMENT_TYPE_ALL);
rule.set_url_pattern_type(proto::URL_PATTERN_TYPE_SUBSTRING);
......@@ -54,7 +54,7 @@ proto::UrlRule CreateAllowlistRuleForDocument(
int32_t activation_types,
std::vector<std::string> domains) {
proto::UrlRule rule;
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
rule.set_source_type(proto::SOURCE_TYPE_ANY);
rule.set_activation_types(activation_types);
......
......@@ -55,7 +55,7 @@ class UnindexedRulesetTestBuilder {
bool is_allowlist = false) {
auto rule = testing::MakeUrlRule(url_pattern);
if (is_allowlist)
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
rule.set_source_type(source_type);
url_rules_.push_back(rule);
......
......@@ -144,7 +144,7 @@ const url_pattern_index::flat::UrlRule* FilterTool::MatchImpl(
ParseRequestUrl(url), ParseType(type));
*blocked = rule && !(rule->options() &
url_pattern_index::flat::OptionFlag_IS_ALLOWLIST);
url_pattern_index::flat::OptionFlag_IS_WHITELIST);
return rule;
}
......
......@@ -81,8 +81,8 @@ url_pattern_index::proto::UrlRule UrlRule::ToProtobuf() const {
url_pattern_index::proto::UrlRule result;
result.set_semantics(
is_allowlist ? url_pattern_index::proto::RULE_SEMANTICS_ALLOWLIST
: url_pattern_index::proto::RULE_SEMANTICS_BLOCKLIST);
is_allowlist ? url_pattern_index::proto::RULE_SEMANTICS_WHITELIST
: url_pattern_index::proto::RULE_SEMANTICS_BLACKLIST);
switch (is_third_party) {
case TriState::DONT_CARE:
result.set_source_type(url_pattern_index::proto::SOURCE_TYPE_ANY);
......@@ -151,8 +151,8 @@ url_pattern_index::proto::CssRule CssRule::ToProtobuf() const {
url_pattern_index::proto::CssRule result;
result.set_semantics(
is_allowlist ? url_pattern_index::proto::RULE_SEMANTICS_ALLOWLIST
: url_pattern_index::proto::RULE_SEMANTICS_BLOCKLIST);
is_allowlist ? url_pattern_index::proto::RULE_SEMANTICS_WHITELIST
: url_pattern_index::proto::RULE_SEMANTICS_BLACKLIST);
for (const std::string& domain : domains) {
url_pattern_index::proto::DomainListItem* list_item = result.add_domains();
......@@ -206,9 +206,9 @@ std::string ToString(const url_pattern_index::proto::UrlRule& rule) {
std::string result;
switch (rule.semantics()) {
case url_pattern_index::proto::RULE_SEMANTICS_BLOCKLIST:
case url_pattern_index::proto::RULE_SEMANTICS_BLACKLIST:
break;
case url_pattern_index::proto::RULE_SEMANTICS_ALLOWLIST:
case url_pattern_index::proto::RULE_SEMANTICS_WHITELIST:
result += "@@";
break;
default:
......@@ -327,10 +327,10 @@ std::string ToString(const url_pattern_index::proto::CssRule& rule) {
DomainListJoin(rule.domains(), ',', &result);
switch (rule.semantics()) {
case url_pattern_index::proto::RULE_SEMANTICS_BLOCKLIST:
case url_pattern_index::proto::RULE_SEMANTICS_BLACKLIST:
result += "##";
break;
case url_pattern_index::proto::RULE_SEMANTICS_ALLOWLIST:
case url_pattern_index::proto::RULE_SEMANTICS_WHITELIST:
result += "#@#";
break;
default:
......
......@@ -25,7 +25,7 @@ enum AnchorType : ubyte {
// url_pattern_index::proto::UrlRule, but here, they are represented as flags
// of the same bitmask to allow for compact storage.
enum OptionFlag : ubyte (bit_flags) {
IS_ALLOWLIST,
IS_WHITELIST,
APPLIES_TO_FIRST_PARTY,
APPLIES_TO_THIRD_PARTY,
IS_CASE_INSENSITIVE,
......
......@@ -96,10 +96,10 @@ enum RuleSemantics {
// Matching subresource requests should be aborted, matching elements should
// be hidden.
RULE_SEMANTICS_BLOCKLIST = 1;
// If the rule matches, it suppresses any matching RULE_SEMANTICS_BLOCKLIST
RULE_SEMANTICS_BLACKLIST = 1;
// If the rule matches, it suppresses any matching RULE_SEMANTICS_BLACKLIST
// rule.
RULE_SEMANTICS_ALLOWLIST = 2;
RULE_SEMANTICS_WHITELIST = 2;
}
// The type of relation between the source of the requested subresource and that
......
......@@ -241,9 +241,9 @@ class UrlRuleFlatBufferConverter {
static_assert(flat::OptionFlag_ANY <= std::numeric_limits<uint8_t>::max(),
"Option flags can not be stored in uint8_t.");
if (rule_.semantics() == proto::RULE_SEMANTICS_ALLOWLIST) {
options_ |= flat::OptionFlag_IS_ALLOWLIST;
} else if (rule_.semantics() != proto::RULE_SEMANTICS_BLOCKLIST) {
if (rule_.semantics() == proto::RULE_SEMANTICS_WHITELIST) {
options_ |= flat::OptionFlag_IS_WHITELIST;
} else if (rule_.semantics() != proto::RULE_SEMANTICS_BLACKLIST) {
return false; // Unsupported semantics.
}
......
......@@ -604,7 +604,7 @@ TEST_F(UrlPatternIndexTest, OneRuleWithActivationTypes) {
<< "; ActivationType: " << static_cast<int>(test_case.activation_type));
auto rule = MakeUrlRule(UrlPattern(test_case.url_pattern, kSubstring));
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
rule.clear_element_types();
rule.set_activation_types(test_case.activation_types);
ASSERT_TRUE(AddUrlRule(rule));
......@@ -626,7 +626,7 @@ TEST_F(UrlPatternIndexTest, OneRuleWithActivationTypes) {
TEST_F(UrlPatternIndexTest, OneRuleWithElementAndActivationTypes) {
auto rule = MakeUrlRule(UrlPattern("allow.ex.com", kSubstring));
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
rule.set_element_types(testing::kSubdocument);
rule.set_activation_types(kDocument);
ASSERT_TRUE(AddUrlRule(rule));
......@@ -811,7 +811,7 @@ TEST_F(UrlPatternIndexTest, RulesWithSupportedAndUnsupportedTypes) {
for (const auto& rule_data : kRules) {
auto rule = MakeUrlRule(UrlPattern("example.com", kSubstring));
rule.set_semantics(proto::RULE_SEMANTICS_ALLOWLIST);
rule.set_semantics(proto::RULE_SEMANTICS_WHITELIST);
rule.set_element_types(rule_data.element_types);
rule.set_activation_types(rule_data.activation_types);
EXPECT_TRUE(AddUrlRule(rule))
......
......@@ -15,7 +15,7 @@ namespace testing {
proto::UrlRule MakeUrlRule(const UrlPattern& url_pattern) {
proto::UrlRule rule;
rule.set_semantics(proto::RULE_SEMANTICS_BLOCKLIST);
rule.set_semantics(proto::RULE_SEMANTICS_BLACKLIST);
rule.set_source_type(proto::SOURCE_TYPE_ANY);
rule.set_element_types(kAllElementTypes);
......
......@@ -153,7 +153,7 @@ std::string DomainOptionsToString(
std::string FlatUrlRuleToFilterlistString(const flat::UrlRule* flat_rule) {
std::string out;
if (flat_rule->options() & url_pattern_index::flat::OptionFlag_IS_ALLOWLIST)
if (flat_rule->options() & url_pattern_index::flat::OptionFlag_IS_WHITELIST)
out += "@@";
out += AnchorToString(flat_rule->anchor_left());
......
......@@ -79,37 +79,37 @@ class UrlRuleUtilTest : public ::testing::Test {
DISALLOW_COPY_AND_ASSIGN(UrlRuleUtilTest);
};
TEST_F(UrlRuleUtilTest, Blocklist) {
TEST_F(UrlRuleUtilTest, Blacklist) {
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com/", FlatUrlRuleToFilterlistString(flat_rule));
}
TEST_F(UrlRuleUtilTest, Allowlist) {
TEST_F(UrlRuleUtilTest, Whitelist) {
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_ALLOWLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_WHITELIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("@@example.com/", FlatUrlRuleToFilterlistString(flat_rule));
}
TEST_F(UrlRuleUtilTest, LeftAnchor) {
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST,
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST,
UrlPattern("example.com/", proto::ANCHOR_TYPE_NONE,
proto::ANCHOR_TYPE_NONE),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com/", FlatUrlRuleToFilterlistString(flat_rule));
flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST,
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST,
UrlPattern("example.com/", proto::ANCHOR_TYPE_BOUNDARY,
proto::ANCHOR_TYPE_NONE),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("|example.com/", FlatUrlRuleToFilterlistString(flat_rule));
flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST,
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST,
UrlPattern("example.com/", proto::ANCHOR_TYPE_SUBDOMAIN,
proto::ANCHOR_TYPE_NONE),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
......@@ -118,14 +118,14 @@ TEST_F(UrlRuleUtilTest, LeftAnchor) {
TEST_F(UrlRuleUtilTest, RightAnchor) {
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST,
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST,
UrlPattern("example.com", proto::ANCHOR_TYPE_NONE,
proto::ANCHOR_TYPE_NONE),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com", FlatUrlRuleToFilterlistString(flat_rule));
flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST,
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST,
UrlPattern("example.com", proto::ANCHOR_TYPE_NONE,
proto::ANCHOR_TYPE_BOUNDARY),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
......@@ -134,7 +134,7 @@ TEST_F(UrlRuleUtilTest, RightAnchor) {
TEST_F(UrlRuleUtilTest, BothSidesAnchored) {
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST,
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST,
UrlPattern("example.com", proto::ANCHOR_TYPE_SUBDOMAIN,
proto::ANCHOR_TYPE_BOUNDARY),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
......@@ -143,13 +143,13 @@ TEST_F(UrlRuleUtilTest, BothSidesAnchored) {
TEST_F(UrlRuleUtilTest, NonRegex) {
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("/foo/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("/foo/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("/foo/*", FlatUrlRuleToFilterlistString(flat_rule));
// Show that allowlist rules work too.
// Show that whitelist rules work too.
flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_ALLOWLIST, UrlPattern("/foo/"),
MakeProtoRule(proto::RULE_SEMANTICS_WHITELIST, UrlPattern("/foo/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("@@/foo/*", FlatUrlRuleToFilterlistString(flat_rule));
......@@ -159,13 +159,13 @@ TEST_F(UrlRuleUtilTest, NonRegex) {
TEST_F(UrlRuleUtilTest, Party) {
const flat::UrlRule* flat_rule = MakeFlatRule(MakeProtoRule(
proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_THIRD_PARTY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com/$third-party",
FlatUrlRuleToFilterlistString(flat_rule));
flat_rule = MakeFlatRule(MakeProtoRule(
proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_FIRST_PARTY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com/$~third-party",
FlatUrlRuleToFilterlistString(flat_rule));
......@@ -173,7 +173,7 @@ TEST_F(UrlRuleUtilTest, Party) {
TEST_F(UrlRuleUtilTest, MultipleOptions) {
const flat::UrlRule* flat_rule = MakeFlatRule(MakeProtoRule(
proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_THIRD_PARTY, proto::ELEMENT_TYPE_SCRIPT, {}));
EXPECT_EQ("example.com/$third-party,script",
FlatUrlRuleToFilterlistString(flat_rule));
......@@ -182,20 +182,20 @@ TEST_F(UrlRuleUtilTest, MultipleOptions) {
TEST_F(UrlRuleUtilTest, ElementType) {
// Test a single type.
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_SCRIPT, {}));
EXPECT_EQ("example.com/$script", FlatUrlRuleToFilterlistString(flat_rule));
// Test blocking every type.
flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com/", FlatUrlRuleToFilterlistString(flat_rule));
// Block everything except other. This test will need to be updated as
// proto::ElementType is changed.
flat_rule = MakeFlatRule(MakeProtoRule(
proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY,
static_cast<proto::ElementType>(proto::ELEMENT_TYPE_ALL - 1), {}));
std::string expected =
......@@ -209,13 +209,13 @@ TEST_F(UrlRuleUtilTest, ElementType) {
TEST_F(UrlRuleUtilTest, ActivationType) {
// Test with no activiation type.
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com/", FlatUrlRuleToFilterlistString(flat_rule));
// Test with a document activation type.
auto proto_rule =
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {});
proto_rule.set_activation_types(proto::ACTIVATION_TYPE_DOCUMENT);
flat_rule = MakeFlatRule(proto_rule);
......@@ -232,13 +232,13 @@ TEST_F(UrlRuleUtilTest, ActivationType) {
TEST_F(UrlRuleUtilTest, DomainList) {
// Test with no domains set.
const flat::UrlRule* flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL, {}));
EXPECT_EQ("example.com/", FlatUrlRuleToFilterlistString(flat_rule));
// Test with domains set.
flat_rule = MakeFlatRule(
MakeProtoRule(proto::RULE_SEMANTICS_BLOCKLIST, UrlPattern("example.com/"),
MakeProtoRule(proto::RULE_SEMANTICS_BLACKLIST, UrlPattern("example.com/"),
proto::SOURCE_TYPE_ANY, proto::ELEMENT_TYPE_ALL,
{"foo.example.com", "~bar.example.com"}));
EXPECT_EQ("example.com/$domain=foo.example.com|~bar.example.com",
......
......@@ -407,13 +407,13 @@ class ProtoToJSONRuleConverter {
dnr_api::RuleActionType action_type = dnr_api::RULE_ACTION_TYPE_NONE;
CHECK(!is_allow_all_requests_rule_ ||
input_rule_.semantics() == proto::RULE_SEMANTICS_ALLOWLIST);
input_rule_.semantics() == proto::RULE_SEMANTICS_WHITELIST);
switch (input_rule_.semantics()) {
case proto::RULE_SEMANTICS_BLOCKLIST:
case proto::RULE_SEMANTICS_BLACKLIST:
action_type = dnr_api::RULE_ACTION_TYPE_BLOCK;
break;
case proto::RULE_SEMANTICS_ALLOWLIST:
case proto::RULE_SEMANTICS_WHITELIST:
if (is_allow_all_requests_rule_)
action_type = dnr_api::RULE_ACTION_TYPE_ALLOWALLREQUESTS;
else
......
......@@ -452,7 +452,7 @@ TEST_F(FlatRulesetIndexerTest, MultipleRules) {
// Allow rules.
rules_to_index.push_back(CreateIndexedRule(
17, kMinValidPriority, flat_rule::OptionFlag_IS_ALLOWLIST,
17, kMinValidPriority, flat_rule::OptionFlag_IS_WHITELIST,
flat_rule::ElementType_PING | flat_rule::ElementType_SCRIPT,
flat_rule::ActivationType_NONE, flat_rule::UrlPatternType_SUBSTRING,
flat_rule::AnchorType_SUBDOMAIN, flat_rule::AnchorType_NONE,
......@@ -460,7 +460,7 @@ TEST_F(FlatRulesetIndexerTest, MultipleRules) {
dnr_api::RULE_ACTION_TYPE_ALLOW, nullptr, base::nullopt, {}, {}));
rules_to_index.push_back(CreateIndexedRule(
16, kMinValidPriority,
flat_rule::OptionFlag_IS_ALLOWLIST |
flat_rule::OptionFlag_IS_WHITELIST |
flat_rule::OptionFlag_IS_CASE_INSENSITIVE,
flat_rule::ElementType_IMAGE, flat_rule::ActivationType_NONE,
flat_rule::UrlPatternType_SUBSTRING, flat_rule::AnchorType_NONE,
......
......@@ -143,7 +143,7 @@ uint8_t GetOptionsMask(const dnr_api::Rule& parsed_rule) {
uint8_t mask = flat_rule::OptionFlag_NONE;
if (parsed_rule.action.type == dnr_api::RULE_ACTION_TYPE_ALLOW)
mask |= flat_rule::OptionFlag_IS_ALLOWLIST;
mask |= flat_rule::OptionFlag_IS_WHITELIST;
if (!IsCaseSensitive(parsed_rule))
mask |= flat_rule::OptionFlag_IS_CASE_INSENSITIVE;
......
......@@ -142,11 +142,11 @@ TEST_F(IndexedRuleTest, OptionsParsing) {
flat_rule::OptionFlag_APPLIES_TO_FIRST_PARTY},
{dnr_api::DOMAIN_TYPE_FIRSTPARTY, dnr_api::RULE_ACTION_TYPE_ALLOW,
std::make_unique<bool>(true),
flat_rule::OptionFlag_IS_ALLOWLIST |
flat_rule::OptionFlag_IS_WHITELIST |
flat_rule::OptionFlag_APPLIES_TO_FIRST_PARTY},
{dnr_api::DOMAIN_TYPE_FIRSTPARTY, dnr_api::RULE_ACTION_TYPE_ALLOW,
std::make_unique<bool>(false),
flat_rule::OptionFlag_IS_ALLOWLIST |
flat_rule::OptionFlag_IS_WHITELIST |
flat_rule::OptionFlag_APPLIES_TO_FIRST_PARTY |
flat_rule::OptionFlag_IS_CASE_INSENSITIVE},
};
......
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