Merge remote-tracking branch 'origin/topic/awelzel/bdat-websocket-fixlets'

* origin/topic/awelzel/bdat-websocket-fixlets:
  HTTP: Coverity std::move suggestion
  WebSocket: Coverity std::move suggestion
  SMTP/BDAT: Fix SonarQube reported issues
This commit is contained in:
Arne Welzel 2024-01-24 23:04:12 +01:00
commit 77ef7f4ad9
5 changed files with 15 additions and 8 deletions

View file

@ -1,3 +1,11 @@
6.2.0-dev.461 | 2024-01-24 23:04:12 +0100
* HTTP: Coverity std::move suggestion (Arne Welzel, Corelight)
* WebSocket: Coverity std::move suggestion (Arne Welzel, Corelight)
* SMTP/BDAT: Fix SonarQube reported issues (Arne Welzel, Corelight)
6.2.0-dev.456 | 2024-01-23 21:53:07 +0100
* btest/smtp/bdat: Move tests into proper directory (Arne Welzel, Corelight)

View file

@ -1 +1 @@
6.2.0-dev.456
6.2.0-dev.461

View file

@ -1371,7 +1371,7 @@ void HTTP_Analyzer::HTTP_Upgrade() {
analyzer_tag_val->GetType<EnumType>()->Lookup(analyzer_tag_val->AsEnum()),
upgrade_protocol_val->CheckString());
auto analyzer_tag = analyzer_mgr->GetComponentTag(analyzer_tag_val.get());
auto* analyzer = analyzer_mgr->InstantiateAnalyzer(analyzer_tag, Conn());
auto* analyzer = analyzer_mgr->InstantiateAnalyzer(std::move(analyzer_tag), Conn());
if ( analyzer ) {
AddChildAnalyzer(analyzer);

View file

@ -104,13 +104,13 @@ void SMTP_BDAT_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig
}
}
// Start searching for crlf at the end of the old buffer.
std::string::size_type i = buf.size() - 1;
// Start searching for crlf at the end of the old buffer, if any.
std::string::size_type i = buf.size() > 0 ? buf.size() - 1 : 0;
buf.append(reinterpret_cast<const char*>(data), len);
std::string::size_type line_start = 0;
for ( i = 0; i < buf.size(); i++ ) {
for ( ; i < buf.size(); i++ ) {
if ( i < buf.size() - 1 && buf[i] == '\r' && buf[i + 1] == '\n' ) {
// Found a match, buf[line_start, i) is the line we want to Deliver()
buf[i] = '\0';
@ -314,10 +314,9 @@ public:
void SubmitAllHeaders(mime::MIME_HeaderList& hlist) override {}
void SubmitData(int len, const char* buf) override {}
bool RequestBuffer(int* plen, char** pbuf) override { return false; }
void SubmitAllData() {}
void SubmitEvent(int event_type, const char* detail) override {}
const auto& DeliverCalls() { return deliver_calls; }
const auto& DeliverCalls() const { return deliver_calls; }
private:
std::vector<std::pair<std::string, bool>> deliver_calls;

View file

@ -85,7 +85,7 @@ refine flow WebSocket_Flow += {
zeek::BifEvent::enqueue_websocket_frame_data(connection()->zeek_analyzer(),
connection()->zeek_analyzer()->Conn(),
is_orig(),
data_val);
std::move(data_val));
}
// Forward text and binary data to downstream analyzers.