-- new_http_inspect reactiveated (no longer REG_TEST only)
-- ip defrag fixes from Josh
-- added default bindings for stream only configs
+-- added --warn-all
+-- refactored normalizer flags
+-- fixed port_scan logfile to default to off
126
-- pulled latest from tom
uint32_t checksum_eval;
uint32_t checksum_drop;
+ uint32_t normal_mask;
bool decoder_drop;
};
public:
struct FrameworkPolicy* framework_policy;
- uint32_t normal_mask;
};
//-------------------------------------------------------------------------
{ "--version", Parameter::PT_IMPLIED, nullptr, nullptr,
"show version number (same as -V)" },
+ { "--warn-all", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "enable all warnings" },
+
{ "--warn-flowbits", Parameter::PT_IMPLIED, nullptr, nullptr,
- "warn about flowbits that checked but not set and vice-versa" },
+ "warn about flowbits that are checked but not set and vice-versa" },
{ "--warn-unknown", Parameter::PT_IMPLIED, nullptr, nullptr,
"warn about unknown symbols in your config" },
else if ( v.is("--version") )
help_version(sc, v.get_string());
+ else if ( v.is("--warn-all") )
+ {
+ sc->logging_flags |= LOGGING_FLAG__WARN_FLOWBITS;
+ sc->logging_flags |= LOGGING_FLAG__WARN_UNKNOWN;
+ }
else if ( v.is("--warn-flowbits") )
sc->logging_flags |= LOGGING_FLAG__WARN_FLOWBITS;
return instance_max;
}
-
-
-
bool set_cpu_affinity(SnortConfig* sc, const std::string& str, int cpu)
{
std::map<const std::string, int>& sa = *(sc->source_affinity);
Inspector::slot = get_instance_id();
for ( auto* p : sc->framework_config->clist )
+ {
if ( p->api.tinit )
p->api.tinit();
+ }
+ // pin->tinit() only called for default policy
+ set_default_policy();
InspectionPolicy* pi = get_inspection_policy();
if ( pi && pi->framework_policy )
void InspectorManager::thread_term(SnortConfig* sc)
{
+ // pin->tterm() only called for default policy
+ set_default_policy();
InspectionPolicy* pi = get_inspection_policy();
if ( pi && pi->framework_policy )
}
for ( auto* p : sc->framework_config->clist )
+ {
if ( p->api.tterm )
p->api.tterm();
+ }
}
//-------------------------------------------------------------------------
// setup action
stuff.apply_action(flow);
- // FIXIT-H move normalizer flags to policy
- Inspector* ins = InspectorManager::get_inspector(INS_NORM);
-
- if ( ins )
- ins->exec(0, flow);
-
// setup session
stuff.apply_session(flow);
#include "utils/stats.h"
#include "perf_monitor/perf.h"
-#include "packet_io/sfdaq.h"
#include "protocols/ipv4.h"
#include "protocols/ipv4_options.h"
#include "protocols/tcp.h"
int Norm_SetConfig (NormalizerConfig* nc)
{
- if ( !DAQ_CanReplace() )
- {
- // FIXIT-L output only once
- //LogMessage("WARNING: normalizations disabled because DAQ"
- // " can't replace packets.\n");
- nc->normalizer_flags = 0x0;
- return -1;
- }
if ( !nc->normalizer_flags )
{
return 0;
{
nc->normalizers[PacketManager::proto_id(ETHERTYPE_IPV4)] = Norm_IP4;
}
- if ( Norm_IsEnabled(nc, NORM_IP4_TRIM) )
- {
- if ( !DAQ_CanInject() )
- {
- ParseWarning("normalize_ip4: trim disabled since DAQ "
- "can't inject packets.\n");
- Norm_Disable(nc, NORM_IP4_TRIM);
- }
- }
if ( Norm_IsEnabled(nc, NORM_ICMP4) )
{
nc->normalizers[PacketManager::proto_id(IPPROTO_ID_ICMPV4)] = Norm_ICMP4;
#include "norm.h"
#include "norm_module.h"
#include "packet_io/active.h"
-#include "mstring.h"
+#include "packet_io/sfdaq.h"
#include "parser.h"
#include "profiler.h"
#include "snort_types.h"
#include "flow/flow.h"
THREAD_LOCAL ProfileStats norm_perf_stats;
+static THREAD_LOCAL uint32_t t_flags = 0;
//-------------------------------------------------------------------------
// printing stuff
public:
Normalizer(const NormalizerConfig&);
- void tinit() override;
+ bool configure(SnortConfig*) override;
void show(SnortConfig*) override;
void eval(Packet*) override;
- int exec(int, void*) override;
private:
NormalizerConfig config;
config = nc;
}
-void Normalizer::tinit()
+// FIXIT-L this works with one normalizer per policy
+// but would be better if binder could select
+// in which case normal_mask must be moved to flow
+bool Normalizer::configure(SnortConfig*)
{
- // FIXIT-H this isn't good with -z > 1
- // this ensures we init just once but there is a race cond
- // with other threads that won't normalize until this is done
- if ( get_instance_id() )
- return;
-
+ // FIXIT-L norm needs a nap policy mode
if ( get_ips_policy()->policy_mode != POLICY_MODE__INLINE )
{
- ParseWarning("normalizations disabled because not inline.\n");
+ ParseWarning("normalizations disabled because not inline.");
config.normalizer_flags = 0;
- return;
+ return true;
}
NetworkPolicy* nap = get_network_policy();
+ nap->normal_mask = config.normalizer_flags;
if ( nap->new_ttl && nap->new_ttl < nap->min_ttl )
{
}
Norm_SetConfig(&config);
- return;
+ return true;
+}
+
+// FIXIT-L norm flags check should be moved to flow
+// set flow flags once at start of flow
+bool Normalize_IsEnabled(NormFlags nf)
+{
+ if ( !(t_flags & nf) )
+ return false;
+
+ NetworkPolicy* nap = get_network_policy();
+ return ( (nap->normal_mask & nf) != 0 );
}
void Normalizer::show(SnortConfig* sc)
return;
}
-int Normalizer::exec(int, void* pv)
-{
- Flow* flow = (Flow*)pv;
- assert(flow);
- InspectionPolicy* pi = get_inspection_policy();
- pi->normal_mask = config.normalizer_flags;
- return 0;
-}
-
//-------------------------------------------------------------------------
// api stuff
//-------------------------------------------------------------------------
delete p;
}
+static void no_tinit()
+{
+ if ( DAQ_CanReplace() )
+ t_flags = NORM_ALL;
+
+ if ( !DAQ_CanInject() )
+ t_flags &= ~NORM_IP4_TRIM;
+}
+
static const InspectApi no_api =
{
{
nullptr, // service
nullptr, // pinit
nullptr, // pterm
- nullptr, // tinit
+ no_tinit,
nullptr, // tterm
no_ctor,
no_dtor,
NORM_ALL = 0x0003FFFF // all normalizations on
} NormFlags;
-static inline int Normalize_IsEnabled(NormFlags nf)
-{
- InspectionPolicy* pi = get_inspection_policy();
- return ( (pi->normal_mask & nf) != 0 );
-}
+bool Normalize_IsEnabled(NormFlags);
#endif
void PerfMonitor::tinit()
{
- // FIXIT-H this isn't good with -z > 1
- // need thread local per config instance or restructure
- // (file names are ok but not hash table)
- if ( !get_instance_id() )
- InitPerfStats(&config);
+ InitPerfStats(&config);
}
void PerfMonitor::tterm()
LogMessage(" Number of Nodes: %ld\n",
config->common->memcap / (sizeof(PS_PROTO)*proto_cnt-1));
- if (config->logfile != NULL)
- LogMessage(" Logfile: %s\n", config->logfile);
+ if ( config->logfile )
+ LogMessage(" Logfile: %s\n", "yes");
if(config->ignore_scanners)
{
bool PortScan::configure(SnortConfig* sc)
{
- // FIXIT-L use fixed base file name
- config->logfile = SnortStrdup("portscan.log");
-
global = (PsData*)DataManager::acquire(PSG_NAME, sc);
config->common = global->data;
return true;
void PortScan::tinit()
{
g_tmp_pkt = PacketManager::encode_new();
+ ps_init_hash(config->common->memcap);
+
+ if ( !config->logfile )
+ return;
std::string name;
- get_instance_file(name, config->logfile);
+ get_instance_file(name, "portscan.log");
g_logfile = fopen(name.c_str(), "a+");
- if (g_logfile == NULL)
+ if ( !g_logfile )
{
FatalError("Portscan log file '%s' could not be opened: %s.\n",
- config->logfile, get_error(errno));
+ name.c_str(), get_error(errno));
}
- ps_init_hash(config->common->memcap);
}
void PortScan::tterm()
{
- fclose(g_logfile);
+ if ( g_logfile )
+ {
+ fclose(g_logfile);
+ g_logfile = nullptr;
+ }
ps_cleanup();
PacketManager::encode_delete(g_tmp_pkt);
g_tmp_pkt = NULL;
PortscanConfig::~PortscanConfig()
{
- if ( logfile )
- free(logfile);
-
if ( ignore_scanners )
ipset_free(ignore_scanners);
int proto_cnt;
int include_midstream;
int print_tracker;
- char *logfile;
+ bool logfile;
IPSET *ignore_scanners;
IPSET *ignore_scanned;
{ "include_midstream", Parameter::PT_BOOL, nullptr, "false",
"list of CIDRs with optional ports" },
+ { "logfile", Parameter::PT_BOOL, nullptr, "false",
+ "write scan events to file" },
+
{ nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
};
if ( !ips || ipset_parse(ips, v.get_string()) )
return false;
}
+ else if ( v.is("logfile") )
+ config->logfile = v.get_bool();
+
else
return false;
bool Defrag::configure(SnortConfig* sc)
{
+ // FIXIT-L kinda squiffy ... set for each instance
+ // (but to same value) ... move to tinit() ?
layers = sc->get_num_layers();
return true;
}