Commit 535a5cfc authored by mattm@chromium.org's avatar mattm@chromium.org

Sync csd.proto with server-side version.

Adds DANGEROUS_HOST ClientDownloadResponse verdict and pipes it through the downloads system.  For now we show the same warning message for both DANGEROUS_CONTENT and DANGEROUS_HOST.

BUG=none


Review URL: https://chromiumcodereview.appspot.com/12087095

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180064 0039d316-1c4b-4281-b951-d872f2087c98
parent ee77317e
...@@ -348,6 +348,9 @@ DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem( ...@@ -348,6 +348,9 @@ DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem(
case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED:
download_danger_type_string = "USER_VALIDATED"; download_danger_type_string = "USER_VALIDATED";
break; break;
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
download_danger_type_string = "DANGEROUS_HOST";
break;
case content::DOWNLOAD_DANGER_TYPE_MAX: case content::DOWNLOAD_DANGER_TYPE_MAX:
NOTREACHED(); NOTREACHED();
download_danger_type_string = "UNKNOWN"; download_danger_type_string = "UNKNOWN";
......
...@@ -666,6 +666,10 @@ void ChromeDownloadManagerDelegate::CheckClientDownloadDone( ...@@ -666,6 +666,10 @@ void ChromeDownloadManagerDelegate::CheckClientDownloadDone(
item->OnContentCheckCompleted( item->OnContentCheckCompleted(
content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT);
break; break;
case DownloadProtectionService::DANGEROUS_HOST:
item->OnContentCheckCompleted(
content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST);
break;
} }
} }
......
...@@ -118,6 +118,7 @@ string16 DownloadDangerPromptImpl::GetMessage() { ...@@ -118,6 +118,7 @@ string16 DownloadDangerPromptImpl::GetMessage() {
download_->GetFileNameToReportUser().LossyDisplayName()); download_->GetFileNameToReportUser().LossyDisplayName());
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: // Fall through case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: // Fall through
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT,
download_->GetFileNameToReportUser().LossyDisplayName()); download_->GetFileNameToReportUser().LossyDisplayName());
......
...@@ -302,6 +302,7 @@ string16 DownloadItemModel::GetWarningText(const gfx::Font& font, ...@@ -302,6 +302,7 @@ string16 DownloadItemModel::GetWarningText(const gfx::Font& font,
} }
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
return l10n_util::GetStringFUTF16( return l10n_util::GetStringFUTF16(
IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT,
ui::ElideFilename(download_->GetFileNameToReportUser(), ui::ElideFilename(download_->GetFileNameToReportUser(),
...@@ -361,6 +362,7 @@ bool DownloadItemModel::IsMalicious() const { ...@@ -361,6 +362,7 @@ bool DownloadItemModel::IsMalicious() const {
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL:
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
return true; return true;
case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS:
......
...@@ -94,6 +94,7 @@ const char kDangerKey[] = "danger"; ...@@ -94,6 +94,7 @@ const char kDangerKey[] = "danger";
const char kDangerSafe[] = "safe"; const char kDangerSafe[] = "safe";
const char kDangerUncommon[] = "uncommon"; const char kDangerUncommon[] = "uncommon";
const char kDangerAccepted[] = "accepted"; const char kDangerAccepted[] = "accepted";
const char kDangerHost[] = "host";
const char kDangerUrl[] = "url"; const char kDangerUrl[] = "url";
const char kEndTimeKey[] = "endTime"; const char kEndTimeKey[] = "endTime";
const char kEndedAfterKey[] = "endedAfter"; const char kEndedAfterKey[] = "endedAfter";
...@@ -131,6 +132,7 @@ const char* kDangerStrings[] = { ...@@ -131,6 +132,7 @@ const char* kDangerStrings[] = {
kDangerSafe, kDangerSafe,
kDangerUncommon, kDangerUncommon,
kDangerAccepted, kDangerAccepted,
kDangerHost,
}; };
COMPILE_ASSERT(arraysize(kDangerStrings) == content::DOWNLOAD_DANGER_TYPE_MAX, COMPILE_ASSERT(arraysize(kDangerStrings) == content::DOWNLOAD_DANGER_TYPE_MAX,
download_danger_type_enum_changed); download_danger_type_enum_changed);
......
...@@ -366,7 +366,8 @@ Download.DangerType = { ...@@ -366,7 +366,8 @@ Download.DangerType = {
DANGEROUS_FILE: 'DANGEROUS_FILE', DANGEROUS_FILE: 'DANGEROUS_FILE',
DANGEROUS_URL: 'DANGEROUS_URL', DANGEROUS_URL: 'DANGEROUS_URL',
DANGEROUS_CONTENT: 'DANGEROUS_CONTENT', DANGEROUS_CONTENT: 'DANGEROUS_CONTENT',
UNCOMMON_CONTENT: 'UNCOMMON_CONTENT' UNCOMMON_CONTENT: 'UNCOMMON_CONTENT',
DANGEROUS_HOST: 'DANGEROUS_HOST'
}; };
/** /**
...@@ -415,7 +416,8 @@ Download.prototype.update = function(download) { ...@@ -415,7 +416,8 @@ Download.prototype.update = function(download) {
this.fileName_); this.fileName_);
} else if (this.dangerType_ == Download.DangerType.DANGEROUS_URL) { } else if (this.dangerType_ == Download.DangerType.DANGEROUS_URL) {
this.dangerDesc_.textContent = loadTimeData.getString('danger_url_desc'); this.dangerDesc_.textContent = loadTimeData.getString('danger_url_desc');
} else if (this.dangerType_ == Download.DangerType.DANGEROUS_CONTENT) { } else if (this.dangerType_ == Download.DangerType.DANGEROUS_CONTENT ||
this.dangerType_ == Download.DangerType.DANGEROUS_HOST) {
this.dangerDesc_.textContent = loadTimeData.getStringF( this.dangerDesc_.textContent = loadTimeData.getStringF(
'danger_content_desc', this.fileName_); 'danger_content_desc', this.fileName_);
} else if (this.dangerType_ == Download.DangerType.UNCOMMON_CONTENT) { } else if (this.dangerType_ == Download.DangerType.UNCOMMON_CONTENT) {
......
...@@ -465,6 +465,9 @@ class DownloadProtectionService::CheckClientDownloadRequest ...@@ -465,6 +465,9 @@ class DownloadProtectionService::CheckClientDownloadRequest
} else if (response.verdict() == ClientDownloadResponse::UNCOMMON) { } else if (response.verdict() == ClientDownloadResponse::UNCOMMON) {
reason = REASON_DOWNLOAD_UNCOMMON; reason = REASON_DOWNLOAD_UNCOMMON;
result = UNCOMMON; result = UNCOMMON;
} else if (response.verdict() == ClientDownloadResponse::DANGEROUS_HOST) {
reason = REASON_DOWNLOAD_DANGEROUS_HOST;
result = DANGEROUS_HOST;
} else { } else {
LOG(DFATAL) << "Unknown download response verdict: " LOG(DFATAL) << "Unknown download response verdict: "
<< response.verdict(); << response.verdict();
......
...@@ -62,6 +62,7 @@ class DownloadProtectionService { ...@@ -62,6 +62,7 @@ class DownloadProtectionService {
SAFE, SAFE,
DANGEROUS, DANGEROUS,
UNCOMMON, UNCOMMON,
DANGEROUS_HOST,
}; };
// Callback type which is invoked once the download request is done. // Callback type which is invoked once the download request is done.
...@@ -141,6 +142,7 @@ class DownloadProtectionService { ...@@ -141,6 +142,7 @@ class DownloadProtectionService {
REASON_DOWNLOAD_NOT_SUPPORTED, REASON_DOWNLOAD_NOT_SUPPORTED,
REASON_INVALID_RESPONSE_VERDICT, REASON_INVALID_RESPONSE_VERDICT,
REASON_ARCHIVE_WITHOUT_BINARIES, REASON_ARCHIVE_WITHOUT_BINARIES,
REASON_DOWNLOAD_DANGEROUS_HOST,
REASON_MAX // Always add new values before this one. REASON_MAX // Always add new values before this one.
}; };
......
...@@ -406,7 +406,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { ...@@ -406,7 +406,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
EXPECT_CALL(*sb_service_->mock_database_manager(), EXPECT_CALL(*sb_service_->mock_database_manager(),
MatchDownloadWhitelistUrl(_)) MatchDownloadWhitelistUrl(_))
.WillRepeatedly(Return(false)); .WillRepeatedly(Return(false));
EXPECT_CALL(*signature_util_, CheckSignature(info.local_file, _)).Times(4); EXPECT_CALL(*signature_util_, CheckSignature(info.local_file, _)).Times(5);
download_service_->CheckClientDownload( download_service_->CheckClientDownload(
info, info,
...@@ -464,6 +464,25 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { ...@@ -464,6 +464,25 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
#else #else
EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
#endif #endif
// If the response is dangerous_host the result should also be marked as
// dangerous_host.
response.set_verdict(ClientDownloadResponse::DANGEROUS_HOST);
factory.SetFakeResponse(
DownloadProtectionService::GetDownloadRequestUrl(),
response.SerializeAsString(),
true);
download_service_->CheckClientDownload(
info,
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
msg_loop_.Run();
#if defined(OS_WIN)
EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS_HOST));
#else
EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
#endif
} }
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) { TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) {
......
...@@ -94,6 +94,8 @@ const char* GetDangerTypeString(content::DownloadDangerType danger_type) { ...@@ -94,6 +94,8 @@ const char* GetDangerTypeString(content::DownloadDangerType danger_type) {
return "DANGEROUS_CONTENT"; return "DANGEROUS_CONTENT";
case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
return "UNCOMMON_CONTENT"; return "UNCOMMON_CONTENT";
case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
return "DANGEROUS_HOST";
default: default:
// Don't return a danger type string if it is NOT_DANGEROUS or // Don't return a danger type string if it is NOT_DANGEROUS or
// MAYBE_DANGEROUS_CONTENT. // MAYBE_DANGEROUS_CONTENT.
...@@ -151,7 +153,9 @@ DictionaryValue* CreateDownloadItemValue( ...@@ -151,7 +153,9 @@ DictionaryValue* CreateDownloadItemValue(
download_item->GetDangerType() == download_item->GetDangerType() ==
content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
download_item->GetDangerType() == download_item->GetDangerType() ==
content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT ||
download_item->GetDangerType() ==
content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST);
const char* danger_type_value = const char* danger_type_value =
GetDangerTypeString(download_item->GetDangerType()); GetDangerTypeString(download_item->GetDangerType());
file_value->SetString("danger_type", danger_type_value); file_value->SetString("danger_type", danger_type_value);
......
...@@ -47,12 +47,15 @@ namespace downloads { ...@@ -47,12 +47,15 @@ namespace downloads {
// <dt>uncommon</dt> // <dt>uncommon</dt>
// <dd>The download's URL is not commonly downloaded and could be // <dd>The download's URL is not commonly downloaded and could be
// dangerous.</dd> // dangerous.</dd>
// <dt>host</dt>
// <dd>The download came from a host known to distribute malicious
// binaries and is likely dangerous.</dd>
// <dt>safe</dt> // <dt>safe</dt>
// <dd>The download presents no known danger to the user's computer.</dd> // <dd>The download presents no known danger to the user's computer.</dd>
// </dl> // </dl>
// These string constants will never change, however the set of DangerTypes // These string constants will never change, however the set of DangerTypes
// may change. // may change.
enum DangerType {file, url, content, uncommon, safe}; enum DangerType {file, url, content, uncommon, host, safe};
// <dl><dt>in_progress</dt> // <dl><dt>in_progress</dt>
// <dd>The download is currently receiving data from the server.</dd> // <dd>The download is currently receiving data from the server.</dd>
......
...@@ -195,6 +195,8 @@ message ClientDownloadResponse { ...@@ -195,6 +195,8 @@ message ClientDownloadResponse {
UNCOMMON = 2; UNCOMMON = 2;
// The download is potentially unwanted. // The download is potentially unwanted.
POTENTIALLY_UNWANTED = 3; POTENTIALLY_UNWANTED = 3;
// The download is from a dangerous host.
DANGEROUS_HOST = 4;
} }
required Verdict verdict = 1; required Verdict verdict = 1;
......
...@@ -599,7 +599,8 @@ bool DownloadItemImpl::IsDangerous() const { ...@@ -599,7 +599,8 @@ bool DownloadItemImpl::IsDangerous() const {
return (danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || return (danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
danger_type_ == DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); danger_type_ == DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT ||
danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST);
#else #else
return (danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || return (danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL);
......
...@@ -29,7 +29,8 @@ static const char* download_danger_names[] = { ...@@ -29,7 +29,8 @@ static const char* download_danger_names[] = {
"DANGEROUS_CONTENT", "DANGEROUS_CONTENT",
"MAYBE_DANGEROUS_CONTENT", "MAYBE_DANGEROUS_CONTENT",
"UNCOMMON_CONTENT", "UNCOMMON_CONTENT",
"USER_VALIDATED" "USER_VALIDATED",
"DANGEROUS_HOST",
}; };
COMPILE_ASSERT(ARRAYSIZE_UNSAFE(download_type_names) == SRC_SAVE_PAGE_AS + 1, COMPILE_ASSERT(ARRAYSIZE_UNSAFE(download_type_names) == SRC_SAVE_PAGE_AS + 1,
......
...@@ -32,10 +32,15 @@ enum DownloadDangerType { ...@@ -32,10 +32,15 @@ enum DownloadDangerType {
// didn't have enough data to determine whether it was malicious. // didn't have enough data to determine whether it was malicious.
DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT, DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT,
// The download was evaluated to be one of the above types of danger, // The download was evaluated to be one of the other types of danger,
// but the user told us to go ahead anyway. // but the user told us to go ahead anyway.
DOWNLOAD_DANGER_TYPE_USER_VALIDATED, DOWNLOAD_DANGER_TYPE_USER_VALIDATED,
// SafeBrowsing download service checked the contents of the download and
// didn't have data on this specific file, but the file was served from a host
// known to serve mostly malicious content.
DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST,
// Memory space for histograms is determined by the max. // Memory space for histograms is determined by the max.
// ALWAYS ADD NEW VALUES BEFORE THIS ONE. // ALWAYS ADD NEW VALUES BEFORE THIS ONE.
DOWNLOAD_DANGER_TYPE_MAX DOWNLOAD_DANGER_TYPE_MAX
......
...@@ -1572,7 +1572,9 @@ EVENT_TYPE(DOWNLOAD_URL_REQUEST) ...@@ -1572,7 +1572,9 @@ EVENT_TYPE(DOWNLOAD_URL_REQUEST)
// |state_info.force_filename| // |state_info.force_filename|
// |suggested_filename_| // |suggested_filename_|
// the filename specified in the final URL>, // the filename specified in the final URL>,
// "danger_type": <NOT,FILE,URL,CONTENT,MAYBE_CONTENT>, // "danger_type": <NOT_DANGEROUS, DANGEROUS_FILE, DANGEROUS_URL,
// DANGEROUS_CONTENT, MAYBE_DANGEROUS_CONTENT,
// UNCOMMON_CONTENT, USER_VALIDATED, DANGEROUS_HOST>,
// "start_offset": <Where to start writing (defaults to 0)>, // "start_offset": <Where to start writing (defaults to 0)>,
// "has_user_gesture": <Whether or not we think the user initiated // "has_user_gesture": <Whether or not we think the user initiated
// the download> // the download>
...@@ -1586,7 +1588,7 @@ EVENT_TYPE(DOWNLOAD_ITEM_ACTIVE) ...@@ -1586,7 +1588,7 @@ EVENT_TYPE(DOWNLOAD_ITEM_ACTIVE)
// This event is created when a download item's danger type // This event is created when a download item's danger type
// has been modified. // has been modified.
// { // {
// "danger_type": <NOT,FILE,URL,CONTENT,MAYBE_CONTENT,USER_VALIDATED>, // "danger_type": <The new danger type. See above for possible values.>,
// } // }
EVENT_TYPE(DOWNLOAD_ITEM_SAFETY_STATE_UPDATED) EVENT_TYPE(DOWNLOAD_ITEM_SAFETY_STATE_UPDATED)
......
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