diff --git a/NEWS b/NEWS index 4fdc6e7a27..781b1534f7 100644 --- a/NEWS +++ b/NEWS @@ -59,6 +59,10 @@ Deprecated Functionality ``Connection::ConnectionEventFast()`` methods are now deprecated, use ``Connection::EnqueueEvent()`` instead. +- The ``file_analysis::File::FileEvent()`` methods taking ``val_list`` + arguments are now deprecated, use the overload that takes a ``zeek::Args`` + instead. + Zeek 3.1.0 ========== diff --git a/src/file_analysis/File.cc b/src/file_analysis/File.cc index d378fcd19f..5d7711d16c 100644 --- a/src/file_analysis/File.cc +++ b/src/file_analysis/File.cc @@ -155,9 +155,9 @@ void File::RaiseFileOverNewConnection(Connection* conn, bool is_orig) if ( conn && FileEventAvailable(file_over_new_connection) ) { FileEvent(file_over_new_connection, { - val->Ref(), - conn->BuildConnVal(), - val_mgr->GetBool(is_orig), + IntrusivePtr{NewRef{}, val}, + IntrusivePtr{AdoptRef{}, conn->BuildConnVal()}, + IntrusivePtr{AdoptRef{}, val_mgr->GetBool(is_orig)}, }); } } @@ -299,11 +299,11 @@ bool File::SetMime(const string& mime_type) if ( ! FileEventAvailable(file_sniff) ) return false; - RecordVal* meta = new RecordVal(fa_metadata_type); + auto meta = make_intrusive(fa_metadata_type); meta->Assign(meta_mime_type_idx, make_intrusive(mime_type)); meta->Assign(meta_inferred_idx, val_mgr->GetBool(0)); - FileEvent(file_sniff, {val->Ref(), meta}); + FileEvent(file_sniff, {IntrusivePtr{NewRef{}, val}, std::move(meta)}); return true; } @@ -332,7 +332,7 @@ void File::InferMetadata() len = min(len, LookupFieldDefaultCount(bof_buffer_size_idx)); file_mgr->DetectMIME(data, len, &matches); - RecordVal* meta = new RecordVal(fa_metadata_type); + auto meta = make_intrusive(fa_metadata_type); if ( ! matches.empty() ) { @@ -342,8 +342,7 @@ void File::InferMetadata() file_analysis::GenMIMEMatchesVal(matches)); } - FileEvent(file_sniff, {val->Ref(), meta}); - return; + FileEvent(file_sniff, {IntrusivePtr{NewRef{}, val}, std::move(meta)}); } bool File::BufferBOF(const u_char* data, uint64_t len) @@ -455,9 +454,9 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset) if ( FileEventAvailable(file_reassembly_overflow) ) { FileEvent(file_reassembly_overflow, { - val->Ref(), - val_mgr->GetCount(current_offset), - val_mgr->GetCount(gap_bytes), + IntrusivePtr{NewRef{}, val}, + IntrusivePtr{AdoptRef{}, val_mgr->GetCount(current_offset)}, + IntrusivePtr{AdoptRef{}, val_mgr->GetCount(gap_bytes)} }); } } @@ -600,9 +599,9 @@ void File::Gap(uint64_t offset, uint64_t len) if ( FileEventAvailable(file_gap) ) { FileEvent(file_gap, { - val->Ref(), - val_mgr->GetCount(offset), - val_mgr->GetCount(len), + IntrusivePtr{NewRef{}, val}, + IntrusivePtr{AdoptRef{}, val_mgr->GetCount(offset)}, + IntrusivePtr{AdoptRef{}, val_mgr->GetCount(len)} }); } diff --git a/src/file_analysis/File.h b/src/file_analysis/File.h index 8992fca97f..3b0f06e6f4 100644 --- a/src/file_analysis/File.h +++ b/src/file_analysis/File.h @@ -176,7 +176,7 @@ public: * @param h pointer to an event handler. * @param vl list of argument values to pass to event call. */ - // TODO: deprecate + [[deprecated("Remove in v4.1. Use zeek::Args overload instead.")]] void FileEvent(EventHandlerPtr h, val_list* vl); /** @@ -184,7 +184,7 @@ public: * @param h pointer to an event handler. * @param vl list of argument values to pass to event call. */ - // TODO: deprecate + [[deprecated("Remove in v4.1. Use zeek::Args overload instead.")]] void FileEvent(EventHandlerPtr h, val_list vl); /** diff --git a/src/file_analysis/analyzer/extract/Extract.cc b/src/file_analysis/analyzer/extract/Extract.cc index 69ab2f16c7..2a4a5a54f7 100644 --- a/src/file_analysis/analyzer/extract/Extract.cc +++ b/src/file_analysis/analyzer/extract/Extract.cc @@ -92,10 +92,10 @@ bool Extract::DeliverStream(const u_char* data, uint64_t len) { File* f = GetFile(); f->FileEvent(file_extraction_limit, { - f->GetVal()->Ref(), - Args()->Ref(), - val_mgr->GetCount(limit), - val_mgr->GetCount(len), + IntrusivePtr{NewRef{}, f->GetVal()}, + IntrusivePtr{NewRef{}, Args()}, + IntrusivePtr{AdoptRef{}, val_mgr->GetCount(limit)}, + IntrusivePtr{AdoptRef{}, val_mgr->GetCount(len)} }); // Limit may have been modified by a BIF, re-check it.