DetectionEngine::set_check_tags(false);
pc.log_pkts++;
+ const uint8_t* data = nullptr;
+ uint16_t dsize = 0;
+
+ if (p->flow && p->flow->gadget)
+ data = p->flow->gadget->adjust_log_packet(p, dsize);
+
+ uint16_t old_dsize = 0;
+ const uint8_t* old_data = nullptr;
+ if (data)
+ {
+ old_dsize = p->dsize;
+ old_data = p->data;
+ p->data = data;
+ p->dsize = dsize;
+ }
+
OutputSet* idx = head ? head->LogList : nullptr;
EventManager::call_loggers(idx, p, otn->sigInfo.message.c_str(), &event);
+
+ if (data)
+ {
+ p->data = old_data;
+ p->dsize = old_dsize;
+ delete[] data;
+ }
}
void CallAlertFuncs(Packet* p, const OptTreeNode* otn, ListHead* head)
}
}
+const uint8_t* HttpInspect::adjust_log_packet(Packet* p, uint16_t& length)
+{
+ HttpMsgSection* current_section = HttpContextData::get_snapshot(p);
+ if (current_section == nullptr ||
+ current_section->get_inspection_section() != PS_HEADER)
+ return nullptr;
+
+ HttpMsgSection* other_section = nullptr;
+ unsigned id;
+ if ((HttpMsgHeader*)current_section == current_section->get_header(SRC_CLIENT))
+ {
+ other_section = current_section->get_request();
+ id = HTTP_BUFFER_RAW_REQUEST;
+ }
+ else if ((HttpMsgHeader*)current_section == current_section->get_header(SRC_SERVER))
+ {
+ other_section = current_section->get_status();
+ id = HTTP_BUFFER_RAW_STATUS;
+ }
+ else
+ return nullptr;
+
+ const Field& start_line = other_section->get_classic_buffer(id, 0, 0);
+ if (start_line.length() > 0)
+ {
+ static const uint8_t END_HEADERS[] = "\r\n\r\n";
+ static const size_t END_HEADERS_LEN = 4;
+ static const uint8_t* END_START_LINE = END_HEADERS;
+ static const size_t END_START_LINE_LEN = 2;
+
+ const struct { const uint8_t* data; const size_t len; } frags[] =
+ {
+ { start_line.start(), (size_t) start_line.length() },
+ { END_START_LINE, END_START_LINE_LEN },
+ { p->data, p->dsize },
+ { END_HEADERS, END_HEADERS_LEN }
+ };
+ const uint frags_cnt = sizeof(frags)/sizeof(frags[0]);
+
+ uint8_t* data = new uint8_t[start_line.length() + END_START_LINE_LEN +
+ p->dsize + END_HEADERS_LEN];
+
+ uint8_t* dst = data;
+ for (uint i = 0; i < frags_cnt; i++)
+ {
+ memcpy(dst, frags[i].data, frags[i].len);
+ dst += frags[i].len;
+ }
+
+ length = dst - data;
+ return data;
+ }
+
+ return nullptr;
+}