#include "chrome/browser/safe_browsing/cloud_content_scanning/file_analysis_request.h"
#include <string_view>
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/files/memory_mapped_file.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/file_util_service.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include "chrome/common/safe_browsing/archive_analyzer_results.h"
#include "components/file_access/scoped_file_access.h"
#include "components/file_access/scoped_file_access_delegate.h"
#include "components/safe_browsing/core/common/features.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
#include "net/base/filename_util.h"
#include "net/base/mime_sniffer.h"
#include "net/base/mime_util.h"
namespace safe_browsing {
namespace {
constexpr size_t kReadFileChunkSize = …;
std::string GetFileMimeType(const base::FilePath& path,
std::string_view first_bytes) { … }
std::pair<BinaryUploadService::Result, BinaryUploadService::Request::Data>
GetFileDataBlocking(const base::FilePath& path, bool detect_mime_type) { … }
bool IsZipFile(const base::FilePath::StringType& extension,
const std::string& mime_type) { … }
bool IsRarFile(const base::FilePath::StringType& extension,
const std::string& mime_type) { … }
}
FileAnalysisRequest::FileAnalysisRequest(
const enterprise_connectors::AnalysisSettings& analysis_settings,
base::FilePath path,
base::FilePath file_name,
std::string mime_type,
bool delay_opening_file,
BinaryUploadService::ContentAnalysisCallback callback,
BinaryUploadService::Request::RequestStartCallback start_callback)
: … { … }
FileAnalysisRequest::~FileAnalysisRequest() = default;
void FileAnalysisRequest::GetRequestData(DataCallback callback) { … }
void FileAnalysisRequest::OpenFile() { … }
bool FileAnalysisRequest::HasMalwareRequest() const { … }
void FileAnalysisRequest::OnGotFileData(
std::pair<BinaryUploadService::Result, Data> result_and_data) { … }
void FileAnalysisRequest::OnCheckedForEncryption(
Data data,
const ArchiveAnalyzerResults& analyzer_result) { … }
void FileAnalysisRequest::CacheResultAndData(BinaryUploadService::Result result,
Data data) { … }
void FileAnalysisRequest::RunCallback() { … }
void FileAnalysisRequest::GetData(file_access::ScopedFileAccess file_access) { … }
}