*/
bool FileFlows::file_process(Packet* p, uint64_t file_id, const uint8_t* file_data,
int data_size, uint64_t offset, FileDirection dir, uint64_t multi_file_processing_id,
- FilePosition position)
+ FilePosition position, const uint8_t* fname, uint32_t name_size)
{
int64_t file_depth = FileService::get_max_file_depth();
bool continue_processing;
}
FileContext* context = get_file_context(file_id, true, is_new_context, multi_file_processing_id);
-
if (!context)
{
FILE_DEBUG(file_trace , DEFAULT_TRACE_OPTION_ID, TRACE_CRITICAL_LEVEL, p,
"file_process:context missing, returning \n");
return false;
}
+ context->set_file_name((const char*)fname, name_size, false);
if (PacketTracer::is_daq_activated())
PacketTracer::restart_timer();
* false: ignore this file
*/
bool FileFlows::file_process(Packet* p, const uint8_t* file_data, int data_size,
- FilePosition position, bool upload, size_t file_index)
+ FilePosition position, bool upload, size_t file_index, const uint8_t* fname, uint32_t name_size)
{
FileContext* context;
FileDirection direction = upload ? FILE_UPLOAD : FILE_DOWNLOAD;
context = find_main_file_context(position, direction, file_index);
set_current_file_context(context);
+ context->set_file_name((const char*)fname, name_size, false);
context->set_signature_state(gen_signature);
bool file_process_ret = context->process(p, file_data, data_size, position, file_policy);
// This is used when there is only one file per session
bool file_process(Packet* p, const uint8_t* file_data, int data_size, FilePosition,
- bool upload, size_t file_index = 0);
+ bool upload, size_t file_index = 0, const uint8_t* fname = nullptr, uint32_t name_size = 0);
// This is used for each file context. Support multiple files per session
bool file_process(Packet* p, uint64_t file_id, const uint8_t* file_data,
int data_size, uint64_t offset, FileDirection, uint64_t multi_file_processing_id=0,
- FilePosition=SNORT_FILE_POSITION_UNKNOWN);
+ FilePosition=SNORT_FILE_POSITION_UNKNOWN, const uint8_t* fname = nullptr, uint32_t name_size = 0);
static unsigned file_flow_data_id;
/*File properties*/
-void FileInfo::set_file_name(const char* name, uint32_t name_size)
+void FileInfo::set_file_name(const char* name, uint32_t name_size, bool fn_set)
{
if (name and name_size)
- {
file_name.assign(name, name_size);
- }
- file_name_set = true;
+ if (fn_set)
+ file_name_set = fn_set;
}
void FileInfo::set_url(const char* url_name, uint32_t url_size)
FileInfo& operator=(const FileInfo& other);
uint32_t get_file_type() const;
void set_file_type(uint64_t index);
- void set_file_name(const char* file_name, uint32_t name_size);
+ void set_file_name(const char* file_name, uint32_t name_size, bool fn_set = true);
void set_url(const char* url, uint32_t url_size);
std::string& get_file_name();
std::string& get_url();
{
const FileDirection dir = upload ? FILE_UPLOAD : FILE_DOWNLOAD;
continue_inspecting_file = file_flows->file_process(p, get_file_cache_file_id(), data,
- data_size, file_offset, dir, get_multiprocessing_file_id(), position);
+ data_size, file_offset, dir, get_multiprocessing_file_id(), position, (const uint8_t*)filename.c_str(),
+ filename.length());
}
else
{
continue_inspecting_file = file_flows->file_process(p, data, data_size, position,
- upload);
+ upload, 0, (const uint8_t*)filename.c_str(),
+ filename.length());
}
file_offset += data_size;
if (continue_inspecting_file and (isFileStart(position)) && log_state)
#include "decompress/file_olefile.h"
#include "file_api/file_flows.h"
#include "file_api/file_service.h"
+#include "hash/hash_key_operations.h"
#include "helpers/buffer_data.h"
#include "js_norm/js_enum.h"
#include "pub_sub/http_request_body_event.h"
const FileDirection dir = source_id == SRC_SERVER ? FILE_DOWNLOAD : FILE_UPLOAD;
- const uint64_t file_index = get_header(source_id)->get_file_cache_index();
+ uint64_t file_index = get_header(source_id)->get_file_cache_index();
+
+ const uint8_t* filename_buffer = nullptr;
+ uint32_t filename_length = 0;
+ const uint8_t* uri_buffer = nullptr;
+ uint32_t uri_length = 0;
+ if (request != nullptr)
+ get_file_info(dir, filename_buffer, filename_length, uri_buffer, uri_length);
bool continue_processing_file = file_flows->file_process(p, file_index, file_data.start(),
fp_length, session_data->file_octets[source_id], dir,
- get_header(source_id)->get_multi_file_processing_id(), file_position);
+ get_header(source_id)->get_multi_file_processing_id(), file_position,
+ filename_buffer, filename_length);
if (continue_processing_file)
{
session_data->file_depth_remaining[source_id] -= fp_length;
{
if (request != nullptr)
{
- const uint8_t* filename_buffer;
- const uint8_t* uri_buffer;
- uint32_t filename_length;
- uint32_t uri_length;
- get_file_info(dir, filename_buffer, filename_length, uri_buffer, uri_length);
-
continue_processing_file = file_flows->set_file_name(filename_buffer,
filename_length, 0,
get_header(source_id)->get_multi_file_processing_id(), uri_buffer,