//--------------------------------------------------------------------------
-// Copyright (C) 2014-2023 Cisco and/or its affiliates. All rights reserved.
+// Copyright (C) 2014-2024 Cisco and/or its affiliates. All rights reserved.
// Copyright (C) 2012-2013 Sourcefire, Inc.
//
// This program is free software; you can redistribute it and/or modify it
delete config;
}
-bool FileInspect::configure(SnortConfig*)
+bool FileInspect::configure(SnortConfig* sc)
{
if (!config)
return true;
file_cache->set_max_files(config->max_files_cached);
}
+ FileService::set_max_file_depth(sc);
+
return true;
}
/* Get maximal file depth based on configuration
* This function must be called after all file services are configured/enabled.
*/
-int64_t FileService::get_max_file_depth()
+int64_t FileService::get_max_file_depth(FileConfig *fc)
{
- FileConfig* file_config = get_file_config();
+ FileConfig* file_config = fc ? fc : get_file_config();
if (!file_config)
return -1;
- if (file_config->file_depth)
+ if (file_config->file_depth > 0)
return file_config->file_depth;
- file_config->file_depth = -1;
+ return -1;
+}
+
+void FileService::set_max_file_depth(const SnortConfig* sc)
+{
+ FileConfig* file_config = get_file_config(sc);
+
+ if (!file_config)
+ return;
if (file_type_id_enabled)
{
file_config->file_depth = file_config->file_type_depth;
}
- if (file_signature_enabled)
+ if ((file_signature_enabled) and
+ (file_config->file_signature_depth > file_config->file_depth))
{
- if (file_config->file_signature_depth > file_config->file_depth)
- file_config->file_depth = file_config->file_signature_depth;
+ file_config->file_depth = file_config->file_signature_depth;
}
if (file_config->file_depth > 0)
{
/*Extra byte for deciding whether file data will be over limit*/
file_config->file_depth++;
- return (file_config->file_depth);
}
- else
- {
- return -1;
- }
-}
-
-void FileService::reset_depths()
-{
- FileConfig* file_config = get_file_config();
-
- if (file_config)
- file_config->file_depth = 0;
- decode_conf.sync_all_depths();
+ return;
}
namespace snort
class FileEnforcer;
class FileCache;
+class FileConfig;
namespace snort
{
static bool is_file_signature_enabled() { return file_signature_enabled; }
static bool is_file_capture_enabled() { return file_capture_enabled; }
static bool is_file_service_enabled();
- static int64_t get_max_file_depth();
- static void reset_depths();
+ static int64_t get_max_file_depth(FileConfig* = nullptr);
+ static void set_max_file_depth(const SnortConfig*);
static FileCache* get_file_cache() { return file_cache; }
static DecodeConfig decode_conf;
#include "log/messages.h"
#include "file_api/file_service.h"
+#include "file_api/file_config.h"
using namespace snort;
}
// update file depth and max_depth etc
-void DecodeConfig::sync_all_depths()
+void DecodeConfig::sync_all_depths(const SnortConfig* sc)
{
- file_depth = FileService::get_max_file_depth();
+ file_depth = FileService::get_max_file_depth(get_file_config(sc));
decode_enabled = (file_depth >= 0) or (b64_depth >= 0) or (qp_depth >= 0) or
(bitenc_depth >= 0) or (uu_depth >= 0);
}
// List of MIME decode and log configuration functions
#include "main/snort_types.h"
+#include "main/snort_config.h"
/*These are temporary values*/
#define DEFAULT_MIME_MEMCAP 838860
int64_t get_file_depth() const;
bool is_decoding_enabled() const;
- void sync_all_depths();
+ void sync_all_depths(const SnortConfig*);
void show(bool = false) const;
int get_max_depth(int) const;
delete script_finder;
}
-bool HttpInspect::configure(SnortConfig*)
+bool HttpInspect::configure(SnortConfig* sc)
{
params->js_norm_param.configure();
- params->mime_decode_conf->sync_all_depths();
+ params->mime_decode_conf->sync_all_depths(sc);
pub_id = DataBus::get_id(http_pub_key);
return true;
delete config;
}
-bool Imap::configure(SnortConfig*)
+bool Imap::configure(SnortConfig* sc)
{
- config->decode_conf.sync_all_depths();
+ config->decode_conf.sync_all_depths(sc);
if (config->decode_conf.get_file_depth() > -1)
config->log_config.log_filename = true;
delete config;
}
-bool Pop::configure(SnortConfig* )
+bool Pop::configure(SnortConfig* sc)
{
- config->decode_conf.sync_all_depths();
+ config->decode_conf.sync_all_depths(sc);
if (config->decode_conf.get_file_depth() > -1)
config->log_config.log_filename = true;
delete config;
}
-bool Smtp::configure(SnortConfig*)
+bool Smtp::configure(SnortConfig* sc)
{
SMTP_RegXtraDataFuncs(config);
- config->decode_conf.sync_all_depths();
+ config->decode_conf.sync_all_depths(sc);
if (config->decode_conf.get_file_depth() > -1)
config->log_config.log_filename = true;