Squashed commit of the following:
commit
bbe358a1e38a2c5256f20792b9ad5c3120f9a942
Author: mdagon <mdagon@cisco.com>
Date: Fri Jan 17 09:50:41 2020 -0500
http2_inspect: data frame http inspection walking skeleton first phase
EVENT_INVALID_HEADER = 10,
EVENT_SETTINGS_FRAME_ERROR = 11,
EVENT_SETTINGS_FRAME_UNKN_PARAM = 12,
+ EVENT_FRAME_SEQUENCE = 13,
EVENT__MAX_VALUE
};
INF_HPACK_INDEX_OUT_OF_BOUNDS = 17,
INF_INVALID_SETTINGS_FRAME = 18,
INF_SETTINGS_FRAME_UNKN_PARAM = 19,
+ INF_FRAME_SEQUENCE = 20,
INF__MAX_VALUE
};
#endif
private:
- class Http2Stream* find_stream(uint32_t key) const;
class Http2Stream* get_stream(uint32_t key);
class Http2Stream* get_hi_stream() const;
+ class Http2Stream* find_stream(uint32_t key) const;
};
#endif
Http2FlowData* const session_data =
(Http2FlowData*)p->flow->get_flow_data(Http2FlowData::inspector_id);
+ if (!session_data)
+ return;
+
// FIXIT-H Workaround for unexpected eval() calls
// Avoid eval if scan/reassemble aborts
if (session_data->frame_type[source_id] == FT__NONE)
{
AssistantGadgetEvent event(pkt, "http");
DataBus::publish(FLOW_ASSISTANT_GADGET_EVENT, event);
+ if (pkt->flow->assistant_gadget == nullptr)
+ return HttpStreamSplitter::status_value(StreamSplitter::ABORT, true);
pkt->flow->set_flow_data(session_data = new Http2FlowData(pkt->flow));
Http2Module::increment_peg_counts(PEG_FLOW);
}
#include <cassert>
#include "service_inspectors/http_inspect/http_common.h"
+#include "service_inspectors/http_inspect/http_flow_data.h"
#include "service_inspectors/http_inspect/http_test_input.h"
#include "service_inspectors/http_inspect/http_test_manager.h"
session_data->current_stream[source_id] =
get_stream_id(session_data->scan_frame_header[source_id]);
+ if (type == FT_DATA)
+ {
+ Http2Stream* const stream = session_data->find_stream(session_data->current_stream[source_id]);
+ HttpFlowData* http_flow = nullptr;
+ if (stream)
+ http_flow = (HttpFlowData*)stream->get_hi_flow_data();
+
+ if (!stream || !http_flow ||
+ (http_flow->get_type_expected(source_id) != HttpEnums::SEC_BODY_CHUNK))
+ {
+ *session_data->infractions[source_id] += INF_FRAME_SEQUENCE;
+ session_data->events[source_id]->create_event(EVENT_FRAME_SEQUENCE);
+ status = StreamSplitter::ABORT;
+ }
+ }
+
// Compute frame section length once per frame
if (session_data->scan_remaining_frame_octets[source_id] == 0)
{
{ EVENT_INVALID_HEADER, "invalid HTTP/2 header field" },
{ EVENT_SETTINGS_FRAME_ERROR, "error in HTTP/2 settings frame" },
{ EVENT_SETTINGS_FRAME_UNKN_PARAM, "unknown parameter in HTTP/2 settings frame" },
+ { EVENT_FRAME_SEQUENCE, "invalid HTTP/2 frame sequence" },
{ 0, nullptr }
};
friend class HttpUnitTestSetup;
#endif
+ HttpEnums::SectionType get_type_expected(HttpCommon::SourceId source_id)
+ { return type_expected[source_id]; }
+
private:
bool for_http2 = false;