| OLD | NEW |
| 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/zip_analyzer.h" | 5 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "base/i18n/streaming_utf8_validator.h" | 13 #include "base/i18n/streaming_utf8_validator.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "chrome/common/safe_browsing/archive_analyzer_results.h" |
| 16 #include "chrome/common/safe_browsing/binary_feature_extractor.h" | 17 #include "chrome/common/safe_browsing/binary_feature_extractor.h" |
| 17 #include "chrome/common/safe_browsing/download_protection_util.h" | 18 #include "chrome/common/safe_browsing/download_protection_util.h" |
| 18 #include "chrome/common/safe_browsing/file_type_policies.h" | 19 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 19 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | |
| 20 #include "components/safe_browsing/csd.pb.h" | 20 #include "components/safe_browsing/csd.pb.h" |
| 21 #include "crypto/secure_hash.h" | 21 #include "crypto/secure_hash.h" |
| 22 #include "crypto/sha2.h" | 22 #include "crypto/sha2.h" |
| 23 #include "third_party/zlib/google/zip_reader.h" | 23 #include "third_party/zlib/google/zip_reader.h" |
| 24 | 24 |
| 25 namespace safe_browsing { | 25 namespace safe_browsing { |
| 26 namespace zip_analyzer { | 26 namespace zip_analyzer { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // No SignedData blobs were extracted, so clear the signature field. | 89 // No SignedData blobs were extracted, so clear the signature field. |
| 90 archived_binary->clear_signature(); | 90 archived_binary->clear_signature(); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace | 95 } // namespace |
| 96 | 96 |
| 97 void AnalyzeZipFile(base::File zip_file, | 97 void AnalyzeZipFile(base::File zip_file, |
| 98 base::File temp_file, | 98 base::File temp_file, |
| 99 Results* results) { | 99 ArchiveAnalyzerResults* results) { |
| 100 std::set<base::FilePath> archived_archive_filenames; | 100 std::set<base::FilePath> archived_archive_filenames; |
| 101 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor( | 101 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor( |
| 102 new BinaryFeatureExtractor()); | 102 new BinaryFeatureExtractor()); |
| 103 zip::ZipReader reader; | 103 zip::ZipReader reader; |
| 104 if (!reader.OpenFromPlatformFile(zip_file.GetPlatformFile())) { | 104 if (!reader.OpenFromPlatformFile(zip_file.GetPlatformFile())) { |
| 105 DVLOG(1) << "Failed to open zip file"; | 105 DVLOG(1) << "Failed to open zip file"; |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool advanced = true; | 109 bool advanced = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 DVLOG(3) << "Ignoring non-binary file: " << file.value(); | 130 DVLOG(3) << "Ignoring non-binary file: " << file.value(); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 results->archived_archive_filenames.assign(archived_archive_filenames.begin(), | 133 results->archived_archive_filenames.assign(archived_archive_filenames.begin(), |
| 134 archived_archive_filenames.end()); | 134 archived_archive_filenames.end()); |
| 135 results->success = true; | 135 results->success = true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace zip_analyzer | 138 } // namespace zip_analyzer |
| 139 } // namespace safe_browsing | 139 } // namespace safe_browsing |
| OLD | NEW |