Skip to content

Commit

Permalink
Support zeek 32 (#10)
Browse files Browse the repository at this point in the history
* Fix usage of std namespaceing to be more uniform

* Update patch version to match correct version
  • Loading branch information
Mraoul authored Sep 11, 2020
1 parent c1f3eb8 commit 5b160f3
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ argument.
You should see the following output from zeek if successfully installed:

> zeek -NN mitrecnd::HTTP2
mitrecnd::HTTP2 - Hypertext Transfer Protocol Version 2 analyzer (dynamic, version 0.5.0)
mitrecnd::HTTP2 - Hypertext Transfer Protocol Version 2 analyzer (dynamic, version 0.5.1)
[Analyzer] HTTP2 (ANALYZER_HTTP2, enabled)
[Event] http2_request
[Event] http2_reply
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
4 changes: 2 additions & 2 deletions src/HTTP2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ void HTTP2_Analyzer::DeliverStream(int len, const u_char* data, bool orig){
}
// If the connection is HTTP2
if (this->connectionActive) {
vector<HTTP2_Frame*> frames = this->reassemblers[orig].process(&data[prefaceOffset], (len - prefaceOffset));
std::vector<HTTP2_Frame*> frames = this->reassemblers[orig].process(&data[prefaceOffset], (len - prefaceOffset));
// Frame memory is callee handled so clean it up after use
for (vector<HTTP2_Frame*>::iterator it = frames.begin(); it != frames.end(); ++it){
for (std::vector<HTTP2_Frame*>::iterator it = frames.begin(); it != frames.end(); ++it){
if(*it == nullptr) {
// Reassembler will ensure last frame pointer is null, so no other, valid,
// frames should be present that need to be to be handled/deleted
Expand Down
1 change: 0 additions & 1 deletion src/HTTP2.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "nghttp2.h"
#include "nghttp2ver.h"

using namespace std;

namespace analyzer { namespace mitrecnd {

Expand Down
12 changes: 6 additions & 6 deletions src/HTTP2_Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class HTTP2_RstStream_Frame : public HTTP2_Frame {

};

class HTTP2_Settings_Frame : public HTTP2_Frame {
class HTTP2_Settings_Frame : public HTTP2_Frame {
public:
HTTP2_Settings_Frame(HTTP2_FrameHeader* h, uint8_t* payload, uint32_t len);
~HTTP2_Settings_Frame(void);
Expand All @@ -149,7 +149,7 @@ class HTTP2_Settings_Frame : public HTTP2_Frame {
bool getMaxFrameSize(uint32_t& size);
bool getMaxHeaderListSize(uint32_t& size);
bool unrecognizedSettings(void){return this->unrecognized_settings;};
const std::vector<pair<uint16_t, uint32_t>>& getUnrecognizedSettings(void){return (this->unrec_settings);};
const std::vector<std::pair<uint16_t, uint32_t>>& getUnrecognizedSettings(void){return (this->unrec_settings);};
bool isAck(void){return this->header->isAck();};

private:
Expand All @@ -167,10 +167,10 @@ class HTTP2_Settings_Frame : public HTTP2_Frame {
uint32_t initial_window_size;
uint32_t max_frame_size;
uint32_t max_header_list_size;
std::vector<pair<uint16_t, uint32_t>> unrec_settings;
std::vector<std::pair<uint16_t, uint32_t>> unrec_settings;

};

};

class HTTP2_PushPromise_Frame : public HTTP2_Header_Frame_Base {
public:
HTTP2_PushPromise_Frame(HTTP2_FrameHeader* h, uint8_t* payload, uint32_t len);
Expand Down Expand Up @@ -233,6 +233,6 @@ class HTTP2_Continuation_Frame : public HTTP2_Header_Frame {
};


} } // namespace analyzer::*
} } // namespace analyzer::*

#endif
9 changes: 5 additions & 4 deletions src/HTTP2_FrameReassembler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Reporter.h"

using namespace analyzer::mitrecnd;
using namespace std;

HTTP2_FrameReassembler::HTTP2_FrameReassembler()
{
Expand Down Expand Up @@ -117,15 +118,15 @@ vector<HTTP2_Frame*> HTTP2_FrameReassembler::process(const uint8_t* data, uint32
break;
} else {
uint32_t oldBufferLen = this->bufferLen;

// Selectively copy data to minimize bytes copied
if ((this->copyLen == 0) || (this->copyLen >= dataLen)){
// If we don't know how much to copy yet or the amount we
// If we don't know how much to copy yet or the amount we
// need is more than supplied then just copy what is available.
this->appendBuffer(cursor, dataLen);
}
else{
// Only copy what is needed to complete the frame. The excess
// Only copy what is needed to complete the frame. The excess
// just gets flushed, so why waste the copies.
this->appendBuffer(cursor, copyLen);
}
Expand All @@ -148,7 +149,7 @@ vector<HTTP2_Frame*> HTTP2_FrameReassembler::process(const uint8_t* data, uint32
// Determine if any data left in buffer
uint32_t diff = frame_length - oldBufferLen;
// oldBufferLen should always be smaller than the frame length
// double-check!
// double-check!
if (frame_length <= oldBufferLen ) {
DEBUG_ERR("Fragmented Frame Processing Error! frame_length:%d Old Buffer Length:%d\n", frame_length, oldBufferLen);
processed_frames.push_back(nullptr);
Expand Down
30 changes: 14 additions & 16 deletions src/HTTP2_HeaderStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "nghttp2.h"
#include "nghttp2ver.h"

using namespace std;

namespace analyzer { namespace mitrecnd {

struct HTTP2_HeaderStorage {
Expand All @@ -30,55 +28,55 @@ class HTTP2_HeaderList {
/**
* void HTTP2_HeaderList::addHeader(std::string& name,
* std::string& value)
*
*
* Description: Create and add a HTTP2_HeaderStorage object to
* the List.
*
*
* @param name
* @param value
*
* @param name
* @param value
*/
void addHeader(std::string& name, std::string& value);

/**
* void HTTP2_HeaderList::addHeader(HTTP2_HeaderStorage *header)
*
*
* Description: Add an existing HTTP2_HeaderStorage object to
* the List.
*
*
* @param header
*
* @param header
*/
void addHeader(HTTP2_HeaderStorage& header);
void addHeader(HTTP2_HeaderStorage&& header);
/**
* void HTTP2_HeaderList::flushHeaders()
*
*
* Description: Remove all the HTTP2_HeaderStorage objects from
* the list and delete their instances.
*
*
*
*/
void flushHeaders();

/**
* RecordVal*
* HTTP2_HeaderList::BuildHeaderVal(HTTP2_HeaderStorage h)
*
*
* Description: Create a header record entry for use when
* building a header table to be consumed by bro.
*
*
*
* @param h reference to the header storage
* structure to use when building the
* header record entry.
*
*
* @return RecordVal* reference to resulting header record.
*/
RecordVal* BuildHeaderVal(HTTP2_HeaderStorage& h);
/**
* TableVal* HTTP2_HeaderList::BuildHeaderTable(void)
*
*
* Description: Create a header table to be consumed by bro.
*
* @return TableVal* reference to the resulting header table
Expand All @@ -88,7 +86,7 @@ class HTTP2_HeaderList {
std::vector<HTTP2_HeaderStorage> headers;
};

} } // namespace analyzer::*
} } // namespace analyzer::*

#endif

Expand Down
3 changes: 1 addition & 2 deletions src/HTTP2_Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "HTTP2_Frame.h"
#include "HTTP2.h"

using namespace std;

namespace analyzer { namespace mitrecnd {

Expand Down Expand Up @@ -90,7 +89,7 @@ class HTTP2_HalfStream {
* header was found and
* decompressed.
*/
bool processHeaders(uint8_t** headerBlockFragmentPtr, uint32_t& len, bool endHeaders, string& name, string& value);
bool processHeaders(uint8_t** headerBlockFragmentPtr, uint32_t& len, bool endHeaders, std::string& name, std::string& value);

// Data Management
int dataOffset;
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ plugin::Configuration Plugin::Configure()
config.name = "mitrecnd::HTTP2";
config.version.major = 0;
config.version.minor = 5;
config.version.patch = 0;
config.version.patch = 1;
return config;
}

0 comments on commit 5b160f3

Please sign in to comment.