| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Utility functions to extract file features for malicious binary detection. | 5 // Utility functions to extract file features for malicious binary detection. |
| 6 // Each platform has its own implementation of this class. | 6 // Each platform has its own implementation of this class. |
| 7 | 7 |
| 8 #ifndef CHROME_COMMON_SAFE_BROWSING_BINARY_FEATURE_EXTRACTOR_H_ | 8 #ifndef CHROME_COMMON_SAFE_BROWSING_BINARY_FEATURE_EXTRACTOR_H_ |
| 9 #define CHROME_COMMON_SAFE_BROWSING_BINARY_FEATURE_EXTRACTOR_H_ | 9 #define CHROME_COMMON_SAFE_BROWSING_BINARY_FEATURE_EXTRACTOR_H_ |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/files/file.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class FilePath; | 16 class FilePath; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace safe_browsing { | 19 namespace safe_browsing { |
| 19 class ClientDownloadRequest_Digests; | 20 class ClientDownloadRequest_Digests; |
| 20 class ClientDownloadRequest_ImageHeaders; | 21 class ClientDownloadRequest_ImageHeaders; |
| 21 class ClientDownloadRequest_SignatureInfo; | 22 class ClientDownloadRequest_SignatureInfo; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 38 ClientDownloadRequest_SignatureInfo* signature_info); | 39 ClientDownloadRequest_SignatureInfo* signature_info); |
| 39 | 40 |
| 40 // Populates |image_headers| with the PE image headers of |file_path|. | 41 // Populates |image_headers| with the PE image headers of |file_path|. |
| 41 // |options| is a bitfield controlling aspects of extraction. Returns true if | 42 // |options| is a bitfield controlling aspects of extraction. Returns true if |
| 42 // |image_headers| is populated with any information. | 43 // |image_headers| is populated with any information. |
| 43 virtual bool ExtractImageHeaders( | 44 virtual bool ExtractImageHeaders( |
| 44 const base::FilePath& file_path, | 45 const base::FilePath& file_path, |
| 45 ExtractHeadersOption options, | 46 ExtractHeadersOption options, |
| 46 ClientDownloadRequest_ImageHeaders* image_headers); | 47 ClientDownloadRequest_ImageHeaders* image_headers); |
| 47 | 48 |
| 49 // As above, but works with an already-opened file. BinaryFeatureExtractor |
| 50 // takes ownership of |file| and closes it when done. |
| 51 virtual bool ExtractImageHeadersFromFile( |
| 52 base::File file, |
| 53 ExtractHeadersOption options, |
| 54 ClientDownloadRequest_ImageHeaders* image_headers); |
| 55 |
| 48 // Populates |digests.sha256| with the SHA256 digest of |file_path|. | 56 // Populates |digests.sha256| with the SHA256 digest of |file_path|. |
| 49 virtual void ExtractDigest(const base::FilePath& file_path, | 57 virtual void ExtractDigest(const base::FilePath& file_path, |
| 50 ClientDownloadRequest_Digests* digests); | 58 ClientDownloadRequest_Digests* digests); |
| 51 | 59 |
| 52 protected: | 60 protected: |
| 53 friend class base::RefCountedThreadSafe<BinaryFeatureExtractor>; | 61 friend class base::RefCountedThreadSafe<BinaryFeatureExtractor>; |
| 54 virtual ~BinaryFeatureExtractor(); | 62 virtual ~BinaryFeatureExtractor(); |
| 55 | 63 |
| 56 private: | 64 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(BinaryFeatureExtractor); | 65 DISALLOW_COPY_AND_ASSIGN(BinaryFeatureExtractor); |
| 58 }; | 66 }; |
| 59 } // namespace safe_browsing | 67 } // namespace safe_browsing |
| 60 | 68 |
| 61 #endif // CHROME_COMMON_SAFE_BROWSING_BINARY_FEATURE_EXTRACTOR_H_ | 69 #endif // CHROME_COMMON_SAFE_BROWSING_BINARY_FEATURE_EXTRACTOR_H_ |
| OLD | NEW |