Commit 464a2f85 authored by Illia Klimov's avatar Illia Klimov Committed by Commit Bot

Revert "Discard wildcard patterns for plugin enterprise policies"

This reverts commit 444c343b.

Reason for revert: Flash is deprecated and should be removed.

Original change's description:
> Discard wildcard patterns for plugin enterprise policies
>
> This CL adds the possibility to throw away patterns with wildcards
> defined in the enterprise policies for a content settings
>
> Bug: 1073883
> Change-Id: I99f2d742289e77f1d00081a7cf186d4b21a91f1f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207159
> Commit-Queue: Ravjit Singh Uppal <ravjit@chromium.org>
> Reviewed-by: Balazs Engedy <engedy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#770598}

TBR=engedy@chromium.org,ravjit@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1149318
Change-Id: I1cc4691f41e5149a6419c94be756f681dcf9add9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537842Reviewed-by: default avatarIllia Klimov <elklm@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarRavjit Singh Uppal <ravjit@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Commit-Queue: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829268}
parent 4fd241c9
......@@ -259,28 +259,7 @@ INSTANTIATE_TEST_SUITE_P(ServiceWorker,
ExtensionContentSettingsApiLazyTest,
::testing::Values(ContextType::kServiceWorker));
class ExtensionContentSettingsApiTestWithStandardFeatures
: public ExtensionContentSettingsApiLazyTest {
public:
ExtensionContentSettingsApiTestWithStandardFeatures() {
scoped_feature_list_.InitAndEnableFeature(
content_settings::kDisallowWildcardsInPluginContentSettings);
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
INSTANTIATE_TEST_SUITE_P(EventPage,
ExtensionContentSettingsApiTestWithStandardFeatures,
::testing::Values(ContextType::kEventPage));
INSTANTIATE_TEST_SUITE_P(ServiceWorker,
ExtensionContentSettingsApiTestWithStandardFeatures,
::testing::Values(ContextType::kServiceWorker));
IN_PROC_BROWSER_TEST_P(ExtensionContentSettingsApiTestWithStandardFeatures,
Standard) {
IN_PROC_BROWSER_TEST_P(ExtensionContentSettingsApiLazyTest, Standard) {
CheckContentSettingsDefault();
const char kExtensionPath[] = "content_settings/standard";
......@@ -384,34 +363,12 @@ IN_PROC_BROWSER_TEST_P(ExtensionContentSettingsApiLazyTest,
"ContentSettings.ExtensionNonEmbeddedSettingSet", 2);
}
class ExtensionContentSettingsApiTestWithPluginsApiDisabled
: public ExtensionContentSettingsApiLazyTest {
public:
ExtensionContentSettingsApiTestWithPluginsApiDisabled() {
scoped_feature_list_.InitAndEnableFeature(
content_settings::kDisallowWildcardsInPluginContentSettings);
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
INSTANTIATE_TEST_SUITE_P(EventPage,
ExtensionContentSettingsApiTestWithPluginsApiDisabled,
::testing::Values(ContextType::kEventPage));
INSTANTIATE_TEST_SUITE_P(ServiceWorker,
ExtensionContentSettingsApiTestWithPluginsApiDisabled,
::testing::Values(ContextType::kServiceWorker));
IN_PROC_BROWSER_TEST_P(ExtensionContentSettingsApiTestWithPluginsApiDisabled,
PluginsApiTest) {
IN_PROC_BROWSER_TEST_P(ExtensionContentSettingsApiLazyTest, PluginsApiTest) {
constexpr char kExtensionPath[] = "content_settings/disablepluginsapi";
EXPECT_TRUE(RunLazyTest(kExtensionPath)) << message_;
}
IN_PROC_BROWSER_TEST_P(ExtensionContentSettingsApiTestWithPluginsApiDisabled,
ConsoleErrorTest) {
IN_PROC_BROWSER_TEST_P(ExtensionContentSettingsApiLazyTest, ConsoleErrorTest) {
constexpr char kExtensionPath[] = "content_settings/disablepluginsapi";
const extensions::Extension* extension =
LoadExtension(test_data_dir_.AppendASCII(kExtensionPath));
......
......@@ -26,7 +26,6 @@
#include "components/content_settings/core/browser/website_settings_info.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/content_settings/core/common/features.h"
#include "components/permissions/features.h"
#include "content/public/browser/browser_thread.h"
......@@ -105,12 +104,6 @@ void ContentSettingsStore::SetExtensionContentSetting(
ContentSettingsType type,
ContentSetting setting,
ExtensionPrefsScope scope) {
if (base::FeatureList::IsEnabled(
content_settings::kDisallowWildcardsInPluginContentSettings) &&
type == ContentSettingsType::PLUGINS &&
primary_pattern.HasHostWildcards()) {
return;
}
{
base::AutoLock lock(lock_);
OriginIdentifierValueMap* map = GetValueMap(ext_id, scope);
......
......@@ -339,38 +339,4 @@ TEST_F(ContentSettingsStoreTest, RemoveEmbedded) {
store()->RemoveObserver(&observer);
}
TEST_F(ContentSettingsStoreTest, DisallowWildcardsInFlash) {
// Enabling the feature which disallows wildcard matching for Plugin content
// settings.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
content_settings::kDisallowWildcardsInPluginContentSettings);
// Register extension.
std::string ext_id("my_extension");
RegisterExtension(ext_id);
ContentSettingsPattern primary_pattern =
ContentSettingsPattern::FromString("https://[*.]google.com");
ContentSettingsPattern secondary_pattern = ContentSettingsPattern::Wildcard();
store()->SetExtensionContentSetting(
ext_id, primary_pattern, secondary_pattern, ContentSettingsType::PLUGINS,
CONTENT_SETTING_ALLOW, kExtensionPrefsScopeRegular);
store()->SetExtensionContentSetting(
ext_id, primary_pattern, secondary_pattern, ContentSettingsType::COOKIES,
CONTENT_SETTING_ALLOW, kExtensionPrefsScopeRegular);
std::vector<content_settings::Rule> rules;
rules = GetSettingsForOneTypeFromStore(store(), ContentSettingsType::PLUGINS,
false);
// Number of rules will be zero because we tried to add a pattern with
// wildcards.
ASSERT_EQ(rules.size(), 0u);
rules = GetSettingsForOneTypeFromStore(store(), ContentSettingsType::COOKIES,
false);
// Here we will have one rule because wildcard patterns are allowed for
// ContentSettingsType::COOKIES.
ASSERT_EQ(rules.size(), 1u);
}
} // namespace extensions
......@@ -20,7 +20,6 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/browser/private_network_settings.h"
#include "components/content_settings/core/common/features.h"
#include "components/permissions/permission_manager.h"
#include "components/permissions/permission_result.h"
#include "components/policy/core/common/policy_map.h"
......@@ -314,18 +313,6 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ShouldAllowInsecurePrivateNetworkRequests) {
settings_map, GURL("http://woohoo.com/index.html")));
}
class DisallowWildcardPolicyTest : public PolicyTest {
public:
DisallowWildcardPolicyTest() {
scoped_feature_list_.InitAndEnableFeature(
content_settings::kDisallowWildcardsInPluginContentSettings);
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
class ScrollToTextFragmentPolicyTest
: public PolicyTest,
public ::testing::WithParamInterface<bool> {
......
......@@ -20,7 +20,6 @@
#include "components/content_settings/core/browser/website_settings_info.h"
#include "components/content_settings/core/browser/website_settings_registry.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
......@@ -33,8 +32,6 @@ struct PrefsForManagedContentSettingsMapEntry {
const char* pref_name;
ContentSettingsType content_type;
ContentSetting setting;
content_settings::WildcardsInPrimaryPattern wildcards_in_primary_pattern =
content_settings::WildcardsInPrimaryPattern::ALLOWED;
};
const PrefsForManagedContentSettingsMapEntry
......@@ -395,18 +392,6 @@ void PolicyProvider::GetContentSettingsFromPreferences(
continue;
}
if (base::FeatureList::IsEnabled(
content_settings::kDisallowWildcardsInPluginContentSettings) &&
kPrefsForManagedContentSettingsMap[i].wildcards_in_primary_pattern ==
WildcardsInPrimaryPattern::NOT_ALLOWED &&
pattern_pair.first.HasHostWildcards()) {
discarded_rules_value_map_[content_type].push_back(
Rule(pattern_pair.first, secondary_pattern,
base::Value(kPrefsForManagedContentSettingsMap[i].setting),
base::Time(), content_settings::SessionModel::Durable));
continue;
}
// Don't set a timestamp for policy settings.
value_map->SetValue(
pattern_pair.first, secondary_pattern, content_type, base::Time(),
......
......@@ -616,10 +616,6 @@ ContentSettingsPattern::Relation ContentSettingsPattern::Compare(
return path_relation;
}
bool ContentSettingsPattern::HasHostWildcards() const {
return parts_.has_domain_wildcard;
}
bool ContentSettingsPattern::operator==(
const ContentSettingsPattern& other) const {
return Compare(other) == IDENTITY;
......
......@@ -22,11 +22,6 @@ class PatternParser;
namespace mojom {
class ContentSettingsPatternDataView;
}
enum class WildcardsInPrimaryPattern {
NOT_ALLOWED,
ALLOWED,
};
}
// A pattern used in content setting rules. See |IsValid| for a description of
......@@ -224,9 +219,6 @@ class ContentSettingsPattern {
// |Relation| of the two patterns.
Relation Compare(const ContentSettingsPattern& other) const;
// True if the host in the pattern has a wildcard.
bool HasHostWildcards() const;
// Returns true if the pattern and the |other| pattern are identical.
bool operator==(const ContentSettingsPattern& other) const;
......
......@@ -845,22 +845,3 @@ TEST(ContentSettingsPatternTest, FileSchemeHasPath) {
EXPECT_TRUE(Pattern("file:///foo/bar/").HasPath());
EXPECT_TRUE(Pattern("file:///foo/bar/test.html").HasPath());
}
TEST(ContentSettingsPatternTest, PatternHasWildcards) {
// scheme wildcard are allowed
EXPECT_FALSE(Pattern("mail.google.com:443/home").HasHostWildcards());
EXPECT_FALSE(Pattern("*://mail.google.com:443/home").HasHostWildcards());
// domain wildcard
EXPECT_TRUE(Pattern("https://[*.]google.com:443/home").HasHostWildcards());
// path wildcard are allowed
EXPECT_FALSE(Pattern("https://mail.google.com:443/*").HasHostWildcards());
// port wildcards are allowed
EXPECT_FALSE(Pattern("https://mail.google.com/home").HasHostWildcards());
EXPECT_FALSE(Pattern("https://mail.google.com:*/home").HasHostWildcards());
// full wildcard pattern
EXPECT_TRUE(Pattern("*").HasHostWildcards());
// full wildcard pattern
EXPECT_TRUE(ContentSettingsPattern::Wildcard().HasHostWildcards());
// no wildcards
EXPECT_FALSE(Pattern("https://mail.google.com:443/home").HasHostWildcards());
}
......@@ -15,8 +15,4 @@ const base::Feature kImprovedCookieControls{"ImprovedCookieControls",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_IOS)
const base::Feature kDisallowWildcardsInPluginContentSettings{
"DisallowWildcardsInPluginContentSettings",
base::FEATURE_ENABLED_BY_DEFAULT};
} // namespace content_settings
......@@ -20,10 +20,6 @@ COMPONENT_EXPORT(CONTENT_SETTINGS_FEATURES)
extern const base::Feature kImprovedCookieControls;
#endif
// Feature to disallow wildcard pattern matching for plugin content settings
COMPONENT_EXPORT(CONTENT_SETTINGS_FEATURES)
extern const base::Feature kDisallowWildcardsInPluginContentSettings;
} // namespace content_settings
#endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_FEATURES_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