Deprecate file_analysis::File::FileEvent methods using val_list args

And update usages to the overload that takes a zeek::Args instead.
This commit is contained in:
Jon Siwek 2020-03-25 16:20:22 -07:00
parent de47a50dde
commit e394ea38bc
4 changed files with 23 additions and 20 deletions

4
NEWS
View file

@ -59,6 +59,10 @@ Deprecated Functionality
``Connection::ConnectionEventFast()`` methods are now deprecated, use ``Connection::ConnectionEventFast()`` methods are now deprecated, use
``Connection::EnqueueEvent()`` instead. ``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 Zeek 3.1.0
========== ==========

View file

@ -155,9 +155,9 @@ void File::RaiseFileOverNewConnection(Connection* conn, bool is_orig)
if ( conn && FileEventAvailable(file_over_new_connection) ) if ( conn && FileEventAvailable(file_over_new_connection) )
{ {
FileEvent(file_over_new_connection, { FileEvent(file_over_new_connection, {
val->Ref(), IntrusivePtr{NewRef{}, val},
conn->BuildConnVal(), IntrusivePtr{AdoptRef{}, conn->BuildConnVal()},
val_mgr->GetBool(is_orig), IntrusivePtr{AdoptRef{}, val_mgr->GetBool(is_orig)},
}); });
} }
} }
@ -299,11 +299,11 @@ bool File::SetMime(const string& mime_type)
if ( ! FileEventAvailable(file_sniff) ) if ( ! FileEventAvailable(file_sniff) )
return false; return false;
RecordVal* meta = new RecordVal(fa_metadata_type); auto meta = make_intrusive<RecordVal>(fa_metadata_type);
meta->Assign(meta_mime_type_idx, make_intrusive<StringVal>(mime_type)); meta->Assign(meta_mime_type_idx, make_intrusive<StringVal>(mime_type));
meta->Assign(meta_inferred_idx, val_mgr->GetBool(0)); 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; return true;
} }
@ -332,7 +332,7 @@ void File::InferMetadata()
len = min(len, LookupFieldDefaultCount(bof_buffer_size_idx)); len = min(len, LookupFieldDefaultCount(bof_buffer_size_idx));
file_mgr->DetectMIME(data, len, &matches); file_mgr->DetectMIME(data, len, &matches);
RecordVal* meta = new RecordVal(fa_metadata_type); auto meta = make_intrusive<RecordVal>(fa_metadata_type);
if ( ! matches.empty() ) if ( ! matches.empty() )
{ {
@ -342,8 +342,7 @@ void File::InferMetadata()
file_analysis::GenMIMEMatchesVal(matches)); file_analysis::GenMIMEMatchesVal(matches));
} }
FileEvent(file_sniff, {val->Ref(), meta}); FileEvent(file_sniff, {IntrusivePtr{NewRef{}, val}, std::move(meta)});
return;
} }
bool File::BufferBOF(const u_char* data, uint64_t len) 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) ) if ( FileEventAvailable(file_reassembly_overflow) )
{ {
FileEvent(file_reassembly_overflow, { FileEvent(file_reassembly_overflow, {
val->Ref(), IntrusivePtr{NewRef{}, val},
val_mgr->GetCount(current_offset), IntrusivePtr{AdoptRef{}, val_mgr->GetCount(current_offset)},
val_mgr->GetCount(gap_bytes), IntrusivePtr{AdoptRef{}, val_mgr->GetCount(gap_bytes)}
}); });
} }
} }
@ -600,9 +599,9 @@ void File::Gap(uint64_t offset, uint64_t len)
if ( FileEventAvailable(file_gap) ) if ( FileEventAvailable(file_gap) )
{ {
FileEvent(file_gap, { FileEvent(file_gap, {
val->Ref(), IntrusivePtr{NewRef{}, val},
val_mgr->GetCount(offset), IntrusivePtr{AdoptRef{}, val_mgr->GetCount(offset)},
val_mgr->GetCount(len), IntrusivePtr{AdoptRef{}, val_mgr->GetCount(len)}
}); });
} }

View file

@ -176,7 +176,7 @@ public:
* @param h pointer to an event handler. * @param h pointer to an event handler.
* @param vl list of argument values to pass to event call. * @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); void FileEvent(EventHandlerPtr h, val_list* vl);
/** /**
@ -184,7 +184,7 @@ public:
* @param h pointer to an event handler. * @param h pointer to an event handler.
* @param vl list of argument values to pass to event call. * @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); void FileEvent(EventHandlerPtr h, val_list vl);
/** /**

View file

@ -92,10 +92,10 @@ bool Extract::DeliverStream(const u_char* data, uint64_t len)
{ {
File* f = GetFile(); File* f = GetFile();
f->FileEvent(file_extraction_limit, { f->FileEvent(file_extraction_limit, {
f->GetVal()->Ref(), IntrusivePtr{NewRef{}, f->GetVal()},
Args()->Ref(), IntrusivePtr{NewRef{}, Args()},
val_mgr->GetCount(limit), IntrusivePtr{AdoptRef{}, val_mgr->GetCount(limit)},
val_mgr->GetCount(len), IntrusivePtr{AdoptRef{}, val_mgr->GetCount(len)}
}); });
// Limit may have been modified by a BIF, re-check it. // Limit may have been modified by a BIF, re-check it.