Merge remote-tracking branch 'origin/topic/timw/776-using-statements'

* origin/topic/timw/776-using-statements:
  Remove 'using namespace std' from SerialTypes.h
  Remove other using statements from headers
  GH-776: Remove using statements added by PR 770

Includes small fixes in files that changed since the merge request was
made.

Also includes a few small indentation fixes.
This commit is contained in:
Johanna Amann 2020-04-09 13:11:12 -07:00
commit 876c803d75
147 changed files with 553 additions and 579 deletions

View file

@ -7,8 +7,6 @@
#include "Dict.h"
#include "Tag.h"
using std::queue;
class CompositeHash;
class RecordVal;
@ -204,7 +202,7 @@ private:
HashKey* key;
};
typedef queue<Modification*> ModQueue;
using ModQueue = std::queue<Modification*>;
ModQueue mod_queue; /**< A queue of analyzer additions/removals requests. */
};

View file

@ -80,7 +80,7 @@ void File::StaticInit()
meta_inferred_idx = Idx("inferred", fa_metadata_type);
}
File::File(const string& file_id, const string& source_name, Connection* conn,
File::File(const std::string& file_id, const std::string& source_name, Connection* conn,
analyzer::Tag tag, bool is_orig)
: id(file_id), val(nullptr), file_reassembler(nullptr), stream_offset(0),
reassembly_max_buffer(0), did_metadata_inference(false),
@ -174,7 +174,7 @@ double File::LookupFieldDefaultInterval(int idx) const
return v->AsInterval();
}
int File::Idx(const string& field, const RecordType* type)
int File::Idx(const std::string& field, const RecordType* type)
{
int rval = type->FieldOffset(field.c_str());
@ -185,14 +185,14 @@ int File::Idx(const string& field, const RecordType* type)
return rval;
}
string File::GetSource() const
std::string File::GetSource() const
{
Val* v = val->Lookup(source_idx);
return v ? v->AsString()->CheckString() : string();
return v ? v->AsString()->CheckString() : std::string();
}
void File::SetSource(const string& source)
void File::SetSource(const std::string& source)
{
val->Assign(source_idx, make_intrusive<StringVal>(source.c_str()));
}
@ -288,7 +288,7 @@ void File::SetReassemblyBuffer(uint64_t max)
reassembly_max_buffer = max;
}
bool File::SetMime(const string& mime_type)
bool File::SetMime(const std::string& mime_type)
{
if ( mime_type.empty() || bof_buffer.size != 0 || did_metadata_inference )
return false;
@ -329,7 +329,7 @@ void File::InferMetadata()
RuleMatcher::MIME_Matches matches;
const u_char* data = bof_buffer_val->AsString()->Bytes();
uint64_t len = bof_buffer_val->AsString()->Len();
len = min(len, LookupFieldDefaultCount(bof_buffer_size_idx));
len = std::min(len, LookupFieldDefaultCount(bof_buffer_size_idx));
file_mgr->DetectMIME(data, len, &matches);
auto meta = make_intrusive<RecordVal>(fa_metadata_type);
@ -383,7 +383,7 @@ void File::DeliverStream(const u_char* data, uint64_t len)
"[%s] %" PRIu64 " stream bytes in at offset %" PRIu64 "; %s [%s%s]",
id.c_str(), len, stream_offset,
IsComplete() ? "complete" : "incomplete",
fmt_bytes((const char*) data, min((uint64_t)40, len)),
fmt_bytes((const char*) data, std::min((uint64_t)40, len)),
len > 40 ? "..." : "");
file_analysis::Analyzer* a = nullptr;
@ -487,7 +487,7 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset)
"[%s] %" PRIu64 " chunk bytes in at offset %" PRIu64 "; %s [%s%s]",
id.c_str(), len, offset,
IsComplete() ? "complete" : "incomplete",
fmt_bytes((const char*) data, min((uint64_t)40, len)),
fmt_bytes((const char*) data, std::min((uint64_t)40, len)),
len > 40 ? "..." : "");
file_analysis::Analyzer* a = nullptr;

View file

@ -13,8 +13,6 @@
#include "ZeekArgs.h"
#include "WeirdState.h"
using std::string;
class Connection;
class RecordType;
class RecordVal;
@ -46,13 +44,13 @@ public:
* @return the value of the "source" field from #val record or an empty
* string if it's not initialized.
*/
string GetSource() const;
std::string GetSource() const;
/**
* Set the "source" field from #val record to \a source.
* @param source the new value of the "source" field.
*/
void SetSource(const string& source);
void SetSource(const std::string& source);
/**
* @return value (seconds) of the "timeout_interval" field from #val record.
@ -76,7 +74,7 @@ public:
/**
* @return value of the "id" field from #val record.
*/
string GetID() const { return id; }
std::string GetID() const { return id; }
/**
* @return value of "last_active" field in #val record;
@ -212,7 +210,7 @@ public:
* @return true if the mime type was set. False if it could not be set because
* a mime type was already set or inferred.
*/
bool SetMime(const string& mime_type);
bool SetMime(const std::string& mime_type);
/**
* Whether to permit a weird to carry on through the full reporter/weird
@ -236,7 +234,7 @@ protected:
* of the connection to the responder. False indicates the other
* direction.
*/
File(const string& file_id, const string& source_name, Connection* conn = nullptr,
File(const std::string& file_id, const std::string& source_name, Connection* conn = nullptr,
analyzer::Tag tag = analyzer::Tag::Error, bool is_orig = false);
/**
@ -313,7 +311,7 @@ protected:
*/
void DeliverStream(const u_char* data, uint64_t len);
/**
/**
* Perform chunk-wise delivery for analyzers that need it.
*/
void DeliverChunk(const u_char* data, uint64_t len, uint64_t offset);
@ -324,7 +322,7 @@ protected:
* @param type the record type for which the field will be looked up.
* @return the field offset in #val record corresponding to \a field_name.
*/
static int Idx(const string& field_name, const RecordType* type);
static int Idx(const std::string& field_name, const RecordType* type);
/**
* Initializes static member.
@ -332,7 +330,7 @@ protected:
static void StaticInit();
protected:
string id; /**< A pretty hash that likely identifies file */
std::string id; /**< A pretty hash that likely identifies file */
RecordVal* val; /**< \c fa_file from script layer. */
FileReassembler* file_reassembler; /**< A reassembler for the file if it's needed. */
uint64_t stream_offset; /**< The offset of the file which has been forwarded. */

View file

@ -6,7 +6,7 @@
using namespace file_analysis;
FileTimer::FileTimer(double t, const string& id, double interval)
FileTimer::FileTimer(double t, const std::string& id, double interval)
: Timer(t + interval, TIMER_FILE_ANALYSIS_INACTIVITY), file_id(id)
{
DBG_LOG(DBG_FILE_ANALYSIS, "New %f second timeout timer for %s",

View file

@ -2,11 +2,8 @@
#pragma once
#include "Timer.h"
#include <string>
using std::string;
#include "Timer.h"
namespace file_analysis {
@ -22,7 +19,7 @@ public:
* @param id the file identifier which will be checked for inactivity.
* @param interval amount of time after \a t to check for inactivity.
*/
FileTimer(double t, const string& id, double interval);
FileTimer(double t, const std::string& id, double interval);
/**
* Check inactivity of file_analysis::File corresponding to #file_id,
@ -33,7 +30,7 @@ public:
void Dispatch(double t, bool is_expire) override;
private:
string file_id;
std::string file_id;
};
} // namespace file_analysis

View file

@ -15,6 +15,7 @@
#include <openssl/md5.h>
using namespace file_analysis;
using namespace std;
TableVal* Manager::disabled = nullptr;
TableType* Manager::tag_set_type = nullptr;

View file

@ -14,9 +14,6 @@
#include "analyzer/Tag.h"
using std::map;
using std::set;
class TableVal;
class VectorVal;
@ -75,7 +72,7 @@ public:
* a single file.
* @return a prettified MD5 hash of \a handle, truncated to *bits_per_uid* bits.
*/
string HashHandle(const string& handle) const;
std::string HashHandle(const std::string& handle) const;
/**
* Take in a unique file handle string to identify next piece of
@ -83,7 +80,7 @@ public:
* @param handle a unique string (may contain NULs) which identifies
* a single file.
*/
void SetHandle(const string& handle);
void SetHandle(const std::string& handle);
/**
* Pass in non-sequential file data.
@ -150,8 +147,8 @@ public:
* in human-readable form where the file input is coming from (e.g.
* a local file path).
*/
void DataIn(const u_char* data, uint64_t len, const string& file_id,
const string& source);
void DataIn(const u_char* data, uint64_t len, const std::string& file_id,
const std::string& source);
/**
* Signal the end of file data regardless of which direction it is being
@ -173,7 +170,7 @@ public:
* Signal the end of file data being transferred using the file identifier.
* @param file_id the file identifier/hash.
*/
void EndOfFile(const string& file_id);
void EndOfFile(const std::string& file_id);
/**
* Signal a gap in the file data stream.
@ -219,7 +216,7 @@ public:
* @param file_id the file identifier/hash.
* @return false if file identifier did not map to anything, else true.
*/
bool IgnoreFile(const string& file_id);
bool IgnoreFile(const std::string& file_id);
/**
* Set's an inactivity threshold for the file.
@ -229,22 +226,22 @@ public:
* to be considered stale, timed out, and then resource reclaimed.
* @return false if file identifier did not map to anything, else true.
*/
bool SetTimeoutInterval(const string& file_id, double interval) const;
bool SetTimeoutInterval(const std::string& file_id, double interval) const;
/**
* Enable the reassembler for a file.
*/
bool EnableReassembly(const string& file_id);
bool EnableReassembly(const std::string& file_id);
/**
* Disable the reassembler for a file.
*/
bool DisableReassembly(const string& file_id);
bool DisableReassembly(const std::string& file_id);
/**
* Set the reassembly for a file in bytes.
*/
bool SetReassemblyBuffer(const string& file_id, uint64_t max);
bool SetReassemblyBuffer(const std::string& file_id, uint64_t max);
/**
* Sets a limit on the maximum size allowed for extracting the file
@ -256,7 +253,7 @@ public:
* @return false if file identifier and analyzer did not map to anything,
* else true.
*/
bool SetExtractionLimit(const string& file_id, RecordVal* args,
bool SetExtractionLimit(const std::string& file_id, RecordVal* args,
uint64_t n) const;
/**
@ -265,7 +262,7 @@ public:
* @return the File object mapped to \a file_id, or a null pointer if no
* mapping exists.
*/
File* LookupFile(const string& file_id) const;
File* LookupFile(const std::string& file_id) const;
/**
* Queue attachment of an analzer to the file identifier. Multiple
@ -276,7 +273,7 @@ public:
* @param args a \c AnalyzerArgs value which describes a file analyzer.
* @return false if the analyzer failed to be instantiated, else true.
*/
bool AddAnalyzer(const string& file_id, const file_analysis::Tag& tag,
bool AddAnalyzer(const std::string& file_id, const file_analysis::Tag& tag,
RecordVal* args) const;
/**
@ -286,7 +283,7 @@ public:
* @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.
*/
bool RemoveAnalyzer(const string& file_id, const file_analysis::Tag& tag,
bool RemoveAnalyzer(const std::string& file_id, const file_analysis::Tag& tag,
RecordVal* args) const;
/**
@ -294,7 +291,7 @@ public:
* @param file_id the file identifier/hash.
* @return whether the file mapped to \a file_id is being ignored.
*/
bool IsIgnored(const string& file_id);
bool IsIgnored(const std::string& file_id);
/**
* Instantiates a new file analyzer instance for the file.
@ -358,7 +355,7 @@ protected:
* exist, the activity time is refreshed along with any
* connection-related fields.
*/
File* GetFile(const string& file_id, Connection* conn = nullptr,
File* GetFile(const std::string& file_id, Connection* conn = nullptr,
const analyzer::Tag& tag = analyzer::Tag::Error,
bool is_orig = false, bool update_conn = true,
const char* source_name = nullptr);
@ -370,14 +367,14 @@ protected:
* @param is_termination whether the Manager (and probably Bro) is in a
* terminating state. If true, then the timeout cannot be postponed.
*/
void Timeout(const string& file_id, bool is_terminating = ::terminating);
void Timeout(const std::string& file_id, bool is_terminating = ::terminating);
/**
* Immediately remove file_analysis::File object associated with \a file_id.
* @param file_id the file identifier/hash.
* @return false if file id string did not map to anything, else true.
*/
bool RemoveFile(const string& file_id);
bool RemoveFile(const std::string& file_id);
/**
* Sets #current_file_id to a hash of a unique file handle string based on
@ -403,20 +400,20 @@ protected:
static bool IsDisabled(const analyzer::Tag& tag);
private:
typedef set<Tag> TagSet;
typedef map<string, TagSet*> MIMEMap;
typedef std::set<Tag> TagSet;
typedef std::map<std::string, TagSet*> MIMEMap;
TagSet* LookupMIMEType(const string& mtype, bool add_if_not_found);
TagSet* LookupMIMEType(const std::string& mtype, bool add_if_not_found);
std::map<string, File*> id_map; /**< Map file ID to file_analysis::File records. */
std::set<string> ignored; /**< Ignored files. Will be finally removed on EOF. */
string current_file_id; /**< Hash of what get_file_handle event sets. */
std::map<std::string, File*> id_map; /**< Map file ID to file_analysis::File records. */
std::set<std::string> ignored; /**< Ignored files. Will be finally removed on EOF. */
std::string current_file_id; /**< Hash of what get_file_handle event sets. */
RuleFileMagicState* magic_state; /**< File magic signature match state. */
MIMEMap mime_types;/**< Mapping of MIME types to analyzers. */
static TableVal* disabled; /**< Table of disabled analyzers. */
static TableType* tag_set_type; /**< Type for set[tag]. */
static string salt; /**< A salt added to file handles before hashing. */
static std::string salt; /**< A salt added to file handles before hashing. */
size_t cumulative_files;
size_t max_files;

View file

@ -10,7 +10,7 @@
using namespace file_analysis;
Extract::Extract(RecordVal* args, File* file, const string& arg_filename,
Extract::Extract(RecordVal* args, File* file, const std::string& arg_filename,
uint64_t arg_limit)
: file_analysis::Analyzer(file_mgr->GetComponentTag("EXTRACT"), args, file),
filename(arg_filename), limit(arg_limit), depth(0)

View file

@ -66,11 +66,11 @@ protected:
* to which the contents of the file will be extracted/written.
* @param arg_limit the maximum allowed file size.
*/
Extract(RecordVal* args, File* file, const string& arg_filename,
Extract(RecordVal* args, File* file, const std::string& arg_filename,
uint64_t arg_limit);
private:
string filename;
std::string filename;
int fd;
uint64_t limit;
uint64_t depth;

View file

@ -703,7 +703,7 @@ function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signa
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
assert(mdctx);
string errstr;
std::string errstr;
int success = 0;
const EVP_MD* hash = hash_to_evp(hash_algorithm);