Home | History | Annotate | Download | only in safe_browsing
      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
      3 // found in the LICENSE file.
      4 
      5 #include "base/files/file_path.h"
      6 
      7 namespace safe_browsing {
      8 namespace download_protection_util {
      9 
     10 bool IsArchiveFile(const base::FilePath& file) {
     11   return file.MatchesExtension(FILE_PATH_LITERAL(".zip"));
     12 }
     13 
     14 bool IsBinaryFile(const base::FilePath& file) {
     15   return (
     16       // Executable extensions for MS Windows.
     17       file.MatchesExtension(FILE_PATH_LITERAL(".bas")) ||
     18       file.MatchesExtension(FILE_PATH_LITERAL(".bat")) ||
     19       file.MatchesExtension(FILE_PATH_LITERAL(".cab")) ||
     20       file.MatchesExtension(FILE_PATH_LITERAL(".cmd")) ||
     21       file.MatchesExtension(FILE_PATH_LITERAL(".com")) ||
     22       file.MatchesExtension(FILE_PATH_LITERAL(".exe")) ||
     23       file.MatchesExtension(FILE_PATH_LITERAL(".hta")) ||
     24       file.MatchesExtension(FILE_PATH_LITERAL(".msi")) ||
     25       file.MatchesExtension(FILE_PATH_LITERAL(".pif")) ||
     26       file.MatchesExtension(FILE_PATH_LITERAL(".reg")) ||
     27       file.MatchesExtension(FILE_PATH_LITERAL(".scr")) ||
     28       file.MatchesExtension(FILE_PATH_LITERAL(".vb")) ||
     29       file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) ||
     30       // Chrome extensions and android APKs are also reported.
     31       file.MatchesExtension(FILE_PATH_LITERAL(".crx")) ||
     32       file.MatchesExtension(FILE_PATH_LITERAL(".apk")) ||
     33       // Archives _may_ contain binaries, we'll check in ExtractFileFeatures.
     34       IsArchiveFile(file));
     35 }
     36 
     37 }  // namespace download_protection_util
     38 }  // namespace safe_browsing
     39