"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/service_inspectors/wizard/wiz_module.cc" between
snort3-3.1.29.0.tar.gz and snort3-3.1.30.0.tar.gz

About: Snort 3 is a network intrusion prevention and detection system (IDS/IPS) combining the benefits of signature, protocol and anomaly-based inspection.

wiz_module.cc  (snort3-3.1.29.0):wiz_module.cc  (snort3-3.1.30.0)
skipping to change at line 134 skipping to change at line 134
delete curses; delete curses;
} }
void WizardModule::set_trace(const Trace* trace) const void WizardModule::set_trace(const Trace* trace) const
{ wizard_trace = trace; } { wizard_trace = trace; }
const TraceOption* WizardModule::get_trace_options() const const TraceOption* WizardModule::get_trace_options() const
{ {
static const TraceOption wizard_trace_options(nullptr, 0, nullptr); static const TraceOption wizard_trace_options(nullptr, 0, nullptr);
return &wizard_trace_options; return &wizard_trace_options;
} }
ProfileStats* WizardModule::get_profile() const ProfileStats* WizardModule::get_profile() const
{ return &wizPerfStats; } { return &wizPerfStats; }
bool WizardModule::set(const char*, Value& v, SnortConfig*) bool WizardModule::set(const char*, Value& v, SnortConfig*)
{ {
if ( v.is("service") ) if ( v.is("service") )
service = v.get_string(); service = v.get_string();
// FIXIT-L implement proto and client_first // FIXIT-L implement proto and client_first
else if ( v.is("proto") ) else if ( v.is("proto") )
return true; return true;
else if ( v.is("client_first") ) else if ( v.is("client_first") )
return true; return true;
else if ( v.is("hex") || v.is("spell") ) else if ( v.is("hex") or v.is("spell") )
{ {
if (c2s) if ( c2s )
c2s_patterns.emplace_back(v.get_string()); c2s_patterns.emplace_back(v.get_string());
else else
s2c_patterns.emplace_back(v.get_string()); s2c_patterns.emplace_back(v.get_string());
} }
else if ( v.is("curses") ) else if ( v.is("curses") )
curses->add_curse(v.get_string()); curses->add_curse(v.get_string());
else if ( v.is("max_search_depth") ) else if ( v.is("max_search_depth") )
max_search_depth = v.get_uint16(); max_search_depth = v.get_uint16();
skipping to change at line 180 skipping to change at line 181
if ( !strcmp(fqn, "wizard") ) if ( !strcmp(fqn, "wizard") )
{ {
c2s_hexes = new HexBook; c2s_hexes = new HexBook;
s2c_hexes = new HexBook; s2c_hexes = new HexBook;
c2s_spells = new SpellBook; c2s_spells = new SpellBook;
s2c_spells = new SpellBook; s2c_spells = new SpellBook;
curses = new CurseBook; curses = new CurseBook;
} }
else if ( !strcmp(fqn, "wizard.hexes") || !strcmp(fqn, "wizard.spells") ) else if ( !strcmp(fqn, "wizard.hexes") or !strcmp(fqn, "wizard.spells") )
{ {
if ( idx > 0 ) if ( idx > 0 )
{ {
service.clear(); service.clear();
c2s_patterns.clear(); c2s_patterns.clear();
s2c_patterns.clear(); s2c_patterns.clear();
} }
} }
else if ( !strcmp(fqn, "wizard.hexes.to_client") || !strcmp(fqn, "wizard.spe lls.to_client") ) else if ( !strcmp(fqn, "wizard.hexes.to_client") or !strcmp(fqn, "wizard.spe lls.to_client") )
c2s = false; c2s = false;
else if ( !strcmp(fqn, "wizard.hexes.to_server") || !strcmp(fqn, "wizard.spe lls.to_server") ) else if ( !strcmp(fqn, "wizard.hexes.to_server") or !strcmp(fqn, "wizard.spe lls.to_server") )
c2s = true; c2s = true;
return true; return true;
} }
static bool add_spells(MagicBook* b, const string& service, const vector<string> & patterns, bool hex) static bool add_spells(MagicBook* b, const string& service, const vector<string> & patterns, bool hex)
{ {
for ( const auto& p : patterns ) for ( const auto& p : patterns )
{ {
const char* val = service.c_str(); const char* val = service.c_str();
if ( !b->add_spell(p.c_str(), val) ) if ( !b->add_spell(p.c_str(), val) )
{ {
if ( !val ) if ( !val )
{ {
ParseError("Invalid %s '%s' for service '%s'", ParseError("Invalid %s '%s' for service '%s'",
hex ? "hex" : "spell", p.c_str(), service.c_str()); hex ? "hex" : "spell", p.c_str(), service.c_str());
return false; return false;
} }
else if ( service != val ) else if ( service != val )
{ {
ParseWarning(WARN_CONF, "%s '%s' for service '%s' already exists for service '%s'", ParseWarning(WARN_CONF, "%s '%s' for service '%s' already exists for service '%s'",
hex ? "Hex" : "Spell", p.c_str(), service.c_str(), val); hex ? "Hex" : "Spell", p.c_str(), service.c_str(), val);
} }
else else
{ {
ParseWarning(WARN_CONF, "Duplicate %s '%s' for service '%s'", ParseWarning(WARN_CONF, "Duplicate %s '%s' for service '%s'",
skipping to change at line 241 skipping to change at line 243
c2s_patterns.clear(); c2s_patterns.clear();
} }
else if ( !strcmp(fqn, "wizard.hexes") ) else if ( !strcmp(fqn, "wizard.hexes") )
{ {
if ( idx > 0 ) if ( idx > 0 )
{ {
// Validate the hex // Validate the hex
if ( service.empty() ) if ( service.empty() )
{ {
ParseError("Hexes must have a service name"); ParseError("Hexes must have a service name");
return false; return false;
} }
if ( c2s_patterns.empty() && s2c_patterns.empty() ) if ( c2s_patterns.empty() and s2c_patterns.empty() )
{ {
ParseError("Hexes must have at least one pattern"); ParseError("Hexes must have at least one pattern");
return false; return false;
} }
if ( !add_spells(c2s_hexes, service, c2s_patterns, true) ) if ( !add_spells(c2s_hexes, service, c2s_patterns, true) )
return false; return false;
if ( !add_spells(s2c_hexes, service, s2c_patterns, true) ) if ( !add_spells(s2c_hexes, service, s2c_patterns, true) )
return false; return false;
} }
} }
else if ( !strcmp(fqn, "wizard.spells") ) else if ( !strcmp(fqn, "wizard.spells") )
{ {
if ( idx > 0 ) if ( idx > 0 )
{ {
// Validate the spell // Validate the spell
if ( service.empty() ) if ( service.empty() )
{ {
ParseError("Spells must have a service name"); ParseError("Spells must have a service name");
return false; return false;
} }
if ( c2s_patterns.empty() && s2c_patterns.empty() ) if ( c2s_patterns.empty() and s2c_patterns.empty() )
{ {
ParseError("Spells must have at least one pattern"); ParseError("Spells must have at least one pattern");
return false; return false;
} }
if ( !add_spells(c2s_spells, service, c2s_patterns, false) ) if ( !add_spells(c2s_spells, service, c2s_patterns, false) )
return false; return false;
if ( !add_spells(s2c_spells, service, s2c_patterns, false) ) if ( !add_spells(s2c_spells, service, s2c_patterns, false) )
return false; return false;
} }
} }
return true; return true;
skipping to change at line 308 skipping to change at line 314
case 2: case 2:
b = s2c_hexes; b = s2c_hexes;
s2c_hexes = nullptr; s2c_hexes = nullptr;
break; break;
case 3: case 3:
b = c2s_hexes; b = c2s_hexes;
c2s_hexes = nullptr; c2s_hexes = nullptr;
break; break;
} }
return b; return b;
} }
CurseBook* WizardModule::get_curse_book() CurseBook* WizardModule::get_curse_book()
{ {
CurseBook* b = curses; CurseBook* b = curses;
curses = nullptr; curses = nullptr;
return b; return b;
} }
const PegInfo* WizardModule::get_pegs() const const PegInfo* WizardModule::get_pegs() const
{ return wiz_pegs; } { return wiz_pegs; }
PegCount* WizardModule::get_counts() const PegCount* WizardModule::get_counts() const
{ return (PegCount*)&tstats; } { return (PegCount*)&tstats; }
 End of changes. 15 change blocks. 
7 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)