Skip input framework entries with missing but non-optional fields

The framework so far populated data structures with missing fields
even when those fields are defined without the &optional
attribute. When using the attribute, such entries continue to get
populated.

Update tests to reflect focus on unset fields.
This commit is contained in:
Christian Kreibich 2021-06-16 16:55:28 -07:00
parent ef08605877
commit 937bdccab5
9 changed files with 122 additions and 59 deletions

View file

@ -1935,6 +1935,12 @@ RecordVal* Manager::ValueToRecordVal(const Stream* stream, const Value* const *v
// Better check that it really is optional. Uou never know.
assert(request_type->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL));
}
else if ( ! vals[*position]->present &&
! request_type->FieldDecl(i)->GetAttr(zeek::detail::ATTR_OPTIONAL) )
{
Warning(stream, "Skipping input with missing non-optional value");
have_error = true;
}
else
{
fieldVal = ValueToVal(stream, vals[*position], request_type->GetFieldType(i).get(), have_error);