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::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
==========

View file

@ -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<RecordVal>(fa_metadata_type);
meta->Assign(meta_mime_type_idx, make_intrusive<StringVal>(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<RecordVal>(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)}
});
}

View file

@ -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);
/**

View file

@ -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.