mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Merge branch 'topic/jgras/base64-logging' of https://github.com/J-Gras/bro
* 'topic/jgras/base64-logging' of https://github.com/J-Gras/bro: Update calls of Base64 functions. Refactoring of Base64 functions. I've removed the additional bif for encoding with a connection, as I'm not sure there's much of a use case for it; we can always add it back later if it turns out there is. I've also renamed decode_base64_intern() to decode_base64_conn() to be a bit more explicit about the difference.
This commit is contained in:
commit
f2dbe7f01d
16 changed files with 172 additions and 38 deletions
22
src/Base64.h
22
src/Base64.h
|
@ -8,15 +8,17 @@
|
|||
#include "util.h"
|
||||
#include "BroString.h"
|
||||
#include "Reporter.h"
|
||||
#include "analyzer/Analyzer.h"
|
||||
#include "Conn.h"
|
||||
|
||||
// Maybe we should have a base class for generic decoders?
|
||||
class Base64Converter {
|
||||
public:
|
||||
// <analyzer> is used for error reporting, and it should be zero when
|
||||
// the decoder is called by the built-in function decode_base64() or encode_base64().
|
||||
// Empty alphabet indicates the default base64 alphabet.
|
||||
Base64Converter(analyzer::Analyzer* analyzer, const string& alphabet = "");
|
||||
// <conn> is used for error reporting. If it is set to zero (as,
|
||||
// e.g., done by the built-in functions decode_base64() and
|
||||
// encode_base64()), encoding-errors will go to Reporter instead of
|
||||
// Weird. Usage errors go to Reporter in any case. Empty alphabet
|
||||
// indicates the default base64 alphabet.
|
||||
Base64Converter(Connection* conn, const string& alphabet = "");
|
||||
~Base64Converter();
|
||||
|
||||
// A note on Decode():
|
||||
|
@ -42,8 +44,8 @@ public:
|
|||
void IllegalEncoding(const char* msg)
|
||||
{
|
||||
// strncpy(error_msg, msg, sizeof(error_msg));
|
||||
if ( analyzer )
|
||||
analyzer->Weird("base64_illegal_encoding", msg);
|
||||
if ( conn )
|
||||
conn->Weird("base64_illegal_encoding", msg);
|
||||
else
|
||||
reporter->Error("%s", msg);
|
||||
}
|
||||
|
@ -63,11 +65,11 @@ protected:
|
|||
int base64_after_padding;
|
||||
int* base64_table;
|
||||
int errored; // if true, we encountered an error - skip further processing
|
||||
analyzer::Analyzer* analyzer;
|
||||
Connection* conn;
|
||||
|
||||
};
|
||||
|
||||
BroString* decode_base64(const BroString* s, const BroString* a = 0);
|
||||
BroString* encode_base64(const BroString* s, const BroString* a = 0);
|
||||
BroString* decode_base64(const BroString* s, const BroString* a = 0, Connection* conn = 0);
|
||||
BroString* encode_base64(const BroString* s, const BroString* a = 0, Connection* conn = 0);
|
||||
|
||||
#endif /* base64_h */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue