Commit a045a94c authored by Joe DeBlasio's avatar Joe DeBlasio Committed by Commit Bot

[MIX-DL] Trigger warn/block/silent blocking via feature parameters.

This CL adds feature parameters that create allowlists or blocklists for
warnings, blocking and silent blocking. Finally, it updates the
triggering logic to use those parameters.

The triggering code contains default file extensions which are used when the
feature parameter is not set. These are only used when the user
explicitly enables the feature for testing.

To make testing easier, we:
 - SILENT_BLOCK on files ending in the contrived
   ".silently_block_for_testing".
 - BLOCK files that are executables or archive types, or any download
   that's explicitly user-requested (e.g. from a context menu).
 - WARN on everything else except ".dont_warn_for_testing" files.

Bug: 960819
Change-Id: I006d4e0c3f45b64e3cd84b0ef21cc506988bf5cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984703
Commit-Queue: Joe DeBlasio <jdeblasio@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737470}
parent 26e0773b
...@@ -783,7 +783,7 @@ void ChromeDownloadManagerDelegate::GetMixedContentStatus( ...@@ -783,7 +783,7 @@ void ChromeDownloadManagerDelegate::GetMixedContentStatus(
const base::FilePath& virtual_path, const base::FilePath& virtual_path,
const GetMixedContentStatusCallback& callback) { const GetMixedContentStatusCallback& callback) {
DCHECK(download); DCHECK(download);
callback.Run(GetMixedContentStatusForDownload(virtual_path, *download)); callback.Run(GetMixedContentStatusForDownload(virtual_path, download));
} }
void ChromeDownloadManagerDelegate::NotifyExtensions( void ChromeDownloadManagerDelegate::NotifyExtensions(
......
...@@ -78,7 +78,8 @@ enum class InsecureDownloadExtensions { ...@@ -78,7 +78,8 @@ enum class InsecureDownloadExtensions {
kEPUB = 19, kEPUB = 19,
kICS = 20, kICS = 20,
kSVG = 21, kSVG = 21,
kMaxValue = kSVG, kTest = 22, // Test extensions, e.g. .silently_blocked.
kMaxValue = kTest,
}; };
struct ExtensionMapping { struct ExtensionMapping {
...@@ -99,6 +100,7 @@ static const ExtensionMapping kExtensionsToEnum[] = { ...@@ -99,6 +100,7 @@ static const ExtensionMapping kExtensionsToEnum[] = {
{"webp", InsecureDownloadExtensions::kImage}, {"webp", InsecureDownloadExtensions::kImage},
{"gz", InsecureDownloadExtensions::kArchive}, {"gz", InsecureDownloadExtensions::kArchive},
{"gzip", InsecureDownloadExtensions::kArchive},
{"zip", InsecureDownloadExtensions::kArchive}, {"zip", InsecureDownloadExtensions::kArchive},
{"bz2", InsecureDownloadExtensions::kArchive}, {"bz2", InsecureDownloadExtensions::kArchive},
{"7z", InsecureDownloadExtensions::kArchive}, {"7z", InsecureDownloadExtensions::kArchive},
...@@ -184,6 +186,10 @@ static const ExtensionMapping kExtensionsToEnum[] = { ...@@ -184,6 +186,10 @@ static const ExtensionMapping kExtensionsToEnum[] = {
{"epub", InsecureDownloadExtensions::kEPUB}, {"epub", InsecureDownloadExtensions::kEPUB},
{"ics", InsecureDownloadExtensions::kICS}, {"ics", InsecureDownloadExtensions::kICS},
{"svg", InsecureDownloadExtensions::kSVG}, {"svg", InsecureDownloadExtensions::kSVG},
{"silently_blocked_for_testing", InsecureDownloadExtensions::kTest},
{"warn_for_testing", InsecureDownloadExtensions::kTest},
{"dont_warn_for_testing", InsecureDownloadExtensions::kTest},
}; };
// Convenience function to assemble a histogram name for download blocking. // Convenience function to assemble a histogram name for download blocking.
...@@ -202,6 +208,6 @@ inline std::string GetDLBlockingHistogramName(const std::string& initiator, ...@@ -202,6 +208,6 @@ inline std::string GetDLBlockingHistogramName(const std::string& initiator,
// |item| saved to |path|. Controlled by kTreatUnsafeDownloadsAsActive. // |item| saved to |path|. Controlled by kTreatUnsafeDownloadsAsActive.
download::DownloadItem::MixedContentStatus GetMixedContentStatusForDownload( download::DownloadItem::MixedContentStatus GetMixedContentStatusForDownload(
const base::FilePath& path, const base::FilePath& path,
const download::DownloadItem& item); const download::DownloadItem* item);
#endif // CHROME_BROWSER_DOWNLOAD_MIXED_CONTENT_DOWNLOAD_BLOCKING_H_ #endif // CHROME_BROWSER_DOWNLOAD_MIXED_CONTENT_DOWNLOAD_BLOCKING_H_
...@@ -725,7 +725,6 @@ const base::Feature kAppManagement{"AppManagement", ...@@ -725,7 +725,6 @@ const base::Feature kAppManagement{"AppManagement",
// from a secure page // from a secure page
const base::Feature kTreatUnsafeDownloadsAsActive{ const base::Feature kTreatUnsafeDownloadsAsActive{
"TreatUnsafeDownloadsAsActive", base::FEATURE_DISABLED_BY_DEFAULT}; "TreatUnsafeDownloadsAsActive", base::FEATURE_DISABLED_BY_DEFAULT};
const char kTreatUnsafeDownloadsAsActiveParamName[] = "ExtensionList";
// Enables or disables the intervention that unloads ad iframes with intensive // Enables or disables the intervention that unloads ad iframes with intensive
// resource usage. // resource usage.
......
...@@ -456,8 +456,6 @@ extern const base::Feature kTLS13HardeningForLocalAnchors; ...@@ -456,8 +456,6 @@ extern const base::Feature kTLS13HardeningForLocalAnchors;
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kTreatUnsafeDownloadsAsActive; extern const base::Feature kTreatUnsafeDownloadsAsActive;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const char kTreatUnsafeDownloadsAsActiveParamName[];
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kHeavyAdIntervention; extern const base::Feature kHeavyAdIntervention;
......
...@@ -33839,6 +33839,7 @@ Called by update_gpu_driver_bug_workaround_entries.py.--> ...@@ -33839,6 +33839,7 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="19" label="kEPUB"/> <int value="19" label="kEPUB"/>
<int value="20" label="kICS"/> <int value="20" label="kICS"/>
<int value="21" label="kSVG"/> <int value="21" label="kSVG"/>
<int value="22" label="kTest"/>
</enum> </enum>
<enum name="InsecureDownloadSecurityStatus"> <enum name="InsecureDownloadSecurityStatus">
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