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

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

Issue 1230483005: [SafeBrowsing] Send pingbacks for additional file types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@more-dangerous-files
Patch Set: Created 5 years, 5 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 // TODO(mattm): should .dmg be checked here instead of IsBinaryFile? 14 // TODO(mattm): should .dmg be checked here instead of IsBinaryFile?
15 return file.MatchesExtension(FILE_PATH_LITERAL(".zip")); 15 return file.MatchesExtension(FILE_PATH_LITERAL(".zip"));
16 } 16 }
17 17
18 bool IsBinaryFile(const base::FilePath& file) { 18 bool IsBinaryFile(const base::FilePath& file) {
19 return ( 19 return (
20 // Executable extensions for MS Windows. 20 // Executable extensions for MS Windows.
21 file.MatchesExtension(FILE_PATH_LITERAL(".bas")) || 21 file.MatchesExtension(FILE_PATH_LITERAL(".bas")) ||
Alexei Svitkine (slow) 2015/07/08 14:56:08 Optional: I wonder if this function can call GetE
22 file.MatchesExtension(FILE_PATH_LITERAL(".bat")) || 22 file.MatchesExtension(FILE_PATH_LITERAL(".bat")) ||
23 file.MatchesExtension(FILE_PATH_LITERAL(".cab")) || 23 file.MatchesExtension(FILE_PATH_LITERAL(".cab")) ||
24 file.MatchesExtension(FILE_PATH_LITERAL(".cmd")) || 24 file.MatchesExtension(FILE_PATH_LITERAL(".cmd")) ||
25 file.MatchesExtension(FILE_PATH_LITERAL(".com")) || 25 file.MatchesExtension(FILE_PATH_LITERAL(".com")) ||
26 file.MatchesExtension(FILE_PATH_LITERAL(".exe")) || 26 file.MatchesExtension(FILE_PATH_LITERAL(".exe")) ||
27 file.MatchesExtension(FILE_PATH_LITERAL(".hta")) || 27 file.MatchesExtension(FILE_PATH_LITERAL(".hta")) ||
28 file.MatchesExtension(FILE_PATH_LITERAL(".msi")) || 28 file.MatchesExtension(FILE_PATH_LITERAL(".msi")) ||
29 file.MatchesExtension(FILE_PATH_LITERAL(".pif")) || 29 file.MatchesExtension(FILE_PATH_LITERAL(".pif")) ||
30 file.MatchesExtension(FILE_PATH_LITERAL(".reg")) || 30 file.MatchesExtension(FILE_PATH_LITERAL(".reg")) ||
31 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) || 31 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) ||
32 file.MatchesExtension(FILE_PATH_LITERAL(".url")) || 32 file.MatchesExtension(FILE_PATH_LITERAL(".url")) ||
33 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) || 33 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) ||
34 file.MatchesExtension(FILE_PATH_LITERAL(".vbe")) ||
34 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) || 35 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) ||
36 file.MatchesExtension(FILE_PATH_LITERAL(".js")) ||
37 file.MatchesExtension(FILE_PATH_LITERAL(".jse")) ||
35 file.MatchesExtension(FILE_PATH_LITERAL(".website")) || 38 file.MatchesExtension(FILE_PATH_LITERAL(".website")) ||
39 file.MatchesExtension(FILE_PATH_LITERAL(".mht")) ||
40 file.MatchesExtension(FILE_PATH_LITERAL(".mhtml")) ||
36 // Chrome extensions and android APKs are also reported. 41 // Chrome extensions and android APKs are also reported.
37 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) || 42 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) ||
38 file.MatchesExtension(FILE_PATH_LITERAL(".apk")) || 43 file.MatchesExtension(FILE_PATH_LITERAL(".apk")) ||
39 // Mac extensions. 44 // Mac extensions.
40 file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) || 45 file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) ||
41 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) || 46 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) ||
42 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) || 47 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) ||
43 file.MatchesExtension(FILE_PATH_LITERAL(".app")) || 48 file.MatchesExtension(FILE_PATH_LITERAL(".app")) ||
44 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures. 49 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures.
45 IsArchiveFile(file)); 50 IsArchiveFile(file));
(...skipping 13 matching lines...) Expand all
59 else if (file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) || 64 else if (file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) ||
60 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) || 65 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) ||
61 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) || 66 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) ||
62 file.MatchesExtension(FILE_PATH_LITERAL(".app"))) 67 file.MatchesExtension(FILE_PATH_LITERAL(".app")))
63 return ClientDownloadRequest::MAC_EXECUTABLE; 68 return ClientDownloadRequest::MAC_EXECUTABLE;
64 return ClientDownloadRequest::WIN_EXECUTABLE; 69 return ClientDownloadRequest::WIN_EXECUTABLE;
65 } 70 }
66 71
67 } // namespace download_protection_util 72 } // namespace download_protection_util
68 } // namespace safe_browsing 73 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698