Use const-references in lots of places (preformance-unnecessary-value-param)

This commit is contained in:
Tim Wojtulewicz 2020-02-11 14:11:18 -08:00
parent 92afe64525
commit 5a237d3a3f
27 changed files with 89 additions and 89 deletions

View file

@ -405,7 +405,7 @@ analyzer::Analyzer* Connection::FindAnalyzer(analyzer::ID id)
return root_analyzer ? root_analyzer->FindChild(id) : 0; return root_analyzer ? root_analyzer->FindChild(id) : 0;
} }
analyzer::Analyzer* Connection::FindAnalyzer(analyzer::Tag tag) analyzer::Analyzer* Connection::FindAnalyzer(const analyzer::Tag& tag)
{ {
return root_analyzer ? root_analyzer->FindChild(tag) : 0; return root_analyzer ? root_analyzer->FindChild(tag) : 0;
} }

View file

@ -111,7 +111,7 @@ public:
void FlipRoles(); void FlipRoles();
analyzer::Analyzer* FindAnalyzer(analyzer::ID id); analyzer::Analyzer* FindAnalyzer(analyzer::ID id);
analyzer::Analyzer* FindAnalyzer(analyzer::Tag tag); // find first in tree. analyzer::Analyzer* FindAnalyzer(const analyzer::Tag& tag); // find first in tree.
analyzer::Analyzer* FindAnalyzer(const char* name); // find first in tree. analyzer::Analyzer* FindAnalyzer(const char* name); // find first in tree.
TransportProto ConnTransport() const { return proto; } TransportProto ConnTransport() const { return proto; }

View file

@ -276,7 +276,7 @@ Frame* Frame::SelectiveClone(const id_list& selection, BroFunc* func) const
return other; return other;
} }
broker::expected<broker::data> Frame::Serialize(const Frame* target, id_list selection) broker::expected<broker::data> Frame::Serialize(const Frame* target, const id_list& selection)
{ {
broker::vector rval; broker::vector rval;

View file

@ -180,7 +180,7 @@ public:
* @return the broker representaton, or an error if the serialization * @return the broker representaton, or an error if the serialization
* failed. * failed.
*/ */
static broker::expected<broker::data> Serialize(const Frame* target, const id_list selection); static broker::expected<broker::data> Serialize(const Frame* target, const id_list& selection);
/** /**
* Instantiates a Frame from a serialized one. * Instantiates a Frame from a serialized one.

View file

@ -403,7 +403,7 @@ bool Analyzer::AddChildAnalyzer(Analyzer* analyzer, bool init)
return true; return true;
} }
Analyzer* Analyzer::AddChildAnalyzer(Tag analyzer) Analyzer* Analyzer::AddChildAnalyzer(const Tag& analyzer)
{ {
if ( HasChildAnalyzer(analyzer) ) if ( HasChildAnalyzer(analyzer) )
return nullptr; return nullptr;
@ -605,7 +605,7 @@ void Analyzer::RemoveSupportAnalyzer(SupportAnalyzer* analyzer)
return; return;
} }
bool Analyzer::HasSupportAnalyzer(Tag tag, bool orig) bool Analyzer::HasSupportAnalyzer(const Tag& tag, bool orig)
{ {
SupportAnalyzer* s = orig ? orig_supporters : resp_supporters; SupportAnalyzer* s = orig ? orig_supporters : resp_supporters;
for ( ; s; s = s->sibling ) for ( ; s; s = s->sibling )

View file

@ -378,7 +378,7 @@ public:
* @param tag The type of analyzer to add. * @param tag The type of analyzer to add.
* @return the new analyzer instance that was added. * @return the new analyzer instance that was added.
*/ */
Analyzer* AddChildAnalyzer(Tag tag); Analyzer* AddChildAnalyzer(const Tag& tag);
/** /**
* Removes a child analyzer. It's ok for the analyzer to not to be a * Removes a child analyzer. It's ok for the analyzer to not to be a
@ -647,7 +647,7 @@ protected:
* *
* @param orig True if asking about the originator side. * @param orig True if asking about the originator side.
*/ */
bool HasSupportAnalyzer(Tag tag, bool orig); bool HasSupportAnalyzer(const Tag& tag, bool orig);
/** /**
* Returns the first still active support analyzer for the given * Returns the first still active support analyzer for the given

View file

@ -145,7 +145,7 @@ void Manager::Done()
{ {
} }
bool Manager::EnableAnalyzer(Tag tag) bool Manager::EnableAnalyzer(const Tag& tag)
{ {
Component* p = Lookup(tag); Component* p = Lookup(tag);
@ -171,7 +171,7 @@ bool Manager::EnableAnalyzer(EnumVal* val)
return true; return true;
} }
bool Manager::DisableAnalyzer(Tag tag) bool Manager::DisableAnalyzer(const Tag& tag)
{ {
Component* p = Lookup(tag); Component* p = Lookup(tag);
@ -211,7 +211,7 @@ analyzer::Tag Manager::GetAnalyzerTag(const char* name)
return GetComponentTag(name); return GetComponentTag(name);
} }
bool Manager::IsEnabled(Tag tag) bool Manager::IsEnabled(const Tag& tag)
{ {
if ( ! tag ) if ( ! tag )
return false; return false;
@ -255,7 +255,7 @@ bool Manager::UnregisterAnalyzerForPort(EnumVal* val, PortVal* port)
return UnregisterAnalyzerForPort(p->Tag(), port->PortType(), port->Port()); return UnregisterAnalyzerForPort(p->Tag(), port->PortType(), port->Port());
} }
bool Manager::RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port) bool Manager::RegisterAnalyzerForPort(const Tag& tag, TransportProto proto, uint32_t port)
{ {
tag_set* l = LookupPort(proto, port, true); tag_set* l = LookupPort(proto, port, true);
@ -271,7 +271,7 @@ bool Manager::RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t po
return true; return true;
} }
bool Manager::UnregisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port) bool Manager::UnregisterAnalyzerForPort(const Tag& tag, TransportProto proto, uint32_t port)
{ {
tag_set* l = LookupPort(proto, port, true); tag_set* l = LookupPort(proto, port, true);
@ -287,7 +287,7 @@ bool Manager::UnregisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t
return true; return true;
} }
Analyzer* Manager::InstantiateAnalyzer(Tag tag, Connection* conn) Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, Connection* conn)
{ {
Component* c = Lookup(tag); Component* c = Lookup(tag);
@ -542,7 +542,7 @@ void Manager::ExpireScheduledAnalyzers()
void Manager::ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp, void Manager::ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp,
uint16_t resp_p, uint16_t resp_p,
TransportProto proto, Tag analyzer, TransportProto proto, const Tag& analyzer,
double timeout) double timeout)
{ {
if ( ! network_time ) if ( ! network_time )

View file

@ -90,7 +90,7 @@ public:
* *
* @return True if successful. * @return True if successful.
*/ */
bool EnableAnalyzer(Tag tag); bool EnableAnalyzer(const Tag& tag);
/** /**
* Enables an analyzer type. Only enabled analyzers will be * Enables an analyzer type. Only enabled analyzers will be
@ -111,7 +111,7 @@ public:
* *
* @return True if successful. * @return True if successful.
*/ */
bool DisableAnalyzer(Tag tag); bool DisableAnalyzer(const Tag& tag);
/** /**
* Disables an analyzer type. Disabled analyzers will not be * Disables an analyzer type. Disabled analyzers will not be
@ -142,7 +142,7 @@ public:
* *
* @param tag The analyzer's tag. * @param tag The analyzer's tag.
*/ */
bool IsEnabled(Tag tag); bool IsEnabled(const Tag& tag);
/** /**
* Returns true if an analyzer is enabled. * Returns true if an analyzer is enabled.
@ -179,7 +179,7 @@ public:
* *
* @return True if successful. * @return True if successful.
*/ */
bool RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port); bool RegisterAnalyzerForPort(const Tag& tag, TransportProto proto, uint32_t port);
/** /**
* Unregisters a well-known port for an anlyzers. * Unregisters a well-known port for an anlyzers.
@ -207,7 +207,7 @@ public:
* @param tag The analyzer's tag as an enum of script type \c * @param tag The analyzer's tag as an enum of script type \c
* Analyzer::Tag. * Analyzer::Tag.
*/ */
bool UnregisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port); bool UnregisterAnalyzerForPort(const Tag& tag, TransportProto proto, uint32_t port);
/** /**
* Instantiates a new analyzer instance for a connection. * Instantiates a new analyzer instance for a connection.
@ -221,7 +221,7 @@ public:
* null if tag is invalid, the requested analyzer is disabled, or the * null if tag is invalid, the requested analyzer is disabled, or the
* analyzer can't be instantiated. * analyzer can't be instantiated.
*/ */
Analyzer* InstantiateAnalyzer(Tag tag, Connection* c); Analyzer* InstantiateAnalyzer(const Tag& tag, Connection* c);
/** /**
* Instantiates a new analyzer instance for a connection. * Instantiates a new analyzer instance for a connection.
@ -269,7 +269,7 @@ public:
* schedule this analyzer. Must be non-zero. * schedule this analyzer. Must be non-zero.
*/ */
void ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp, uint16_t resp_p, void ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp, uint16_t resp_p,
TransportProto proto, Tag analyzer, double timeout); TransportProto proto, const Tag& analyzer, double timeout);
/** /**
* Schedules a particular analyzer for an upcoming connection. Once * Schedules a particular analyzer for an upcoming connection. Once

View file

@ -1206,11 +1206,11 @@ void IRC_Analyzer::StartTLS()
ConnectionEventFast(irc_starttls, {BuildConnVal()}); ConnectionEventFast(irc_starttls, {BuildConnVal()});
} }
vector<string> IRC_Analyzer::SplitWords(const string input, const char split) vector<string> IRC_Analyzer::SplitWords(const string& input, char split)
{ {
vector<string> words; vector<string> words;
if ( input.size() < 1 ) if ( input.empty() )
return words; return words;
unsigned int start = 0; unsigned int start = 0;

View file

@ -62,11 +62,11 @@ private:
* \param split character which separates the words * \param split character which separates the words
* \return vector containing words * \return vector containing words
*/ */
vector<string> SplitWords(const string input, const char split); vector<string> SplitWords(const string& input, char split);
tcp::ContentLine_Analyzer* cl_orig; tcp::ContentLine_Analyzer* cl_orig;
tcp::ContentLine_Analyzer* cl_resp; tcp::ContentLine_Analyzer* cl_resp;
bool starttls; // if true, connection has been upgraded to tls bool starttls; // if true, connection has been upgraded to tls
}; };
} } // namespace analyzer::* } } // namespace analyzer::*

View file

@ -8,13 +8,13 @@
# #
%header{ %header{
VectorVal* bytestring_to_coils(bytestring coils, uint quantity); VectorVal* bytestring_to_coils(const bytestring& coils, uint quantity);
RecordVal* HeaderToBro(ModbusTCP_TransportHeader *header); RecordVal* HeaderToBro(ModbusTCP_TransportHeader *header);
VectorVal* create_vector_of_count(); VectorVal* create_vector_of_count();
%} %}
%code{ %code{
VectorVal* bytestring_to_coils(bytestring coils, uint quantity) VectorVal* bytestring_to_coils(const bytestring& coils, uint quantity)
{ {
VectorVal* modbus_coils = new VectorVal(BifType::Vector::ModbusCoils); VectorVal* modbus_coils = new VectorVal(BifType::Vector::ModbusCoils);
for ( uint i = 0; i < quantity; i++ ) for ( uint i = 0; i < quantity; i++ )

View file

@ -884,7 +884,7 @@ int POP3_Analyzer::ParseCmd(string cmd)
return -1; return -1;
} }
vector<string> POP3_Analyzer::TokenizeLine(const string input, const char split) vector<string> POP3_Analyzer::TokenizeLine(const string& input, char split)
{ {
vector<string> tokens; vector<string> tokens;

View file

@ -99,7 +99,7 @@ protected:
void EndData(); void EndData();
void StartTLS(); void StartTLS();
vector<string> TokenizeLine(const string input, const char split); vector<string> TokenizeLine(const string& input, char split);
int ParseCmd(string cmd); int ParseCmd(string cmd);
void AuthSuccessfull(); void AuthSuccessfull();
void POP3Event(EventHandlerPtr event, bool is_orig, void POP3Event(EventHandlerPtr event, bool is_orig,
@ -114,4 +114,4 @@ private:
tcp::ContentLine_Analyzer* cl_resp; tcp::ContentLine_Analyzer* cl_resp;
}; };
} } // namespace analyzer::* } } // namespace analyzer::*

View file

@ -5,12 +5,12 @@
%} %}
%header{ %header{
VectorVal* name_list_to_vector(const bytestring nl); VectorVal* name_list_to_vector(const bytestring& nl);
%} %}
%code{ %code{
// Copied from IRC_Analyzer::SplitWords // Copied from IRC_Analyzer::SplitWords
VectorVal* name_list_to_vector(const bytestring nl) VectorVal* name_list_to_vector(const bytestring& nl)
{ {
VectorVal* vv = new VectorVal(internal_type("string_vec")->AsVectorType()); VectorVal* vv = new VectorVal(internal_type("string_vec")->AsVectorType());

View file

@ -38,7 +38,7 @@ AnalyzerSet::~AnalyzerSet()
delete analyzer_hash; delete analyzer_hash;
} }
Analyzer* AnalyzerSet::Find(file_analysis::Tag tag, RecordVal* args) Analyzer* AnalyzerSet::Find(const file_analysis::Tag& tag, RecordVal* args)
{ {
HashKey* key = GetKey(tag, args); HashKey* key = GetKey(tag, args);
Analyzer* rval = analyzer_map.Lookup(key); Analyzer* rval = analyzer_map.Lookup(key);
@ -46,7 +46,7 @@ Analyzer* AnalyzerSet::Find(file_analysis::Tag tag, RecordVal* args)
return rval; return rval;
} }
bool AnalyzerSet::Add(file_analysis::Tag tag, RecordVal* args) bool AnalyzerSet::Add(const file_analysis::Tag& tag, RecordVal* args)
{ {
HashKey* key = GetKey(tag, args); HashKey* key = GetKey(tag, args);
@ -73,7 +73,7 @@ bool AnalyzerSet::Add(file_analysis::Tag tag, RecordVal* args)
return true; return true;
} }
Analyzer* AnalyzerSet::QueueAdd(file_analysis::Tag tag, RecordVal* args) Analyzer* AnalyzerSet::QueueAdd(const file_analysis::Tag& tag, RecordVal* args)
{ {
HashKey* key = GetKey(tag, args); HashKey* key = GetKey(tag, args);
file_analysis::Analyzer* a = InstantiateAnalyzer(tag, args); file_analysis::Analyzer* a = InstantiateAnalyzer(tag, args);
@ -106,12 +106,12 @@ bool AnalyzerSet::AddMod::Perform(AnalyzerSet* set)
return true; return true;
} }
bool AnalyzerSet::Remove(file_analysis::Tag tag, RecordVal* args) bool AnalyzerSet::Remove(const file_analysis::Tag& tag, RecordVal* args)
{ {
return Remove(tag, GetKey(tag, args)); return Remove(tag, GetKey(tag, args));
} }
bool AnalyzerSet::Remove(file_analysis::Tag tag, HashKey* key) bool AnalyzerSet::Remove(const file_analysis::Tag& tag, HashKey* key)
{ {
file_analysis::Analyzer* a = file_analysis::Analyzer* a =
(file_analysis::Analyzer*) analyzer_map.Remove(key); (file_analysis::Analyzer*) analyzer_map.Remove(key);
@ -139,7 +139,7 @@ bool AnalyzerSet::Remove(file_analysis::Tag tag, HashKey* key)
return true; return true;
} }
bool AnalyzerSet::QueueRemove(file_analysis::Tag tag, RecordVal* args) bool AnalyzerSet::QueueRemove(const file_analysis::Tag& tag, RecordVal* args)
{ {
HashKey* key = GetKey(tag, args); HashKey* key = GetKey(tag, args);
@ -153,7 +153,7 @@ bool AnalyzerSet::RemoveMod::Perform(AnalyzerSet* set)
return set->Remove(tag, key); return set->Remove(tag, key);
} }
HashKey* AnalyzerSet::GetKey(file_analysis::Tag t, RecordVal* args) const HashKey* AnalyzerSet::GetKey(const file_analysis::Tag& t, RecordVal* args) const
{ {
ListVal* lv = new ListVal(TYPE_ANY); ListVal* lv = new ListVal(TYPE_ANY);
lv->Append(t.AsEnumVal()->Ref()); lv->Append(t.AsEnumVal()->Ref());
@ -166,7 +166,7 @@ HashKey* AnalyzerSet::GetKey(file_analysis::Tag t, RecordVal* args) const
return key; return key;
} }
file_analysis::Analyzer* AnalyzerSet::InstantiateAnalyzer(Tag tag, file_analysis::Analyzer* AnalyzerSet::InstantiateAnalyzer(const Tag& tag,
RecordVal* args) const RecordVal* args) const
{ {
file_analysis::Analyzer* a = file_mgr->InstantiateAnalyzer(tag, args, file); file_analysis::Analyzer* a = file_mgr->InstantiateAnalyzer(tag, args, file);

View file

@ -41,7 +41,7 @@ public:
* @param args an \c AnalyzerArgs record. * @param args an \c AnalyzerArgs record.
* @return pointer to an analyzer instance, or a null pointer if not found. * @return pointer to an analyzer instance, or a null pointer if not found.
*/ */
Analyzer* Find(file_analysis::Tag tag, RecordVal* args); Analyzer* Find(const file_analysis::Tag& tag, RecordVal* args);
/** /**
* Attach an analyzer to #file immediately. * Attach an analyzer to #file immediately.
@ -49,7 +49,7 @@ public:
* @param args an \c AnalyzerArgs value which specifies an analyzer. * @param args an \c AnalyzerArgs value which specifies an analyzer.
* @return true if analyzer was instantiated/attached, else false. * @return true if analyzer was instantiated/attached, else false.
*/ */
bool Add(file_analysis::Tag tag, RecordVal* args); bool Add(const file_analysis::Tag& tag, RecordVal* args);
/** /**
* Queue the attachment of an analyzer to #file. * Queue the attachment of an analyzer to #file.
@ -58,7 +58,7 @@ public:
* @return if successful, a pointer to a newly instantiated analyzer else * @return if successful, a pointer to a newly instantiated analyzer else
* a null pointer. The caller does *not* take ownership of the memory. * a null pointer. The caller does *not* take ownership of the memory.
*/ */
file_analysis::Analyzer* QueueAdd(file_analysis::Tag tag, RecordVal* args); file_analysis::Analyzer* QueueAdd(const file_analysis::Tag& tag, RecordVal* args);
/** /**
* Remove an analyzer from #file immediately. * Remove an analyzer from #file immediately.
@ -66,7 +66,7 @@ public:
* @param args an \c AnalyzerArgs value which specifies an analyzer. * @param args an \c AnalyzerArgs value which specifies an analyzer.
* @return false if analyzer didn't exist and so wasn't removed, else true. * @return false if analyzer didn't exist and so wasn't removed, else true.
*/ */
bool Remove(file_analysis::Tag tag, RecordVal* args); bool Remove(const file_analysis::Tag& tag, RecordVal* args);
/** /**
* Queue the removal of an analyzer from #file. * Queue the removal of an analyzer from #file.
@ -74,7 +74,7 @@ public:
* @param args an \c AnalyzerArgs value which specifies an analyzer. * @param args an \c AnalyzerArgs value which specifies an analyzer.
* @return true if analyzer exists at time of call, else false; * @return true if analyzer exists at time of call, else false;
*/ */
bool QueueRemove(file_analysis::Tag tag, RecordVal* args); bool QueueRemove(const file_analysis::Tag& tag, RecordVal* args);
/** /**
* Perform all queued modifications to the current analyzer set. * Perform all queued modifications to the current analyzer set.
@ -107,7 +107,7 @@ protected:
* @param args an \c AnalyzerArgs value which specifies an analyzer. * @param args an \c AnalyzerArgs value which specifies an analyzer.
* @return the hash key calculated from \a args * @return the hash key calculated from \a args
*/ */
HashKey* GetKey(file_analysis::Tag tag, RecordVal* args) const; HashKey* GetKey(const file_analysis::Tag& tag, RecordVal* args) const;
/** /**
* Create an instance of a file analyzer. * Create an instance of a file analyzer.
@ -115,7 +115,7 @@ protected:
* @param args an \c AnalyzerArgs value which specifies an analyzer. * @param args an \c AnalyzerArgs value which specifies an analyzer.
* @return a new file analyzer instance. * @return a new file analyzer instance.
*/ */
file_analysis::Analyzer* InstantiateAnalyzer(file_analysis::Tag tag, file_analysis::Analyzer* InstantiateAnalyzer(const file_analysis::Tag& tag,
RecordVal* args) const; RecordVal* args) const;
/** /**
@ -131,7 +131,7 @@ protected:
* just used for debugging messages. * just used for debugging messages.
* @param key the hash key which represents the analyzer's \c AnalyzerArgs. * @param key the hash key which represents the analyzer's \c AnalyzerArgs.
*/ */
bool Remove(file_analysis::Tag tag, HashKey* key); bool Remove(const file_analysis::Tag& tag, HashKey* key);
private: private:
@ -190,7 +190,7 @@ private:
* @param arg_a an analyzer instance to add to an analyzer set. * @param arg_a an analyzer instance to add to an analyzer set.
* @param arg_key hash key representing the analyzer's \c AnalyzerArgs. * @param arg_key hash key representing the analyzer's \c AnalyzerArgs.
*/ */
RemoveMod(file_analysis::Tag arg_tag, HashKey* arg_key) RemoveMod(const file_analysis::Tag& arg_tag, HashKey* arg_key)
: Modification(), tag(arg_tag), key(arg_key) {} : Modification(), tag(arg_tag), key(arg_key) {}
~RemoveMod() override {} ~RemoveMod() override {}
bool Perform(AnalyzerSet* set) override; bool Perform(AnalyzerSet* set) override;

View file

@ -100,7 +100,7 @@ void Manager::SetHandle(const string& handle)
} }
string Manager::DataIn(const u_char* data, uint64_t len, uint64_t offset, string Manager::DataIn(const u_char* data, uint64_t len, uint64_t offset,
analyzer::Tag tag, Connection* conn, bool is_orig, const analyzer::Tag& tag, Connection* conn, bool is_orig,
const string& precomputed_id, const string& mime_type) const string& precomputed_id, const string& mime_type)
{ {
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id; string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
@ -129,7 +129,7 @@ string Manager::DataIn(const u_char* data, uint64_t len, uint64_t offset,
return id; return id;
} }
string Manager::DataIn(const u_char* data, uint64_t len, analyzer::Tag tag, string Manager::DataIn(const u_char* data, uint64_t len, const analyzer::Tag& tag,
Connection* conn, bool is_orig, const string& precomputed_id, Connection* conn, bool is_orig, const string& precomputed_id,
const string& mime_type) const string& mime_type)
{ {
@ -170,13 +170,13 @@ void Manager::DataIn(const u_char* data, uint64_t len, const string& file_id,
RemoveFile(file->GetID()); RemoveFile(file->GetID());
} }
void Manager::EndOfFile(analyzer::Tag tag, Connection* conn) void Manager::EndOfFile(const analyzer::Tag& tag, Connection* conn)
{ {
EndOfFile(tag, conn, true); EndOfFile(tag, conn, true);
EndOfFile(tag, conn, false); EndOfFile(tag, conn, false);
} }
void Manager::EndOfFile(analyzer::Tag tag, Connection* conn, bool is_orig) void Manager::EndOfFile(const analyzer::Tag& tag, Connection* conn, bool is_orig)
{ {
// Don't need to create a file if we're just going to remove it right away. // Don't need to create a file if we're just going to remove it right away.
RemoveFile(GetFileID(tag, conn, is_orig)); RemoveFile(GetFileID(tag, conn, is_orig));
@ -187,7 +187,7 @@ void Manager::EndOfFile(const string& file_id)
RemoveFile(file_id); RemoveFile(file_id);
} }
string Manager::Gap(uint64_t offset, uint64_t len, analyzer::Tag tag, string Manager::Gap(uint64_t offset, uint64_t len, const analyzer::Tag& tag,
Connection* conn, bool is_orig, const string& precomputed_id) Connection* conn, bool is_orig, const string& precomputed_id)
{ {
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id; string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
@ -200,7 +200,7 @@ string Manager::Gap(uint64_t offset, uint64_t len, analyzer::Tag tag,
return id; return id;
} }
string Manager::SetSize(uint64_t size, analyzer::Tag tag, Connection* conn, string Manager::SetSize(uint64_t size, const analyzer::Tag& tag, Connection* conn,
bool is_orig, const string& precomputed_id) bool is_orig, const string& precomputed_id)
{ {
string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id; string id = precomputed_id.empty() ? GetFileID(tag, conn, is_orig) : precomputed_id;
@ -278,7 +278,7 @@ bool Manager::SetExtractionLimit(const string& file_id, RecordVal* args,
return file->SetExtractionLimit(args, n); return file->SetExtractionLimit(args, n);
} }
bool Manager::AddAnalyzer(const string& file_id, file_analysis::Tag tag, bool Manager::AddAnalyzer(const string& file_id, const file_analysis::Tag& tag,
RecordVal* args) const RecordVal* args) const
{ {
File* file = LookupFile(file_id); File* file = LookupFile(file_id);
@ -289,7 +289,7 @@ bool Manager::AddAnalyzer(const string& file_id, file_analysis::Tag tag,
return file->AddAnalyzer(tag, args); return file->AddAnalyzer(tag, args);
} }
bool Manager::RemoveAnalyzer(const string& file_id, file_analysis::Tag tag, bool Manager::RemoveAnalyzer(const string& file_id, const file_analysis::Tag& tag,
RecordVal* args) const RecordVal* args) const
{ {
File* file = LookupFile(file_id); File* file = LookupFile(file_id);
@ -301,7 +301,7 @@ bool Manager::RemoveAnalyzer(const string& file_id, file_analysis::Tag tag,
} }
File* Manager::GetFile(const string& file_id, Connection* conn, File* Manager::GetFile(const string& file_id, Connection* conn,
analyzer::Tag tag, bool is_orig, bool update_conn, const analyzer::Tag& tag, bool is_orig, bool update_conn,
const char* source_name) const char* source_name)
{ {
if ( file_id.empty() ) if ( file_id.empty() )
@ -417,7 +417,7 @@ bool Manager::IsIgnored(const string& file_id)
return ignored.find(file_id) != ignored.end(); return ignored.find(file_id) != ignored.end();
} }
string Manager::GetFileID(analyzer::Tag tag, Connection* c, bool is_orig) string Manager::GetFileID(const analyzer::Tag& tag, Connection* c, bool is_orig)
{ {
current_file_id.clear(); current_file_id.clear();
@ -442,7 +442,7 @@ string Manager::GetFileID(analyzer::Tag tag, Connection* c, bool is_orig)
return current_file_id; return current_file_id;
} }
bool Manager::IsDisabled(analyzer::Tag tag) bool Manager::IsDisabled(const analyzer::Tag& tag)
{ {
if ( ! disabled ) if ( ! disabled )
disabled = internal_const_val("Files::disable")->AsTableVal(); disabled = internal_const_val("Files::disable")->AsTableVal();
@ -460,7 +460,7 @@ bool Manager::IsDisabled(analyzer::Tag tag)
return rval; return rval;
} }
Analyzer* Manager::InstantiateAnalyzer(Tag tag, RecordVal* args, File* f) const Analyzer* Manager::InstantiateAnalyzer(const Tag& tag, RecordVal* args, File* f) const
{ {
Component* c = Lookup(tag); Component* c = Lookup(tag);

View file

@ -110,7 +110,7 @@ public:
* indicates the associate file is not going to be analyzed further. * indicates the associate file is not going to be analyzed further.
*/ */
std::string DataIn(const u_char* data, uint64_t len, uint64_t offset, std::string DataIn(const u_char* data, uint64_t len, uint64_t offset,
analyzer::Tag tag, Connection* conn, bool is_orig, const analyzer::Tag& tag, Connection* conn, bool is_orig,
const std::string& precomputed_file_id = "", const std::string& precomputed_file_id = "",
const std::string& mime_type = ""); const std::string& mime_type = "");
@ -136,7 +136,7 @@ public:
* the \c get_file_handle script-layer event). An empty string * the \c get_file_handle script-layer event). An empty string
* indicates the associated file is not going to be analyzed further. * indicates the associated file is not going to be analyzed further.
*/ */
std::string DataIn(const u_char* data, uint64_t len, analyzer::Tag tag, std::string DataIn(const u_char* data, uint64_t len, const analyzer::Tag& tag,
Connection* conn, bool is_orig, Connection* conn, bool is_orig,
const std::string& precomputed_file_id = "", const std::string& precomputed_file_id = "",
const std::string& mime_type = ""); const std::string& mime_type = "");
@ -159,7 +159,7 @@ public:
* @param tag network protocol over which the file data is transferred. * @param tag network protocol over which the file data is transferred.
* @param conn network connection over which the file data is transferred. * @param conn network connection over which the file data is transferred.
*/ */
void EndOfFile(analyzer::Tag tag, Connection* conn); void EndOfFile(const analyzer::Tag& tag, Connection* conn);
/** /**
* Signal the end of file data being transferred over a connection in * Signal the end of file data being transferred over a connection in
@ -167,7 +167,7 @@ public:
* @param tag network protocol over which the file data is transferred. * @param tag network protocol over which the file data is transferred.
* @param conn network connection over which the file data is transferred. * @param conn network connection over which the file data is transferred.
*/ */
void EndOfFile(analyzer::Tag tag, Connection* conn, bool is_orig); void EndOfFile(const analyzer::Tag& tag, Connection* conn, bool is_orig);
/** /**
* Signal the end of file data being transferred using the file identifier. * Signal the end of file data being transferred using the file identifier.
@ -191,7 +191,7 @@ public:
* the \c get_file_handle script-layer event). An empty string * the \c get_file_handle script-layer event). An empty string
* indicates the associate file is not going to be analyzed further. * indicates the associate file is not going to be analyzed further.
*/ */
std::string Gap(uint64_t offset, uint64_t len, analyzer::Tag tag, std::string Gap(uint64_t offset, uint64_t len, const analyzer::Tag& tag,
Connection* conn, bool is_orig, Connection* conn, bool is_orig,
const std::string& precomputed_file_id = ""); const std::string& precomputed_file_id = "");
@ -210,7 +210,7 @@ public:
* the \c get_file_handle script-layer event). An empty string * the \c get_file_handle script-layer event). An empty string
* indicates the associate file is not going to be analyzed further. * indicates the associate file is not going to be analyzed further.
*/ */
std::string SetSize(uint64_t size, analyzer::Tag tag, Connection* conn, std::string SetSize(uint64_t size, const analyzer::Tag& tag, Connection* conn,
bool is_orig, const std::string& precomputed_file_id = ""); bool is_orig, const std::string& precomputed_file_id = "");
/** /**
@ -276,7 +276,7 @@ public:
* @param args a \c AnalyzerArgs value which describes a file analyzer. * @param args a \c AnalyzerArgs value which describes a file analyzer.
* @return false if the analyzer failed to be instantiated, else true. * @return false if the analyzer failed to be instantiated, else true.
*/ */
bool AddAnalyzer(const string& file_id, file_analysis::Tag tag, bool AddAnalyzer(const string& file_id, const file_analysis::Tag& tag,
RecordVal* args) const; RecordVal* args) const;
/** /**
@ -286,7 +286,7 @@ public:
* @param args a \c AnalyzerArgs value which describes a file analyzer. * @param args a \c AnalyzerArgs value which describes a file analyzer.
* @return true if the analyzer is active at the time of call, else false. * @return true if the analyzer is active at the time of call, else false.
*/ */
bool RemoveAnalyzer(const string& file_id, file_analysis::Tag tag, bool RemoveAnalyzer(const string& file_id, const file_analysis::Tag& tag,
RecordVal* args) const; RecordVal* args) const;
/** /**
@ -303,7 +303,7 @@ public:
* @param f The file analzer is to be associated with. * @param f The file analzer is to be associated with.
* @return The new analyzer instance or null if tag is invalid. * @return The new analyzer instance or null if tag is invalid.
*/ */
Analyzer* InstantiateAnalyzer(Tag tag, RecordVal* args, File* f) const; Analyzer* InstantiateAnalyzer(const Tag& tag, RecordVal* args, File* f) const;
/** /**
* Returns a set of all matching MIME magic signatures for a given * Returns a set of all matching MIME magic signatures for a given
@ -359,7 +359,7 @@ protected:
* connection-related fields. * connection-related fields.
*/ */
File* GetFile(const string& file_id, Connection* conn = 0, File* GetFile(const string& file_id, Connection* conn = 0,
analyzer::Tag tag = analyzer::Tag::Error, const analyzer::Tag& tag = analyzer::Tag::Error,
bool is_orig = false, bool update_conn = true, bool is_orig = false, bool update_conn = true,
const char* source_name = 0); const char* source_name = 0);
@ -390,7 +390,7 @@ protected:
* @return #current_file_id, which is a hash of a unique file handle string * @return #current_file_id, which is a hash of a unique file handle string
* set by a \c get_file_handle event handler. * set by a \c get_file_handle event handler.
*/ */
std::string GetFileID(analyzer::Tag tag, Connection* c, bool is_orig); std::string GetFileID(const analyzer::Tag& tag, Connection* c, bool is_orig);
/** /**
* Check if analysis is available for files transferred over a given * Check if analysis is available for files transferred over a given
@ -400,7 +400,7 @@ protected:
* @return whether file analysis is disabled for the analyzer given by * @return whether file analysis is disabled for the analyzer given by
* \a tag. * \a tag.
*/ */
static bool IsDisabled(analyzer::Tag tag); static bool IsDisabled(const analyzer::Tag& tag);
private: private:
typedef set<Tag> TagSet; typedef set<Tag> TagSet;

View file

@ -16,7 +16,7 @@
using namespace file_analysis; using namespace file_analysis;
X509Common::X509Common(file_analysis::Tag arg_tag, RecordVal* arg_args, File* arg_file) X509Common::X509Common(const file_analysis::Tag& arg_tag, RecordVal* arg_args, File* arg_file)
: file_analysis::Analyzer(arg_tag, arg_args, arg_file) : file_analysis::Analyzer(arg_tag, arg_args, arg_file)
{ {
} }
@ -230,7 +230,7 @@ void file_analysis::X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION*
delete conn; delete conn;
} }
void file_analysis::X509Common::ParseExtension(X509_EXTENSION* ex, EventHandlerPtr h, bool global) void file_analysis::X509Common::ParseExtension(X509_EXTENSION* ex, const EventHandlerPtr& h, bool global)
{ {
char name[256]; char name[256];
char oid[256]; char oid[256];

View file

@ -35,9 +35,9 @@ public:
static double GetTimeFromAsn1(const ASN1_TIME* atime, File* f, Reporter* reporter); static double GetTimeFromAsn1(const ASN1_TIME* atime, File* f, Reporter* reporter);
protected: protected:
X509Common(file_analysis::Tag arg_tag, RecordVal* arg_args, File* arg_file); X509Common(const file_analysis::Tag& arg_tag, RecordVal* arg_args, File* arg_file);
void ParseExtension(X509_EXTENSION* ex, EventHandlerPtr h, bool global); void ParseExtension(X509_EXTENSION* ex, const EventHandlerPtr& h, bool global);
void ParseSignedCertificateTimestamps(X509_EXTENSION* ext); void ParseSignedCertificateTimestamps(X509_EXTENSION* ext);
virtual void ParseExtensionsSpecific(X509_EXTENSION* ex, bool, ASN1_OBJECT*, const char*) = 0; virtual void ParseExtensionsSpecific(X509_EXTENSION* ex, bool, ASN1_OBJECT*, const char*) = 0;
}; };

View file

@ -735,7 +735,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
return true; return true;
} }
bool Manager::CheckErrorEventTypes(std::string stream_name, const Func* ev, bool table) const bool Manager::CheckErrorEventTypes(const std::string& stream_name, const Func* ev, bool table) const
{ {
if ( ev == nullptr ) if ( ev == nullptr )
return true; return true;

View file

@ -191,7 +191,7 @@ private:
// Check if the types of the error_ev event are correct. If table is // Check if the types of the error_ev event are correct. If table is
// true, check for tablestream type, otherwhise check for eventstream // true, check for tablestream type, otherwhise check for eventstream
// type. // type.
bool CheckErrorEventTypes(std::string stream_name, const Func* error_event, bool table) const; bool CheckErrorEventTypes(const std::string& stream_name, const Func* error_event, bool table) const;
// SendEntry implementation for Table stream. // SendEntry implementation for Table stream.
int SendEntryTable(Stream* i, const threading::Value* const *vals); int SendEntryTable(Stream* i, const threading::Value* const *vals);

View file

@ -386,7 +386,7 @@ bool Manager::DisableStream(EnumVal* id)
// Helper for recursive record field unrolling. // Helper for recursive record field unrolling.
bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
TableVal* include, TableVal* exclude, string path, list<int> indices) TableVal* include, TableVal* exclude, const string& path, const list<int>& indices)
{ {
// Only include extensions for the outer record. // Only include extensions for the outer record.
int num_ext_fields = (indices.size() == 0) ? filter->num_ext_fields : 0; int num_ext_fields = (indices.size() == 0) ? filter->num_ext_fields : 0;
@ -676,7 +676,7 @@ bool Manager::RemoveFilter(EnumVal* id, StringVal* name)
return RemoveFilter(id, name->AsString()->CheckString()); return RemoveFilter(id, name->AsString()->CheckString());
} }
bool Manager::RemoveFilter(EnumVal* id, string name) bool Manager::RemoveFilter(EnumVal* id, const string& name)
{ {
Stream* stream = FindStream(id); Stream* stream = FindStream(id);
if ( ! stream ) if ( ! stream )
@ -1259,7 +1259,7 @@ void Manager::DeleteVals(int num_fields, threading::Value** vals)
delete [] vals; delete [] vals;
} }
bool Manager::WriteFromRemote(EnumVal* id, EnumVal* writer, string path, int num_fields, bool Manager::WriteFromRemote(EnumVal* id, EnumVal* writer, const string& path, int num_fields,
threading::Value** vals) threading::Value** vals)
{ {
Stream* stream = FindStream(id); Stream* stream = FindStream(id);

View file

@ -112,7 +112,7 @@ public:
* This methods corresponds directly to the internal BiF defined in * This methods corresponds directly to the internal BiF defined in
* logging.bif, which just forwards here. * logging.bif, which just forwards here.
*/ */
bool RemoveFilter(EnumVal* id, string name); bool RemoveFilter(EnumVal* id, const string& name);
/** /**
* Write a record to a log stream. * Write a record to a log stream.
@ -165,7 +165,7 @@ public:
* @param vals An array of log values to write, of size num_fields. * @param vals An array of log values to write, of size num_fields.
* The method takes ownership of the array. * The method takes ownership of the array.
*/ */
bool WriteFromRemote(EnumVal* stream, EnumVal* writer, string path, bool WriteFromRemote(EnumVal* stream, EnumVal* writer, const string& path,
int num_fields, threading::Value** vals); int num_fields, threading::Value** vals);
/** /**
@ -256,7 +256,7 @@ private:
struct WriterInfo; struct WriterInfo;
bool TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, bool TraverseRecord(Stream* stream, Filter* filter, RecordType* rt,
TableVal* include, TableVal* exclude, string path, list<int> indices); TableVal* include, TableVal* exclude, const string& path, const list<int>& indices);
threading::Value** RecordToFilterVals(Stream* stream, Filter* filter, threading::Value** RecordToFilterVals(Stream* stream, Filter* filter,
RecordVal* columns); RecordVal* columns);

View file

@ -27,7 +27,7 @@ static void DbgAndWarn(const char* msg)
} }
static void WarnMissingScript(const char* type, const ID* id, static void WarnMissingScript(const char* type, const ID* id,
string script) const string& script)
{ {
if ( script == "<command line>" ) if ( script == "<command line>" )
return; return;

View file

@ -24,7 +24,7 @@ void ReStructuredTextTable::AddRow(const vector<string>& new_row)
longest_row_in_column[i] = new_row[i].size(); longest_row_in_column[i] = new_row[i].size();
} }
string ReStructuredTextTable::MakeBorder(const vector<size_t> col_sizes, string ReStructuredTextTable::MakeBorder(const vector<size_t>& col_sizes,
char border) char border)
{ {
string rval; string rval;

View file

@ -31,7 +31,7 @@ public:
* @return A border sized appropriated for the table with columns of sizes * @return A border sized appropriated for the table with columns of sizes
* denoted by \a col_sizes. * denoted by \a col_sizes.
*/ */
static std::string MakeBorder(const std::vector<size_t> col_sizes, static std::string MakeBorder(const std::vector<size_t>& col_sizes,
char border); char border);
/** /**