Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/common/safe_browsing/download_protection_util.cc

Issue 1262753002: [SafeBrowsing] Send pings for Zip files that contain other archives. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/safe_browsing/download_protection_util.h" 5 #include "chrome/common/safe_browsing/download_protection_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace safe_browsing { 10 namespace safe_browsing {
11 namespace download_protection_util { 11 namespace download_protection_util {
12 12
13 bool IsArchiveFile(const base::FilePath& file) { 13 bool IsArchiveFile(const base::FilePath& file) {
14 const base::FilePath::CharType* kArchiveFileTypes[] = {
15 FILE_PATH_LITERAL(".zip"),
16 FILE_PATH_LITERAL(".rar"),
17 FILE_PATH_LITERAL(".7z"),
18 FILE_PATH_LITERAL(".cab"),
19 };
20 for (const auto& extension : kArchiveFileTypes)
21 if (file.MatchesExtension(extension))
22 return true;
14 // TODO(mattm): should .dmg be checked here instead of IsBinaryFile? 23 // TODO(mattm): should .dmg be checked here instead of IsBinaryFile?
15 return file.MatchesExtension(FILE_PATH_LITERAL(".zip")); 24 return false;
16 } 25 }
17 26
18 bool IsBinaryFile(const base::FilePath& file) { 27 bool IsBinaryFile(const base::FilePath& file) {
19 const base::FilePath::CharType* kSupportedBinaryFileTypes[] = { 28 const base::FilePath::CharType* kSupportedBinaryFileTypes[] = {
20 // Executable extensions for MS Windows. 29 // Executable extensions for MS Windows.
21 FILE_PATH_LITERAL(".cab"),
22 FILE_PATH_LITERAL(".cmd"), 30 FILE_PATH_LITERAL(".cmd"),
23 FILE_PATH_LITERAL(".com"), 31 FILE_PATH_LITERAL(".com"),
24 FILE_PATH_LITERAL(".dll"), 32 FILE_PATH_LITERAL(".dll"),
25 FILE_PATH_LITERAL(".exe"), 33 FILE_PATH_LITERAL(".exe"),
26 FILE_PATH_LITERAL(".msc"), 34 FILE_PATH_LITERAL(".msc"),
27 FILE_PATH_LITERAL(".msi"), 35 FILE_PATH_LITERAL(".msi"),
28 FILE_PATH_LITERAL(".msp"), 36 FILE_PATH_LITERAL(".msp"),
29 FILE_PATH_LITERAL(".mst"), 37 FILE_PATH_LITERAL(".mst"),
30 FILE_PATH_LITERAL(".pif"), 38 FILE_PATH_LITERAL(".pif"),
31 FILE_PATH_LITERAL(".scr"), 39 FILE_PATH_LITERAL(".scr"),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return IsArchiveFile(file); 84 return IsArchiveFile(file);
77 } 85 }
78 86
79 ClientDownloadRequest::DownloadType GetDownloadType( 87 ClientDownloadRequest::DownloadType GetDownloadType(
80 const base::FilePath& file) { 88 const base::FilePath& file) {
81 DCHECK(IsBinaryFile(file)); 89 DCHECK(IsBinaryFile(file));
82 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk"))) 90 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk")))
83 return ClientDownloadRequest::ANDROID_APK; 91 return ClientDownloadRequest::ANDROID_APK;
84 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx"))) 92 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx")))
85 return ClientDownloadRequest::CHROME_EXTENSION; 93 return ClientDownloadRequest::CHROME_EXTENSION;
86 // For zip files, we use the ZIPPED_EXECUTABLE type since we will only send 94 // For .zip files, we send the ZIPPED_EXECUTABLE type although the type may
87 // the pingback if we find an executable inside the zip archive. 95 // change to ZIPPED_ARCHIVE based on the zip analyzer.
mattm 2015/07/29 22:53:25 still a little confusing.. maybe "we initially set
asanka 2015/07/31 01:04:42 Reworded.
88 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip"))) 96 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip")))
89 return ClientDownloadRequest::ZIPPED_EXECUTABLE; 97 return ClientDownloadRequest::ZIPPED_EXECUTABLE;
90 else if (file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) || 98 else if (file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) ||
91 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) || 99 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) ||
92 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) || 100 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) ||
93 file.MatchesExtension(FILE_PATH_LITERAL(".app"))) 101 file.MatchesExtension(FILE_PATH_LITERAL(".app")))
94 return ClientDownloadRequest::MAC_EXECUTABLE; 102 return ClientDownloadRequest::MAC_EXECUTABLE;
95 return ClientDownloadRequest::WIN_EXECUTABLE; 103 return ClientDownloadRequest::WIN_EXECUTABLE;
96 } 104 }
97 105
98 } // namespace download_protection_util 106 } // namespace download_protection_util
99 } // namespace safe_browsing 107 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698