Commit 81d2d7ce authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Change MaybeOverrideDlpScanResult to MaybeOverrideScanResult

This function can be called when the "malware" tag is present on a scan
request since POTENTIALLY_UNWANTED and UNCOMMON don't exempt from a
deep malware scan. This also makes the function tolerant of all results
which means the UX won't block since the callback will always run.

Bug: 1132981
Change-Id: Ie8836f73ccbcf7af103560d3b9d5291b0709a4f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436416
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812258}
parent bad5128d
...@@ -50,53 +50,52 @@ namespace { ...@@ -50,53 +50,52 @@ namespace {
// This function is called when the result of malware scanning is already known // This function is called when the result of malware scanning is already known
// (via |reason|), but we still want to perform DLP scanning. // (via |reason|), but we still want to perform DLP scanning.
void MaybeOverrideDlpScanResult(DownloadCheckResultReason reason, void MaybeOverrideScanResult(DownloadCheckResultReason reason,
CheckDownloadRepeatingCallback callback, CheckDownloadRepeatingCallback callback,
DownloadCheckResult deep_scan_result) { DownloadCheckResult deep_scan_result) {
if (reason == REASON_DOWNLOAD_DANGEROUS || switch (deep_scan_result) {
reason == REASON_DOWNLOAD_DANGEROUS_HOST || // These results are more dangerous or equivalent to any |reason|, so they
reason == REASON_DOWNLOAD_POTENTIALLY_UNWANTED || // take precedence.
reason == REASON_DOWNLOAD_UNCOMMON) { case DownloadCheckResult::DANGEROUS_HOST:
// Don't let safe deep scanning results override these previous case DownloadCheckResult::DANGEROUS:
// dangerous reasons. callback.Run(deep_scan_result);
switch (deep_scan_result) { return;
case DownloadCheckResult::UNKNOWN:
case DownloadCheckResult::SENSITIVE_CONTENT_WARNING: // These deep scanning results don't override any dangerous reasons.
case DownloadCheckResult::DEEP_SCANNED_SAFE: case DownloadCheckResult::UNKNOWN:
if (reason == REASON_DOWNLOAD_DANGEROUS) case DownloadCheckResult::SENSITIVE_CONTENT_WARNING:
callback.Run(DownloadCheckResult::DANGEROUS); case DownloadCheckResult::DEEP_SCANNED_SAFE:
else if (reason == REASON_DOWNLOAD_DANGEROUS_HOST) case DownloadCheckResult::SAFE:
callback.Run(DownloadCheckResult::DANGEROUS_HOST); case DownloadCheckResult::PROMPT_FOR_SCANNING:
else if (reason == REASON_DOWNLOAD_POTENTIALLY_UNWANTED) case DownloadCheckResult::POTENTIALLY_UNWANTED:
callback.Run(DownloadCheckResult::POTENTIALLY_UNWANTED); case DownloadCheckResult::UNCOMMON:
else if (reason == REASON_DOWNLOAD_DANGEROUS)
callback.Run(DownloadCheckResult::UNCOMMON); callback.Run(DownloadCheckResult::DANGEROUS);
return; else if (reason == REASON_DOWNLOAD_DANGEROUS_HOST)
callback.Run(DownloadCheckResult::DANGEROUS_HOST);
case DownloadCheckResult::ASYNC_SCANNING: else if (reason == REASON_DOWNLOAD_POTENTIALLY_UNWANTED)
case DownloadCheckResult::BLOCKED_PASSWORD_PROTECTED: callback.Run(DownloadCheckResult::POTENTIALLY_UNWANTED);
case DownloadCheckResult::BLOCKED_TOO_LARGE: else if (reason == REASON_DOWNLOAD_UNCOMMON)
case DownloadCheckResult::SENSITIVE_CONTENT_BLOCK: callback.Run(DownloadCheckResult::UNCOMMON);
case DownloadCheckResult::BLOCKED_UNSUPPORTED_FILE_TYPE: else
callback.Run(deep_scan_result); callback.Run(deep_scan_result);
return; return;
case DownloadCheckResult::SAFE: // These other results have precedence over dangerous ones because they
case DownloadCheckResult::UNCOMMON: // indicate the scan is not done, that the file is blocked for another
case DownloadCheckResult::DANGEROUS_HOST: // reason, or that the file is allowed by policy.
case DownloadCheckResult::WHITELISTED_BY_POLICY: case DownloadCheckResult::ASYNC_SCANNING:
case DownloadCheckResult::PROMPT_FOR_SCANNING: case DownloadCheckResult::BLOCKED_PASSWORD_PROTECTED:
case DownloadCheckResult::DANGEROUS: case DownloadCheckResult::BLOCKED_TOO_LARGE:
case DownloadCheckResult::POTENTIALLY_UNWANTED: case DownloadCheckResult::SENSITIVE_CONTENT_BLOCK:
NOTREACHED(); case DownloadCheckResult::BLOCKED_UNSUPPORTED_FILE_TYPE:
return; case DownloadCheckResult::WHITELISTED_BY_POLICY:
} callback.Run(deep_scan_result);
} else if (reason == REASON_WHITELISTED_URL) { return;
callback.Run(deep_scan_result);
return;
} }
NOTREACHED(); // This function should always run |callback| and return before reaching this.
CHECK(false);
} }
} // namespace } // namespace
...@@ -298,8 +297,7 @@ void CheckClientDownloadRequest::UploadBinary( ...@@ -298,8 +297,7 @@ void CheckClientDownloadRequest::UploadBinary(
reason == REASON_DOWNLOAD_POTENTIALLY_UNWANTED || reason == REASON_DOWNLOAD_POTENTIALLY_UNWANTED ||
reason == REASON_DOWNLOAD_UNCOMMON || reason == REASON_WHITELISTED_URL) { reason == REASON_DOWNLOAD_UNCOMMON || reason == REASON_WHITELISTED_URL) {
service()->UploadForDeepScanning( service()->UploadForDeepScanning(
item_, item_, base::BindRepeating(&MaybeOverrideScanResult, reason, callback_),
base::BindRepeating(&MaybeOverrideDlpScanResult, reason, callback_),
DeepScanningRequest::DeepScanTrigger::TRIGGER_POLICY, DeepScanningRequest::DeepScanTrigger::TRIGGER_POLICY,
std::move(settings)); std::move(settings));
} else { } else {
......
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