}
FileVerdict FileCache::check_verdict(Packet* p, FileInfo* file,
- FilePolicyBase* policy)
+ FilePolicyBase* policy, const uint8_t* current_data, uint32_t current_data_len)
{
assert(file);
if ( file->get_file_sig_sha256() and verdict <= FILE_VERDICT_LOG )
{
file->user_file_data_mutex.lock();
+ file->set_capture_file_data(current_data, current_data_len);
verdict = policy->signature_lookup(p, file);
file->user_file_data_mutex.unlock();
}
}
FileVerdict FileCache::cached_verdict_lookup(Packet* p, FileInfo* file,
- FilePolicyBase* policy)
+ FilePolicyBase* policy, const uint8_t* current_data, uint32_t current_data_len)
{
Flow* flow = p->flow;
FileVerdict verdict = FILE_VERDICT_UNKNOWN;
if (file_found)
{
/*Query the file policy in case verdict has been changed*/
- verdict = check_verdict(p, file_found, policy);
+ verdict = check_verdict(p, file_found, policy, current_data, current_data_len);
FILE_DEBUG(file_trace, DEFAULT_TRACE_OPTION_ID, TRACE_DEBUG_LEVEL, p,
"cached_verdict_lookup:Verdict received from cached_verdict_lookup %d\n", verdict);
apply_verdict(p, file_found, verdict, true, policy);
snort::FileContext* get_file(snort::Flow*, uint64_t file_id, bool to_create, bool using_cache_entry);
FileVerdict cached_verdict_lookup(snort::Packet*, snort::FileInfo*,
- snort::FilePolicyBase*);
+ snort::FilePolicyBase*,const uint8_t* current_data, uint32_t current_data_len);
bool apply_verdict(snort::Packet*, snort::FileContext*, FileVerdict, bool resume,
snort::FilePolicyBase*);
snort::FileContext* find_add(const FileHashKey&, int64_t);
snort::FileContext* get_file(snort::Flow*, uint64_t file_id, bool to_create,
int64_t timeout, bool using_cache_entry, bool &cache_full);
- FileVerdict check_verdict(snort::Packet*, snort::FileInfo*, snort::FilePolicyBase*);
+ FileVerdict check_verdict(snort::Packet*, snort::FileInfo*, snort::FilePolicyBase*,const uint8_t* current_data, uint32_t current_data_len);
int store_verdict(snort::Flow*, snort::FileInfo*, int64_t timeout, bool &cache_full);
/* The hash table of expected files */
int64_t get_max_file_capture_size() { return capture_max_size; }
int64_t get_file_capture_size() { return capture_size; }
void get_file_reset() { current_block = head; }
+ void set_data(const uint8_t* file_data, const uint32_t size) {current_data = file_data; current_data_len = size;}
private:
if ((context->is_cacheable() and not is_new_context) or context->is_partial_download()) // If partial header was seen - check file_cache
{
FileVerdict verdict = FileService::get_file_cache()->cached_verdict_lookup(p, context,
- file_policy);
+ file_policy, file_data, data_size);
if (verdict != FILE_VERDICT_UNKNOWN and verdict != FILE_VERDICT_PENDING)
{
context->processing_complete = true;
user_file_data = fd;
}
+void FileInfo::set_capture_file_data(const uint8_t* file_data, uint32_t size)
+{
+ if (file_capture)
+ file_capture->set_data(file_data, size);
+}
+
UserFileDataBase* FileInfo::get_file_data() const
{
return user_file_data;
return false;
}
- if (cacheable and (FileService::get_file_cache()->cached_verdict_lookup(p, this, policy) !=
+ if (cacheable and (FileService::get_file_cache()->cached_verdict_lookup(p, this, policy, file_data, data_size) !=
FILE_VERDICT_UNKNOWN))
{
FILE_DEBUG(file_trace, DEFAULT_TRACE_OPTION_ID, TRACE_INFO_LEVEL,
/*Fails to capture, when out of memory or size limit, need lookup*/
if (is_file_capture_enabled())
{
+ user_file_data_mutex.lock();
process_file_capture(file_data, data_size, position);
+ user_file_data_mutex.unlock();
}
finish_signature_lookup(p, ( file_state.sig_state != FILE_SIG_FLUSH ), policy);
UserFileDataBase* get_file_data() const;
void copy(const FileInfo& other, bool clear_data = true);
void reset();
+ void set_capture_file_data(const uint8_t* file_data, uint32_t size);
// Preserve the file in memory until it is released
// The file reserved will be returned and it will be detached from file context/session
FileCaptureState reserve_file(FileCapture*& dest);