only be built statically. The code will hopefully evolve and eliminate
these cases.
+IPS options are not guaranteed to get all they need for evaluation. For example,
+a packet may not have a flow assigned to it, or the flow may not have a gadget
+present. Not all options need specific inputs, so, if one does, that option should
+validate input values.
+Service-only options may not be guaranteed to get a gadget on the flow.
+
Several options use RangeCheck to implement upper and/or lower bound
semantics. The Snort 2X options had various implementations of ranges so
3X differs in some places.
{
RuleProfile profile(vbaDataPerfStats);
+ if (!p->flow or !p->flow->gadget)
+ return NO_MATCH;
+
InspectionBuffer buf;
if (!p->flow->gadget->get_fp_buf(buf.IBT_VBA, p, buf))
return NO_MATCH;
nullptr
};
+//-------------------------------------------------------------------------
+// UNIT TESTS
+//-------------------------------------------------------------------------
+#ifdef UNIT_TEST
+
+#include "catch/snort_catch.h"
+
+TEST_CASE("vba_data test", "[ips_vba_data]")
+{
+ VbaDataOption vba_data_opt;
+ Packet p;
+ p.data = (const uint8_t*) "foo";
+ p.dsize = strlen((const char*) p.data);
+
+ SECTION("null flow")
+ {
+ p.flow = nullptr;
+
+ Cursor c(&p);
+ REQUIRE(vba_data_opt.eval(c, &p) == IpsOption::NO_MATCH);
+ }
+
+ SECTION("null gadget")
+ {
+ Flow f;
+ p.flow = &f;
+ p.flow->gadget = nullptr;
+
+ Cursor c(&p);
+ REQUIRE(vba_data_opt.eval(c, &p) == IpsOption::NO_MATCH);
+ }
+}
+
+#endif