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

Make MaybeReportDeepScanningVerdict use hex-encoded sha256.

Change-Id: I5b1132e596225950efc889494c8221ed8cce45ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1948229
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721085}
parent a07e7f06
......@@ -12,6 +12,7 @@
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
......@@ -476,8 +477,9 @@ void DeepScanningDialogDelegate::CompleteFileRequestCallback(
MaybeReportDeepScanningVerdict(
Profile::FromBrowserContext(web_contents_->GetBrowserContext()),
web_contents_->GetLastCommittedURL(), path.AsUTF8Unsafe(),
file_info_[index].sha256, mime_type,
extensions::SafeBrowsingPrivateEventRouter::kTriggerFileUpload,
base::HexEncode(file_info_[index].sha256.data(),
file_info_[index].sha256.size()),
mime_type, extensions::SafeBrowsingPrivateEventRouter::kTriggerFileUpload,
file_info_[index].size, result, response);
bool dlp_ok = DlpTriggeredRulesOK(response.dlp_scan_verdict());
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include <algorithm>
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h"
......@@ -43,6 +44,11 @@ void MaybeReportDeepScanningVerdict(Profile* profile,
const int64_t content_size,
BinaryUploadService::Result result,
DeepScanningClientResponse response) {
DCHECK(std::all_of(download_digest_sha256.begin(),
download_digest_sha256.end(), [](const char& c) {
return (c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
}));
if (result == BinaryUploadService::Result::FILE_TOO_LARGE) {
extensions::SafeBrowsingPrivateEventRouterFactory::GetForProfile(profile)
->OnUnscannedFileEvent(url, file_name, download_digest_sha256,
......
......@@ -15,7 +15,8 @@ class Profile;
namespace safe_browsing {
// Helper function to examine a DeepScanningClientResponse and report the
// appropriate events to the enterprise admin.
// appropriate events to the enterprise admin. |download_digest_sha256| must be
// encoded using base::HexEncode.
void MaybeReportDeepScanningVerdict(Profile* profile,
const GURL& url,
const std::string& file_name,
......
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