Update all callers to more aggressively use UNITTESTS guards as well.
static int DetectAppLayerEventPktMatch(DetectEngineThreadCtx *det_ctx,
Packet *p, const Signature *s, const SigMatchCtx *ctx);
static int DetectAppLayerEventSetupP1(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectAppLayerEventRegisterTests(void);
+#endif
static void DetectAppLayerEventFree(DetectEngineCtx *, void *);
static int DetectEngineAptEventInspect(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
DetectAppLayerEventPktMatch;
sigmatch_table[DETECT_AL_APP_LAYER_EVENT].Setup = DetectAppLayerEventSetupP1;
sigmatch_table[DETECT_AL_APP_LAYER_EVENT].Free = DetectAppLayerEventFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_APP_LAYER_EVENT].RegisterTests =
DetectAppLayerEventRegisterTests;
-
+#endif
DetectAppLayerInspectEngineRegister("app-layer-events",
ALPROTO_UNKNOWN, SIG_FLAG_TOSERVER, 0,
DetectEngineAptEventInspect);
DetectAppLayerEventFree(NULL, aled);
PASS;
}
-#endif /* UNITTESTS */
/**
* \brief This function registers unit tests for "app-layer-event" keyword.
*/
-void DetectAppLayerEventRegisterTests(void)
+static void DetectAppLayerEventRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectAppLayerEventTest01", DetectAppLayerEventTest01);
UtRegisterTest("DetectAppLayerEventTest02", DetectAppLayerEventTest02);
UtRegisterTest("DetectAppLayerEventTest03", DetectAppLayerEventTest03);
UtRegisterTest("DetectAppLayerEventTest04", DetectAppLayerEventTest04);
UtRegisterTest("DetectAppLayerEventTest05", DetectAppLayerEventTest05);
UtRegisterTest("DetectAppLayerEventTest06", DetectAppLayerEventTest06);
-#endif /* UNITTESTS */
-
- return;
}
+#endif /* UNITTESTS */
#include "util-unittest.h"
#include "util-unittest-helper.h"
+#ifdef UNITTESTS
static void DetectAppLayerProtocolRegisterTests(void);
+#endif
static int DetectAppLayerProtocolPacketMatch(
DetectEngineThreadCtx *det_ctx,
DetectAppLayerProtocolSetup;
sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].Free =
DetectAppLayerProtocolFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].RegisterTests =
DetectAppLayerProtocolRegisterTests;
+#endif
sigmatch_table[DETECT_AL_APP_LAYER_PROTOCOL].flags =
(SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION);
PASS;
}
-#endif /* UNITTESTS */
static void DetectAppLayerProtocolRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectAppLayerProtocolTest01",
DetectAppLayerProtocolTest01);
UtRegisterTest("DetectAppLayerProtocolTest02",
DetectAppLayerProtocolTest13);
UtRegisterTest("DetectAppLayerProtocolTest14",
DetectAppLayerProtocolTest14);
-#endif /* UNITTESTS */
-
- return;
}
+#endif /* UNITTESTS */
static int DetectAsn1Match(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectAsn1Setup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectAsn1RegisterTests(void);
+#endif
static void DetectAsn1Free(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_ASN1].Match = DetectAsn1Match;
sigmatch_table[DETECT_ASN1].Setup = DetectAsn1Setup;
sigmatch_table[DETECT_ASN1].Free = DetectAsn1Free;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ASN1].RegisterTests = DetectAsn1RegisterTests;
-
- return;
+#endif
}
/**
return result;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectAsn1
*/
static void DetectAsn1RegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectAsn1TestReal01", DetectAsn1TestReal01);
UtRegisterTest("DetectAsn1TestReal02", DetectAsn1TestReal02);
UtRegisterTest("DetectAsn1TestReal03", DetectAsn1TestReal03);
UtRegisterTest("DetectAsn1TestReal04", DetectAsn1TestReal04);
-
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
#include "util-unittest.h"
static int DetectBase64DataSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectBase64DataRegisterTests(void);
+#endif
void DetectBase64DataRegister(void)
{
sigmatch_table[DETECT_BASE64_DATA].url =
"/rules/base64-keywords.html#base64-data";
sigmatch_table[DETECT_BASE64_DATA].Setup = DetectBase64DataSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_BASE64_DATA].RegisterTests =
DetectBase64DataRegisterTests;
-
+#endif
sigmatch_table[DETECT_BASE64_DATA].flags |= SIGMATCH_NOOPT;
}
return retval;
}
-#endif
-
static void DetectBase64DataRegisterTests(void)
{
-#ifdef UNITTESTS
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
UtRegisterTest("DetectBase64DataSetupTest01", DetectBase64DataSetupTest01);
UtRegisterTest("DetectBase64DataSetupTest02", DetectBase64DataSetupTest02);
UtRegisterTest("DetectBase64DataSetupTest03", DetectBase64DataSetupTest03);
UtRegisterTest("DetectBase64DataSetupTest04", DetectBase64DataSetupTest04);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
static int DetectBase64DecodeSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectBase64DecodeFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectBase64DecodeRegisterTests(void);
+#endif
void DetectBase64DecodeRegister(void)
{
"/rules/base64-keywords.html#base64-decode";
sigmatch_table[DETECT_BASE64_DECODE].Setup = DetectBase64DecodeSetup;
sigmatch_table[DETECT_BASE64_DECODE].Free = DetectBase64DecodeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_BASE64_DECODE].RegisterTests =
DetectBase64DecodeRegisterTests;
-
+#endif
sigmatch_table[DETECT_BASE64_DECODE].flags |= SIGMATCH_OPTIONAL_OPT;
DetectSetupParseRegexes(decode_pattern, &decode_pcre);
return retval;
}
-#endif
-
static void DetectBase64DecodeRegisterTests(void)
{
-#ifdef UNITTESTS
g_http_header_buffer_id = DetectBufferTypeGetByName("http_header");
UtRegisterTest("DetectBase64TestDecodeParse", DetectBase64TestDecodeParse);
DetectBase64DecodeTestDecodeLargeOffset);
UtRegisterTest("DetectBase64DecodeTestDecodeRelative",
DetectBase64DecodeTestDecodeRelative);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
static int DetectBypassMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectBypassSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectBypassRegisterTests(void);
+#endif
/**
* \brief Registration function for keyword: bypass
sigmatch_table[DETECT_BYPASS].Match = DetectBypassMatch;
sigmatch_table[DETECT_BYPASS].Setup = DetectBypassSetup;
sigmatch_table[DETECT_BYPASS].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_BYPASS].RegisterTests = DetectBypassRegisterTests;
+#endif
sigmatch_table[DETECT_BYPASS].flags = SIGMATCH_NOOPT;
}
SCFree(livedev);
PASS;
}
-#endif /* UNITTESTS */
static void DetectBypassRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectBypassTestSig01", DetectBypassTestSig01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
static DetectParseRegex parse_regex;
static int DetectByteExtractSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectByteExtractRegisterTests(void);
+#endif
static void DetectByteExtractFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_BYTE_EXTRACT].Match = NULL;
sigmatch_table[DETECT_BYTE_EXTRACT].Setup = DetectByteExtractSetup;
sigmatch_table[DETECT_BYTE_EXTRACT].Free = DetectByteExtractFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_BYTE_EXTRACT].RegisterTests = DetectByteExtractRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
return result;
}
-#endif /* UNITTESTS */
-
static void DetectByteExtractRegisterTests(void)
{
-#ifdef UNITTESTS
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
g_http_uri_buffer_id = DetectBufferTypeGetByName("http_uri");
UtRegisterTest("DetectByteExtractTestParseNoBase",
DetectByteExtractTestParseNoBase);
-#endif /* UNITTESTS */
-
- return;
}
+#endif /* UNITTESTS */
static DetectBytejumpData *DetectBytejumpParse(DetectEngineCtx *de_ctx, const char *optstr, char **offset);
static int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr);
static void DetectBytejumpFree(DetectEngineCtx*, void *ptr);
+#ifdef UNITTESTS
static void DetectBytejumpRegisterTests(void);
+#endif
void DetectBytejumpRegister (void)
{
sigmatch_table[DETECT_BYTEJUMP].Match = DetectBytejumpMatch;
sigmatch_table[DETECT_BYTEJUMP].Setup = DetectBytejumpSetup;
sigmatch_table[DETECT_BYTEJUMP].Free = DetectBytejumpFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_BYTEJUMP].RegisterTests = DetectBytejumpRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
PASS;
}
-#endif /* UNITTESTS */
-
-
/**
* \brief this function registers unit tests for DetectBytejump
*/
static void DetectBytejumpRegisterTests(void)
{
-#ifdef UNITTESTS
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data");
UtRegisterTest("DetectByteJumpTestPacket06", DetectByteJumpTestPacket06);
UtRegisterTest("DetectByteJumpTestPacket07", DetectByteJumpTestPacket07);
UtRegisterTest("DetectByteJumpTestPacket08", DetectByteJumpTestPacket08);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
static DetectParseRegex parse_regex;
static int DetectByteMathSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectByteMathRegisterTests(void);
+#endif
static void DetectByteMathFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_BYTEMATH].Match = NULL;
sigmatch_table[DETECT_BYTEMATH].Setup = DetectByteMathSetup;
sigmatch_table[DETECT_BYTEMATH].Free = DetectByteMathFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_BYTEMATH].RegisterTests = DetectByteMathRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
PASS;
}
-#endif /* UNITTESTS */
-
static void DetectByteMathRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectByteMathParseTest01", DetectByteMathParseTest01);
UtRegisterTest("DetectByteMathParseTest02", DetectByteMathParseTest02);
UtRegisterTest("DetectByteMathParseTest03", DetectByteMathParseTest03);
UtRegisterTest("DetectByteMathParseTest15", DetectByteMathParseTest15);
UtRegisterTest("DetectByteMathPacket01", DetectByteMathPacket01);
UtRegisterTest("DetectByteMathContext01", DetectByteMathContext01);
-#endif /* UNITTESTS */
-
- return;
}
+#endif /* UNITTESTS */
Packet *p, const Signature *s, const SigMatchCtx *ctx);
static int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, const char *optstr);
static void DetectBytetestFree(DetectEngineCtx *, void *ptr);
+#ifdef UNITTESTS
static void DetectBytetestRegisterTests(void);
+#endif
void DetectBytetestRegister (void)
{
sigmatch_table[DETECT_BYTETEST].Match = DetectBytetestMatch;
sigmatch_table[DETECT_BYTETEST].Setup = DetectBytetestSetup;
sigmatch_table[DETECT_BYTETEST].Free = DetectBytetestFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_BYTETEST].RegisterTests = DetectBytetestRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
PASS;
}
-#endif /* UNITTESTS */
-
-
/**
* \brief this function registers unit tests for DetectBytetest
*/
static void DetectBytetestRegisterTests(void)
{
-#ifdef UNITTESTS
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data");
UtRegisterTest("DetectByteTestTestPacket04", DetectByteTestTestPacket04);
UtRegisterTest("DetectByteTestTestPacket05", DetectByteTestTestPacket05);
UtRegisterTest("DetectByteTestTestPacket06", DetectByteTestTestPacket06);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
*/
static int DetectCipServiceSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectCipServiceFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectCipServiceRegisterTests(void);
+#endif
static int g_cip_buffer_id = 0;
/**
sigmatch_table[DETECT_CIPSERVICE].Match = NULL;
sigmatch_table[DETECT_CIPSERVICE].Setup = DetectCipServiceSetup;
sigmatch_table[DETECT_CIPSERVICE].Free = DetectCipServiceFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_CIPSERVICE].RegisterTests
= DetectCipServiceRegisterTests;
-
+#endif
DetectAppLayerInspectEngineRegister("cip",
ALPROTO_ENIP, SIG_FLAG_TOSERVER, 0,
DetectEngineInspectCIP);
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectCipService
*/
static void DetectCipServiceRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectCipServiceParseTest01",
DetectCipServiceParseTest01);
UtRegisterTest("DetectCipServiceSignatureTest01",
DetectCipServiceSignatureTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
/*
* ENIP COMMAND CODE
*/
static int DetectEnipCommandSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectEnipCommandFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectEnipCommandRegisterTests(void);
+#endif
static int g_enip_buffer_id = 0;
/**
sigmatch_table[DETECT_ENIPCOMMAND].Match = NULL;
sigmatch_table[DETECT_ENIPCOMMAND].Setup = DetectEnipCommandSetup;
sigmatch_table[DETECT_ENIPCOMMAND].Free = DetectEnipCommandFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ENIPCOMMAND].RegisterTests
= DetectEnipCommandRegisterTests;
-
+#endif
DetectAppLayerInspectEngineRegister("enip",
ALPROTO_ENIP, SIG_FLAG_TOSERVER, 0,
DetectEngineInspectENIP);
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectEnipCommand
*/
static void DetectEnipCommandRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectEnipCommandParseTest01",
DetectEnipCommandParseTest01);
UtRegisterTest("DetectEnipCommandSignatureTest01",
DetectEnipCommandSignatureTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static DetectParseRegex parse_regex;
static int DetectClasstypeSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectClasstypeRegisterTests(void);
+#endif
/**
* \brief Registers the handler functions for the "Classtype" keyword.
sigmatch_table[DETECT_CLASSTYPE].desc = "information about the classification of rules and alerts";
sigmatch_table[DETECT_CLASSTYPE].url = "/rules/meta.html#classtype";
sigmatch_table[DETECT_CLASSTYPE].Setup = DetectClasstypeSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_CLASSTYPE].RegisterTests = DetectClasstypeRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief This function registers unit tests for Classification Config API.
*/
static void DetectClasstypeRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectClasstypeTest01", DetectClasstypeTest01);
UtRegisterTest("DetectClasstypeTest02", DetectClasstypeTest02);
UtRegisterTest("DetectClasstypeTest03", DetectClasstypeTest03);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
const Signature *s, const SigMatchCtx *ctx);
static int DetectConfigSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectConfigFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectConfigRegisterTests(void);
+#endif
/**
* \brief Registration function for keyword: filestore
sigmatch_table[DETECT_CONFIG].Match = DetectConfigPostMatch;
sigmatch_table[DETECT_CONFIG].Setup = DetectConfigSetup;
sigmatch_table[DETECT_CONFIG].Free = DetectConfigFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_CONFIG].RegisterTests = DetectConfigRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
DetectEngineCtxFree(de_ctx);
PASS;
}
-#endif /* UNITTESTS */
void DetectConfigRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectConfigTest01", DetectConfigTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
#include "util-profiling.h"
#include "detect-dsize.h"
+#ifdef UNITTESTS
static void DetectContentRegisterTests(void);
+#endif
void DetectContentRegister (void)
{
sigmatch_table[DETECT_CONTENT].Match = NULL;
sigmatch_table[DETECT_CONTENT].Setup = DetectContentSetup;
sigmatch_table[DETECT_CONTENT].Free = DetectContentFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_CONTENT].RegisterTests = DetectContentRegisterTests;
+#endif
sigmatch_table[DETECT_CONTENT].flags = (SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION);
}
return !DetectLongContentTestCommon(sig, 1);
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectContent
*/
static void DetectContentRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data");
UtRegisterTest("DetectLongContentTest1", DetectLongContentTest1);
UtRegisterTest("DetectLongContentTest2", DetectLongContentTest2);
UtRegisterTest("DetectLongContentTest3", DetectLongContentTest3);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
static int DetectICMPV6CsumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectICMPV6CsumFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectCsumRegisterTests(void);
+#endif
/**
* \brief Registers handlers for all the checksum keywords. The checksum
sigmatch_table[DETECT_IPV4_CSUM].Match = DetectIPV4CsumMatch;
sigmatch_table[DETECT_IPV4_CSUM].Setup = DetectIPV4CsumSetup;
sigmatch_table[DETECT_IPV4_CSUM].Free = DetectIPV4CsumFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_IPV4_CSUM].RegisterTests = DetectCsumRegisterTests;
+#endif
sigmatch_table[DETECT_TCPV4_CSUM].name = "tcpv4-csum";
sigmatch_table[DETECT_TCPV4_CSUM].Match = DetectTCPV4CsumMatch;
sigmatch_table[DETECT_TCPV4_CSUM].Setup = DetectTCPV4CsumSetup;
sigmatch_table[DETECT_TCPV4_CSUM].Free = DetectTCPV4CsumFree;
- sigmatch_table[DETECT_TCPV4_CSUM].RegisterTests = NULL;
sigmatch_table[DETECT_TCPV6_CSUM].name = "tcpv6-csum";
sigmatch_table[DETECT_TCPV6_CSUM].Match = DetectTCPV6CsumMatch;
sigmatch_table[DETECT_TCPV6_CSUM].Setup = DetectTCPV6CsumSetup;
sigmatch_table[DETECT_TCPV6_CSUM].Free = DetectTCPV6CsumFree;
- sigmatch_table[DETECT_TCPV6_CSUM].RegisterTests = NULL;
sigmatch_table[DETECT_UDPV4_CSUM].name = "udpv4-csum";
sigmatch_table[DETECT_UDPV4_CSUM].Match = DetectUDPV4CsumMatch;
sigmatch_table[DETECT_UDPV4_CSUM].Setup = DetectUDPV4CsumSetup;
sigmatch_table[DETECT_UDPV4_CSUM].Free = DetectUDPV4CsumFree;
- sigmatch_table[DETECT_UDPV4_CSUM].RegisterTests = NULL;
sigmatch_table[DETECT_UDPV6_CSUM].name = "udpv6-csum";
sigmatch_table[DETECT_UDPV6_CSUM].Match = DetectUDPV6CsumMatch;
sigmatch_table[DETECT_UDPV6_CSUM].Setup = DetectUDPV6CsumSetup;
sigmatch_table[DETECT_UDPV6_CSUM].Free = DetectUDPV6CsumFree;
- sigmatch_table[DETECT_UDPV6_CSUM].RegisterTests = NULL;
sigmatch_table[DETECT_ICMPV4_CSUM].name = "icmpv4-csum";
sigmatch_table[DETECT_ICMPV4_CSUM].Match = DetectICMPV4CsumMatch;
sigmatch_table[DETECT_ICMPV4_CSUM].Setup = DetectICMPV4CsumSetup;
sigmatch_table[DETECT_ICMPV4_CSUM].Free = DetectICMPV4CsumFree;
- sigmatch_table[DETECT_ICMPV4_CSUM].RegisterTests = NULL;
sigmatch_table[DETECT_ICMPV6_CSUM].name = "icmpv6-csum";
sigmatch_table[DETECT_ICMPV6_CSUM].Match = DetectICMPV6CsumMatch;
sigmatch_table[DETECT_ICMPV6_CSUM].Setup = DetectICMPV6CsumSetup;
sigmatch_table[DETECT_ICMPV6_CSUM].Free = DetectICMPV6CsumFree;
- sigmatch_table[DETECT_ICMPV6_CSUM].RegisterTests = NULL;
-
- return;
}
/**
PASS;
}
-#endif /* UNITTESTS */
-
static void DetectCsumRegisterTests(void)
{
-#ifdef UNITTESTS
-
UtRegisterTest("DetectCsumValidArgsTestParse01",
DetectCsumValidArgsTestParse01);
UtRegisterTest("DetectCsumInvalidArgsTestParse02",
UtRegisterTest("DetectCsumICMPV6Test01",
DetectCsumICMPV6Test01);
-
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
const Signature *s, const SigMatchCtx *m);
static int DetectDceIfaceSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectDceIfaceFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectDceIfaceRegisterTests(void);
+#endif
static int g_dce_generic_list_id = 0;
static int InspectDceGeneric(ThreadVars *tv,
sigmatch_table[DETECT_DCE_IFACE].AppLayerTxMatch = DetectDceIfaceMatchRust;
sigmatch_table[DETECT_DCE_IFACE].Setup = DetectDceIfaceSetup;
sigmatch_table[DETECT_DCE_IFACE].Free = DetectDceIfaceFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_DCE_IFACE].RegisterTests = DetectDceIfaceRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
g_dce_generic_list_id = DetectBufferTypeRegister("dce_generic");
return result;
}
-#endif
-
static void DetectDceIfaceRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDceIfaceTestParse1", DetectDceIfaceTestParse1);
/* Disabled because of bug_753. Would be enabled, once we rewrite
* dce parser */
UtRegisterTest("DetectDceIfaceTestParse13", DetectDceIfaceTestParse13, 1);
#endif
UtRegisterTest("DetectDceIfaceTestParse2", DetectDceIfaceTestParse2);
-#endif
}
+#endif /* UNITTESTS */
const Signature *s, const SigMatchCtx *m);
static int DetectDceOpnumSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectDceOpnumFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectDceOpnumRegisterTests(void);
+#endif
static int g_dce_generic_list_id = 0;
/**
sigmatch_table[DETECT_DCE_OPNUM].AppLayerTxMatch = DetectDceOpnumMatchRust;
sigmatch_table[DETECT_DCE_OPNUM].Setup = DetectDceOpnumSetup;
sigmatch_table[DETECT_DCE_OPNUM].Free = DetectDceOpnumFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_DCE_OPNUM].RegisterTests = DetectDceOpnumRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
g_dce_generic_list_id = DetectBufferTypeRegister("dce_generic");
return result;
}
#endif
-#endif /* UNITTESTS */
static void DetectDceOpnumRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDceOpnumTestParse01", DetectDceOpnumTestParse01);
UtRegisterTest("DetectDceOpnumTestParse02", DetectDceOpnumTestParse02);
/* Disabled because of bug_753. Would be enabled, once we rewrite
UtRegisterTest("DetectDceOpnumTestParse12", DetectDceOpnumTestParse12, 1);
UtRegisterTest("DetectDceOpnumTestParse13", DetectDceOpnumTestParse13, 1);
#endif
-#endif
}
+#endif /* UNITTESTS */
#define KEYWORD_NAME "dce_stub_data"
static int DetectDceStubDataSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectDceStubDataRegisterTests(void);
+#endif
static int g_dce_stub_data_buffer_id = 0;
static InspectionBuffer *GetSMBData(DetectEngineThreadCtx *det_ctx,
sigmatch_table[DETECT_DCE_STUB_DATA].name = "dcerpc.stub_data";
sigmatch_table[DETECT_DCE_STUB_DATA].alias = "dce_stub_data";
sigmatch_table[DETECT_DCE_STUB_DATA].Setup = DetectDceStubDataSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_DCE_STUB_DATA].RegisterTests = DetectDceStubDataRegisterTests;
+#endif
sigmatch_table[DETECT_DCE_STUB_DATA].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER;
DetectAppLayerInspectEngineRegister2(BUFFER_NAME,
return result;
}
-
-#endif
-
static void DetectDceStubDataRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDceStubDataTestParse01",
DetectDceStubDataTestParse01);
UtRegisterTest("DetectDceStubDataTestParse02",
DetectDceStubDataTestParse04);
UtRegisterTest("DetectDceStubDataTestParse05",
DetectDceStubDataTestParse05);
-#endif
-
- return;
}
+#endif
sigmatch_table[DETECT_DEPTH].Match = NULL;
sigmatch_table[DETECT_DEPTH].Setup = DetectDepthSetup;
sigmatch_table[DETECT_DEPTH].Free = NULL;
- sigmatch_table[DETECT_DEPTH].RegisterTests = NULL;
sigmatch_table[DETECT_STARTS_WITH].name = "startswith";
sigmatch_table[DETECT_STARTS_WITH].desc = "pattern must be at the start of a buffer (same as 'depth:<pattern len>')";
static int DetectDetectionFilterMatch(DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectDetectionFilterSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectDetectionFilterRegisterTests(void);
+#endif
static void DetectDetectionFilterFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_DETECTION_FILTER].Match = DetectDetectionFilterMatch;
sigmatch_table[DETECT_DETECTION_FILTER].Setup = DetectDetectionFilterSetup;
sigmatch_table[DETECT_DETECTION_FILTER].Free = DetectDetectionFilterFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_DETECTION_FILTER].RegisterTests = DetectDetectionFilterRegisterTests;
+#endif
/* this is compatible to ip-only signatures */
sigmatch_table[DETECT_DETECTION_FILTER].flags |= SIGMATCH_IPONLY_COMPAT;
HostShutdown();
return result;
}
-#endif /* UNITTESTS */
static void DetectDetectionFilterRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDetectionFilterTestParse01",
DetectDetectionFilterTestParse01);
UtRegisterTest("DetectDetectionFilterTestParse02",
DetectDetectionFilterTestSig2);
UtRegisterTest("DetectDetectionFilterTestSig3",
DetectDetectionFilterTestSig3);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
#include "util-unittest-helper.h"
static int DetectDistanceSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectDistanceRegisterTests(void);
+#endif
void DetectDistanceRegister(void)
{
sigmatch_table[DETECT_DISTANCE].Match = NULL;
sigmatch_table[DETECT_DISTANCE].Setup = DetectDistanceSetup;
sigmatch_table[DETECT_DISTANCE].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_DISTANCE].RegisterTests = DetectDistanceRegisterTests;
+#endif
}
static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
end:
return result;
}
-#endif /* UNITTESTS */
static void DetectDistanceRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDistanceTest01 -- distance / within mix",
DetectDistanceTest01);
UtRegisterTest("DetectDistanceTestPacket01", DetectDistanceTestPacket01);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
{"authenticate_resp", 131}
};
+#ifdef UNITTESTS
static void DetectDNP3FuncRegisterTests(void);
static void DetectDNP3IndRegisterTests(void);
static void DetectDNP3ObjRegisterTests(void);
static void DetectDNP3DataRegisterTests(void);
+#endif
/**
* \brief Utility function to trim leading and trailing whitespace
sigmatch_table[DETECT_AL_DNP3FUNC].AppLayerTxMatch = DetectDNP3FuncMatch;
sigmatch_table[DETECT_AL_DNP3FUNC].Setup = DetectDNP3FuncSetup;
sigmatch_table[DETECT_AL_DNP3FUNC].Free = DetectDNP3Free;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_DNP3FUNC].RegisterTests =
DetectDNP3FuncRegisterTests;
-
+#endif
SCReturn;
}
sigmatch_table[DETECT_AL_DNP3IND].AppLayerTxMatch = DetectDNP3IndMatch;
sigmatch_table[DETECT_AL_DNP3IND].Setup = DetectDNP3IndSetup;
sigmatch_table[DETECT_AL_DNP3IND].Free = DetectDNP3Free;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_DNP3IND].RegisterTests =
DetectDNP3IndRegisterTests;
-
+#endif
SCReturn;
}
sigmatch_table[DETECT_AL_DNP3OBJ].AppLayerTxMatch = DetectDNP3ObjMatch;
sigmatch_table[DETECT_AL_DNP3OBJ].Setup = DetectDNP3ObjSetup;
sigmatch_table[DETECT_AL_DNP3OBJ].Free = DetectDNP3Free;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_DNP3OBJ].RegisterTests =
DetectDNP3ObjRegisterTests;
-
+#endif
SCReturn;
}
sigmatch_table[DETECT_AL_DNP3DATA].desc = "make the following content options to match on the re-assembled application buffer";
sigmatch_table[DETECT_AL_DNP3DATA].url = "/rules/dnp3-keywords.html#dnp3-data";
sigmatch_table[DETECT_AL_DNP3DATA].Setup = DetectDNP3DataSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_DNP3DATA].RegisterTests =
DetectDNP3DataRegisterTests;
-
+#endif
sigmatch_table[DETECT_AL_DNP3DATA].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER;
DetectAppLayerInspectEngineRegister2("dnp3_data",
PASS;
}
-#endif
-
static void DetectDNP3FuncRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDNP3FuncParseFunctionCodeTest",
DetectDNP3FuncParseFunctionCodeTest);
UtRegisterTest("DetectDNP3FuncTest01", DetectDNP3FuncTest01);
-#endif
}
static void DetectDNP3IndRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDNP3IndTestParseAsInteger",
DetectDNP3IndTestParseAsInteger);
UtRegisterTest("DetectDNP3IndTestParseByName",
DetectDNP3IndTestParseByName);
-#endif
}
static void DetectDNP3ObjRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDNP3ObjParseTest", DetectDNP3ObjParseTest);
UtRegisterTest("DetectDNP3ObjSetupTest", DetectDNP3ObjSetupTest);
-#endif
}
void DetectDNP3DataRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDNP3DataTest01", DetectDNP3DataTest01);
UtRegisterTest("DetectDNP3DataTest02", DetectDNP3DataTest02);
-#endif
}
+#endif
#include "rust.h"
static int DetectDnsQuerySetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectDnsQueryRegisterTests(void);
+#endif
static int g_dns_query_buffer_id = 0;
struct DnsQueryGetDataArgs {
sigmatch_table[DETECT_AL_DNS_QUERY].desc = "sticky buffer to match DNS query-buffer";
sigmatch_table[DETECT_AL_DNS_QUERY].url = "/rules/dns-keywords.html#dns-query";
sigmatch_table[DETECT_AL_DNS_QUERY].Setup = DetectDnsQuerySetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_DNS_QUERY].RegisterTests = DetectDnsQueryRegisterTests;
+#endif
sigmatch_table[DETECT_AL_DNS_QUERY].flags |= SIGMATCH_NOOPT;
sigmatch_table[DETECT_AL_DNS_QUERY].flags |= SIGMATCH_INFO_STICKY_BUFFER;
PASS;
}
-#endif
-
static void DetectDnsQueryRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectDnsQueryTest01", DetectDnsQueryTest01);
UtRegisterTest("DetectDnsQueryTest02", DetectDnsQueryTest02);
UtRegisterTest("DetectDnsQueryTest03 -- tcp", DetectDnsQueryTest03);
UtRegisterTest("DetectDnsQueryIsdataatParseTest",
DetectDnsQueryIsdataatParseTest);
-#endif
}
+#endif
static int DetectDsizeMatch (DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectDsizeSetup (DetectEngineCtx *, Signature *s, const char *str);
+#ifdef UNITTESTS
static void DsizeRegisterTests(void);
+#endif
static void DetectDsizeFree(DetectEngineCtx *, void *);
static int PrefilterSetupDsize(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
sigmatch_table[DETECT_DSIZE].Match = DetectDsizeMatch;
sigmatch_table[DETECT_DSIZE].Setup = DetectDsizeSetup;
sigmatch_table[DETECT_DSIZE].Free = DetectDsizeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_DSIZE].RegisterTests = DsizeRegisterTests;
-
+#endif
sigmatch_table[DETECT_DSIZE].SupportsPrefilter = PrefilterDsizeIsPrefilterable;
sigmatch_table[DETECT_DSIZE].SetupPrefilter = PrefilterSetupDsize;
return result;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for dsize
*/
static void DsizeRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DsizeTestParse01", DsizeTestParse01);
UtRegisterTest("DsizeTestParse02", DsizeTestParse02);
UtRegisterTest("DsizeTestParse03", DsizeTestParse03);
UtRegisterTest("DsizeTestParse20", DsizeTestParse20);
UtRegisterTest("DetectDsizeIcmpv6Test01", DetectDsizeIcmpv6Test01);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
static int DetectDecodeEventSetup (DetectEngineCtx *, Signature *, const char *);
static int DetectStreamEventSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectEngineEventFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
void EngineEventRegisterTests(void);
-
+#endif
/**
* \brief Registration function for decode-event: keyword
sigmatch_table[DETECT_ENGINE_EVENT].Match = DetectEngineEventMatch;
sigmatch_table[DETECT_ENGINE_EVENT].Setup = DetectEngineEventSetup;
sigmatch_table[DETECT_ENGINE_EVENT].Free = DetectEngineEventFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ENGINE_EVENT].RegisterTests = EngineEventRegisterTests;
+#endif
sigmatch_table[DETECT_DECODE_EVENT].name = "decode-event";
sigmatch_table[DETECT_DECODE_EVENT].Match = DetectEngineEventMatch;
SCFree(p);
return 0;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for EngineEvent
*/
void EngineEventRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("EngineEventTestParse01", EngineEventTestParse01);
UtRegisterTest("EngineEventTestParse02", EngineEventTestParse02);
UtRegisterTest("EngineEventTestParse03", EngineEventTestParse03);
UtRegisterTest("EngineEventTestParse04", EngineEventTestParse04);
UtRegisterTest("EngineEventTestParse05", EngineEventTestParse05);
UtRegisterTest("EngineEventTestParse06", EngineEventTestParse06);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
DetectBufferTypeCloseRegistration();
}
+#ifdef UNITTESTS
void SigTableRegisterTests(void)
{
/* register the tests */
- int i = 0;
- for (i = 0; i < DETECT_TBLSIZE; i++) {
+ for (int i = 0; i < DETECT_TBLSIZE; i++) {
g_ut_modules++;
if (sigmatch_table[i].RegisterTests != NULL) {
sigmatch_table[i].RegisterTests();
}
}
}
+#endif
static DetectParseRegex parse_regex;
static int DetectFastPatternSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectFastPatternRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectFastPatternRegisterTests(void);
+#endif
/* holds the list of sm match lists that need to be searched for a keyword
* that has fp support */
sigmatch_table[DETECT_FAST_PATTERN].Match = NULL;
sigmatch_table[DETECT_FAST_PATTERN].Setup = DetectFastPatternSetup;
sigmatch_table[DETECT_FAST_PATTERN].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FAST_PATTERN].RegisterTests = DetectFastPatternRegisterTests;
-
+#endif
sigmatch_table[DETECT_FAST_PATTERN].flags |= SIGMATCH_NOOPT;
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
PASS;
}
-#endif
-
-void DetectFastPatternRegisterTests(void)
+static void DetectFastPatternRegisterTests(void)
{
-#ifdef UNITTESTS
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
g_http_method_buffer_id = DetectBufferTypeGetByName("http_method");
g_http_uri_buffer_id = DetectBufferTypeGetByName("http_uri");
* - if 2 duplicate patterns, with no chop set get unique ids.
*/
UtRegisterTest("DetectFastPatternTest671", DetectFastPatternTest671);
-#endif
-
- return;
}
+#endif
static int DetectFileextMatch (DetectEngineThreadCtx *, Flow *,
uint8_t, File *, const Signature *, const SigMatchCtx *);
static int DetectFileextSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectFileextRegisterTests(void);
+#endif
static void DetectFileextFree(DetectEngineCtx *, void *);
static int g_file_match_list_id = 0;
sigmatch_table[DETECT_FILEEXT].FileMatch = DetectFileextMatch;
sigmatch_table[DETECT_FILEEXT].Setup = DetectFileextSetup;
sigmatch_table[DETECT_FILEEXT].Free = DetectFileextFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILEEXT].RegisterTests = DetectFileextRegisterTests;
+#endif
sigmatch_table[DETECT_FILEEXT].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION;
sigmatch_table[DETECT_FILEEXT].alternative = DETECT_FILE_NAME;
return 0;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectFileext
*/
void DetectFileextRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectFileextTestParse01", DetectFileextTestParse01);
UtRegisterTest("DetectFileextTestParse02", DetectFileextTestParse02);
UtRegisterTest("DetectFileextTestParse03", DetectFileextTestParse03);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
static int DetectFilemagicMatch (DetectEngineThreadCtx *, Flow *,
uint8_t, File *, const Signature *, const SigMatchCtx *);
static int DetectFilemagicSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectFilemagicRegisterTests(void);
+#endif
static void DetectFilemagicFree(DetectEngineCtx *, void *);
static int g_file_match_list_id = 0;
sigmatch_table[DETECT_FILEMAGIC].FileMatch = DetectFilemagicMatch;
sigmatch_table[DETECT_FILEMAGIC].Setup = DetectFilemagicSetup;
sigmatch_table[DETECT_FILEMAGIC].Free = DetectFilemagicFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILEMAGIC].RegisterTests = DetectFilemagicRegisterTests;
+#endif
sigmatch_table[DETECT_FILEMAGIC].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION;
sigmatch_table[DETECT_FILEMAGIC].alternative = DETECT_FILE_MAGIC;
return 0;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectFilemagic
*/
void DetectFilemagicRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectFilemagicTestParse01", DetectFilemagicTestParse01);
UtRegisterTest("DetectFilemagicTestParse02", DetectFilemagicTestParse02);
UtRegisterTest("DetectFilemagicTestParse03", DetectFilemagicTestParse03);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
#endif /* HAVE_MAGIC */
void DetectFileMd5Register(void)
{
sigmatch_table[DETECT_FILEMD5].name = "filemd5";
- sigmatch_table[DETECT_FILEMD5].FileMatch = NULL;
sigmatch_table[DETECT_FILEMD5].Setup = DetectFileMd5SetupNoSupport;
- sigmatch_table[DETECT_FILEMD5].Free = NULL;
- sigmatch_table[DETECT_FILEMD5].RegisterTests = NULL;
sigmatch_table[DETECT_FILEMD5].flags = SIGMATCH_NOT_BUILT;
SCLogDebug("registering filemd5 rule option");
static int g_file_match_list_id = 0;
static int DetectFileMd5Setup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectFileMd5RegisterTests(void);
+#endif
/**
* \brief Registration function for keyword: filemd5
sigmatch_table[DETECT_FILEMD5].FileMatch = DetectFileHashMatch;
sigmatch_table[DETECT_FILEMD5].Setup = DetectFileMd5Setup;
sigmatch_table[DETECT_FILEMD5].Free = DetectFileHashFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILEMD5].RegisterTests = DetectFileMd5RegisterTests;
-
+#endif
g_file_match_list_id = DetectBufferTypeRegister("files");
SCLogDebug("registering filemd5 rule option");
ROHashFree(hash);
return 1;
}
-#endif
void DetectFileMd5RegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("MD5MatchTest01", MD5MatchTest01);
-#endif
}
+#endif
#endif /* HAVE_NSS */
uint8_t, File *, const Signature *, const SigMatchCtx *);
static int DetectFilenameSetup (DetectEngineCtx *, Signature *, const char *);
static int DetectFilenameSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str);
+#ifdef UNITTESTS
static void DetectFilenameRegisterTests(void);
+#endif
static void DetectFilenameFree(DetectEngineCtx *, void *);
static int g_file_match_list_id = 0;
static int g_file_name_buffer_id = 0;
sigmatch_table[DETECT_FILENAME].FileMatch = DetectFilenameMatch;
sigmatch_table[DETECT_FILENAME].Setup = DetectFilenameSetup;
sigmatch_table[DETECT_FILENAME].Free = DetectFilenameFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILENAME].RegisterTests = DetectFilenameRegisterTests;
+#endif
sigmatch_table[DETECT_FILENAME].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION;
sigmatch_table[DETECT_FILENAME].alternative = DETECT_FILE_NAME;
return 0;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for DetectFilename
*/
void DetectFilenameRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectFilenameSignatureParseTest01", DetectFilenameSignatureParseTest01);
UtRegisterTest("DetectFilenameTestParse01", DetectFilenameTestParse01);
UtRegisterTest("DetectFilenameTestParse02", DetectFilenameTestParse02);
UtRegisterTest("DetectFilenameTestParse03", DetectFilenameTestParse03);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
void DetectFileSha1Register(void)
{
sigmatch_table[DETECT_FILESHA1].name = "filesha1";
- sigmatch_table[DETECT_FILESHA1].FileMatch = NULL;
sigmatch_table[DETECT_FILESHA1].Setup = DetectFileSha1SetupNoSupport;
- sigmatch_table[DETECT_FILESHA1].Free = NULL;
- sigmatch_table[DETECT_FILESHA1].RegisterTests = NULL;
sigmatch_table[DETECT_FILESHA1].flags = SIGMATCH_NOT_BUILT;
SCLogDebug("registering filesha1 rule option");
#else /* HAVE_NSS */
static int DetectFileSha1Setup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectFileSha1RegisterTests(void);
+#endif
static int g_file_match_list_id = 0;
/**
sigmatch_table[DETECT_FILESHA1].FileMatch = DetectFileHashMatch;
sigmatch_table[DETECT_FILESHA1].Setup = DetectFileSha1Setup;
sigmatch_table[DETECT_FILESHA1].Free = DetectFileHashFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILESHA1].RegisterTests = DetectFileSha1RegisterTests;
-
+#endif
g_file_match_list_id = DetectBufferTypeRegister("files");
SCLogDebug("registering filesha1 rule option");
ROHashFree(hash);
return 1;
}
-#endif
-void DetectFileSha1RegisterTests(void)
+static void DetectFileSha1RegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("SHA1MatchTest01", SHA1MatchTest01);
-#endif
}
-
+#endif
#endif /* HAVE_NSS */
void DetectFileSha256Register(void)
{
sigmatch_table[DETECT_FILESHA256].name = "filesha256";
- sigmatch_table[DETECT_FILESHA256].FileMatch = NULL;
sigmatch_table[DETECT_FILESHA256].Setup = DetectFileSha256SetupNoSupport;
- sigmatch_table[DETECT_FILESHA256].Free = NULL;
- sigmatch_table[DETECT_FILESHA256].RegisterTests = NULL;
sigmatch_table[DETECT_FILESHA256].flags = SIGMATCH_NOT_BUILT;
SCLogDebug("registering filesha256 rule option");
#else /* HAVE_NSS */
static int DetectFileSha256Setup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectFileSha256RegisterTests(void);
+#endif
static int g_file_match_list_id = 0;
/**
sigmatch_table[DETECT_FILESHA256].FileMatch = DetectFileHashMatch;
sigmatch_table[DETECT_FILESHA256].Setup = DetectFileSha256Setup;
sigmatch_table[DETECT_FILESHA256].Free = DetectFileHashFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILESHA256].RegisterTests = DetectFileSha256RegisterTests;
+#endif
g_file_match_list_id = DetectBufferTypeRegister("files");
ROHashFree(hash);
return 1;
}
-#endif
void DetectFileSha256RegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("SHA256MatchTest01", SHA256MatchTest01);
-#endif
}
-
+#endif
#endif /* HAVE_NSS */
uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m);
static int DetectFilesizeSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectFilesizeFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectFilesizeRegisterTests (void);
+#endif
static int g_file_match_list_id = 0;
/**
sigmatch_table[DETECT_FILESIZE].FileMatch = DetectFilesizeMatch;
sigmatch_table[DETECT_FILESIZE].Setup = DetectFilesizeSetup;
sigmatch_table[DETECT_FILESIZE].Free = DetectFilesizeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILESIZE].RegisterTests = DetectFilesizeRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
g_file_match_list_id = DetectBufferTypeRegister("files");
return res;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectFilesize
*/
void DetectFilesizeRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectFilesizeParseTest01", DetectFilesizeParseTest01);
UtRegisterTest("DetectFilesizeParseTest02", DetectFilesizeParseTest02);
UtRegisterTest("DetectFilesizeParseTest03", DetectFilesizeParseTest03);
UtRegisterTest("DetectFilesizeParseTest04", DetectFilesizeParseTest04);
UtRegisterTest("DetectFilesizeParseTest05", DetectFilesizeParseTest05);
UtRegisterTest("DetectFilesizeSetpTest01", DetectFilesizeSetpTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
Packet *p, const Signature *s, const SigMatchCtx *ctx);
static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectFilestoreFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectFilestoreRegisterTests(void);
+#endif
static int g_file_match_list_id = 0;
/**
sigmatch_table[DETECT_FILESTORE].FileMatch = DetectFilestoreMatch;
sigmatch_table[DETECT_FILESTORE].Setup = DetectFilestoreSetup;
sigmatch_table[DETECT_FILESTORE].Free = DetectFilestoreFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FILESTORE].RegisterTests = DetectFilestoreRegisterTests;
+#endif
sigmatch_table[DETECT_FILESTORE].flags = SIGMATCH_OPTIONAL_OPT;
sigmatch_table[DETECT_FILESTORE_POSTMATCH].name = "__filestore__postmatch__";
return result;
}
-#endif /* UNITTESTS */
void DetectFilestoreRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectFilestoreTest01", DetectFilestoreTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
int DetectFlowMatch (DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectFlowSetup (DetectEngineCtx *, Signature *, const char *);
-void DetectFlowRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectFlowRegisterTests(void);
+#endif
void DetectFlowFree(DetectEngineCtx *, void *);
static int PrefilterSetupFlow(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
sigmatch_table[DETECT_FLOW].Match = DetectFlowMatch;
sigmatch_table[DETECT_FLOW].Setup = DetectFlowSetup;
sigmatch_table[DETECT_FLOW].Free = DetectFlowFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FLOW].RegisterTests = DetectFlowRegisterTests;
-
+#endif
sigmatch_table[DETECT_FLOW].SupportsPrefilter = PrefilterFlowIsPrefilterable;
sigmatch_table[DETECT_FLOW].SetupPrefilter = PrefilterSetupFlow;
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectFlow
*/
-void DetectFlowRegisterTests(void)
+static void DetectFlowRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectFlowTestParse01", DetectFlowTestParse01);
UtRegisterTest("DetectFlowTestParse02", DetectFlowTestParse02);
UtRegisterTest("DetectFlowTestParse03", DetectFlowTestParse03);
UtRegisterTest("DetectFlowTestOnlyFragMatch", DetectFlowTestOnlyFragMatch);
UtRegisterTest("DetectFlowSigTest01", DetectFlowSigTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectFlowbitSetup (DetectEngineCtx *, Signature *, const char *);
static int FlowbitOrAddData(DetectEngineCtx *, DetectFlowbitsData *, char *);
void DetectFlowbitFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
void FlowBitsRegisterTests(void);
+#endif
void DetectFlowbitsRegister (void)
{
sigmatch_table[DETECT_FLOWBITS].Match = DetectFlowbitMatch;
sigmatch_table[DETECT_FLOWBITS].Setup = DetectFlowbitSetup;
sigmatch_table[DETECT_FLOWBITS].Free = DetectFlowbitFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FLOWBITS].RegisterTests = FlowBitsRegisterTests;
+#endif
/* this is compatible to ip-only signatures */
sigmatch_table[DETECT_FLOWBITS].flags |= SIGMATCH_IPONLY_COMPAT;
SCFree(p);
PASS;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for FlowBits
*/
void FlowBitsRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("FlowBitsTestParse01", FlowBitsTestParse01);
UtRegisterTest("FlowBitsTestSig01", FlowBitsTestSig01);
UtRegisterTest("FlowBitsTestSig02", FlowBitsTestSig02);
UtRegisterTest("FlowBitsTestSig09", FlowBitsTestSig09);
UtRegisterTest("FlowBitsTestSig10", FlowBitsTestSig10);
UtRegisterTest("FlowBitsTestSig11", FlowBitsTestSig11);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
const Signature *, const SigMatchCtx *);
static int DetectFlowintSetup(DetectEngineCtx *, Signature *, const char *);
void DetectFlowintFree(DetectEngineCtx *, void *);
-void DetectFlowintRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectFlowintRegisterTests(void);
+#endif
void DetectFlowintRegister(void)
{
sigmatch_table[DETECT_FLOWINT].Match = DetectFlowintMatch;
sigmatch_table[DETECT_FLOWINT].Setup = DetectFlowintSetup;
sigmatch_table[DETECT_FLOWINT].Free = DetectFlowintFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FLOWINT].RegisterTests = DetectFlowintRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectFlowint
*/
void DetectFlowintRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectFlowintTestParseVal01", DetectFlowintTestParseVal01);
UtRegisterTest("DetectFlowintTestParseVar01", DetectFlowintTestParseVar01);
UtRegisterTest("DetectFlowintTestParseVal02", DetectFlowintTestParseVal02);
DetectFlowintTestPacket02Real);
UtRegisterTest("DetectFlowintTestPacket03Real",
DetectFlowintTestPacket03Real);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
sigmatch_table[DETECT_FLOWVAR].Match = DetectFlowvarMatch;
sigmatch_table[DETECT_FLOWVAR].Setup = DetectFlowvarSetup;
sigmatch_table[DETECT_FLOWVAR].Free = DetectFlowvarDataFree;
- sigmatch_table[DETECT_FLOWVAR].RegisterTests = NULL;
/* post-match for flowvar storage */
sigmatch_table[DETECT_FLOWVAR_POSTMATCH].name = "__flowvar__postmatch__";
sigmatch_table[DETECT_FLOWVAR_POSTMATCH].Match = DetectFlowvarPostMatch;
sigmatch_table[DETECT_FLOWVAR_POSTMATCH].Setup = NULL;
sigmatch_table[DETECT_FLOWVAR_POSTMATCH].Free = DetectFlowvarDataFree;
- sigmatch_table[DETECT_FLOWVAR_POSTMATCH].RegisterTests = NULL;
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
static int PrefilterSetupFragBits(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
static bool PrefilterFragBitsIsPrefilterable(const Signature *s);
+#ifdef UNITTESTS
+static void FragBitsRegisterTests(void);
+#endif
/**
* \brief Registration function for fragbits: keyword
sigmatch_table[DETECT_FRAGBITS].Match = DetectFragBitsMatch;
sigmatch_table[DETECT_FRAGBITS].Setup = DetectFragBitsSetup;
sigmatch_table[DETECT_FRAGBITS].Free = DetectFragBitsFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FRAGBITS].RegisterTests = FragBitsRegisterTests;
-
+#endif
sigmatch_table[DETECT_FRAGBITS].SetupPrefilter = PrefilterSetupFragBits;
sigmatch_table[DETECT_FRAGBITS].SupportsPrefilter = PrefilterFragBitsIsPrefilterable;
SCFree(p);
PASS;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for FragBits
*/
-void FragBitsRegisterTests(void)
+static void FragBitsRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("FragBitsTestParse01", FragBitsTestParse01);
UtRegisterTest("FragBitsTestParse02", FragBitsTestParse02);
UtRegisterTest("FragBitsTestParse03", FragBitsTestParse03);
UtRegisterTest("FragBitsTestParse04", FragBitsTestParse04);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
void DetectFragBitsRegister (void);
-/**
- * This function registers unit tests for FragBits
- */
-
-void FragBitsRegisterTests(void);
-
#endif /*__DETECT_FRAGBITS_H__ */
static int DetectFragOffsetMatch(DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
static int DetectFragOffsetSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
void DetectFragOffsetRegisterTests(void);
+#endif
void DetectFragOffsetFree(DetectEngineCtx *, void *);
static int PrefilterSetupFragOffset(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
sigmatch_table[DETECT_FRAGOFFSET].Match = DetectFragOffsetMatch;
sigmatch_table[DETECT_FRAGOFFSET].Setup = DetectFragOffsetSetup;
sigmatch_table[DETECT_FRAGOFFSET].Free = DetectFragOffsetFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FRAGOFFSET].RegisterTests = DetectFragOffsetRegisterTests;
-
+#endif
sigmatch_table[DETECT_FRAGOFFSET].SupportsPrefilter = PrefilterFragOffsetIsPrefilterable;
sigmatch_table[DETECT_FRAGOFFSET].SetupPrefilter = PrefilterSetupFragOffset;
return result;
}
-#endif /* UNITTESTS */
void DetectFragOffsetRegisterTests (void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectFragOffsetParseTest01", DetectFragOffsetParseTest01);
UtRegisterTest("DetectFragOffsetParseTest02", DetectFragOffsetParseTest02);
UtRegisterTest("DetectFragOffsetParseTest03", DetectFragOffsetParseTest03);
UtRegisterTest("DetectFragOffsetMatchTest01", DetectFragOffsetMatchTest01);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
const Signature *, const SigMatchCtx *);
static int DetectFtpbounceSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectFtpbounceRegisterTests(void);
+#endif
static int g_ftp_request_list_id = 0;
static int InspectFtpRequest(ThreadVars *tv,
sigmatch_table[DETECT_FTPBOUNCE].desc = "detect FTP bounce attacks";
sigmatch_table[DETECT_FTPBOUNCE].Setup = DetectFtpbounceSetup;
sigmatch_table[DETECT_FTPBOUNCE].AppLayerTxMatch = DetectFtpbounceALMatch;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FTPBOUNCE].RegisterTests = DetectFtpbounceRegisterTests;
+#endif
sigmatch_table[DETECT_FTPBOUNCE].url = "/rules/ftp-keywords.html#ftpbounce";
sigmatch_table[DETECT_FTPBOUNCE].flags = SIGMATCH_NOOPT;
return result;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectFtpbounce
*/
-void DetectFtpbounceRegisterTests(void)
+static void DetectFtpbounceRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectFtpbounceTestSetup01", DetectFtpbounceTestSetup01);
UtRegisterTest("DetectFtpbounceTestALMatch02",
DetectFtpbounceTestALMatch02);
UtRegisterTest("DetectFtpbounceTestALMatch03",
DetectFtpbounceTestALMatch03);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
const Signature *, const SigMatchCtx *);
static int DetectFtpdataSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectFtpdataFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectFtpdataRegisterTests (void);
+#endif
static int DetectEngineInspectFtpdataGeneric(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd,
* shutdown, but also during rule reloads. */
sigmatch_table[DETECT_FTPDATA].Free = DetectFtpdataFree;
/* registers unittests into the system */
+#ifdef UNITTESTS
sigmatch_table[DETECT_FTPDATA].RegisterTests = DetectFtpdataRegisterTests;
-
+#endif
DetectAppLayerInspectEngineRegister("ftpdata_command",
ALPROTO_FTPDATA, SIG_FLAG_TOSERVER, 0,
DetectEngineInspectFtpdataGeneric);
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectFtpdata
*/
-void DetectFtpdataRegisterTests(void) {
-#ifdef UNITTESTS
+static void DetectFtpdataRegisterTests(void)
+{
UtRegisterTest("DetectFtpdataParseTest01", DetectFtpdataParseTest01);
UtRegisterTest("DetectFtpdataSignatureTest01",
DetectFtpdataSignatureTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
sigmatch_table[DETECT_GEOIP].url = "/rules/header-keywords.html#geoip";
sigmatch_table[DETECT_GEOIP].Setup = DetectGeoipSetupNoSupport;
sigmatch_table[DETECT_GEOIP].Free = NULL;
- sigmatch_table[DETECT_GEOIP].RegisterTests = NULL;
}
#else /* HAVE_GEOIP */
static int DetectGeoipMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectGeoipSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectGeoipRegisterTests(void);
+#endif
static void DetectGeoipDataFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_GEOIP].Match = DetectGeoipMatch;
sigmatch_table[DETECT_GEOIP].Setup = DetectGeoipSetup;
sigmatch_table[DETECT_GEOIP].Free = DetectGeoipDataFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_GEOIP].RegisterTests = DetectGeoipRegisterTests;
+#endif
}
/**
GEOIP_MATCH_BOTH_FLAG | GEOIP_MATCH_NEGATED);
}
-
-
-#endif /* UNITTESTS */
-
/**
* \internal
* \brief This function registers unit tests for DetectGeoip
*/
static void DetectGeoipRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("GeoipParseTest01", GeoipParseTest01);
UtRegisterTest("GeoipParseTest02", GeoipParseTest02);
UtRegisterTest("GeoipParseTest03", GeoipParseTest03);
UtRegisterTest("GeoipParseTest05", GeoipParseTest05);
UtRegisterTest("GeoipParseTest06", GeoipParseTest06);
UtRegisterTest("GeoipParseTest07", GeoipParseTest07);
-
-#endif /* UNITTESTS */
}
-
-#endif /* HAVE_GEOIP */
+#endif /* UNITTESTS */
+#endif /* HAVE_GEOIP */
\ No newline at end of file
#include "util-debug.h"
static int DetectGidSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
+static void GidRegisterTests(void);
+#endif
/**
* \brief Registration function for gid: keyword
sigmatch_table[DETECT_GID].Match = NULL;
sigmatch_table[DETECT_GID].Setup = DetectGidSetup;
sigmatch_table[DETECT_GID].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_GID].RegisterTests = GidRegisterTests;
+#endif
}
/**
DetectEngineCtxFree(de_ctx);
return result;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for Gid
*/
-void GidRegisterTests(void)
+static void GidRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("GidTestParse01", GidTestParse01);
UtRegisterTest("GidTestParse02", GidTestParse02);
UtRegisterTest("GidTestParse03", GidTestParse03);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
void DetectGidRegister (void);
-/**
- * This function registers unit tests for Gid
- */
-
-void GidRegisterTests(void);
-
-#endif /*__DETECT_GID_H__ */
+#endif /*__DETECT_GID_H__ */
\ No newline at end of file
const Signature *, const SigMatchCtx *);
static int DetectHostbitSetup (DetectEngineCtx *, Signature *, const char *);
void DetectHostbitFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
void HostBitsRegisterTests(void);
+#endif
void DetectHostbitsRegister (void)
{
sigmatch_table[DETECT_HOSTBITS].Match = DetectHostbitMatch;
sigmatch_table[DETECT_HOSTBITS].Setup = DetectHostbitSetup;
sigmatch_table[DETECT_HOSTBITS].Free = DetectHostbitFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_HOSTBITS].RegisterTests = HostBitsRegisterTests;
+#endif
/* this is compatible to ip-only signatures */
sigmatch_table[DETECT_HOSTBITS].flags |= SIGMATCH_IPONLY_COMPAT;
SCFree(p);
PASS;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for HostBits
*/
void HostBitsRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("HostBitsTestParse01", HostBitsTestParse01);
UtRegisterTest("HostBitsTestSig01", HostBitsTestSig01);
UtRegisterTest("HostBitsTestSig02", HostBitsTestSig02);
#endif
UtRegisterTest("HostBitsTestSig07", HostBitsTestSig07);
UtRegisterTest("HostBitsTestSig08", HostBitsTestSig08);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
#include "detect-http-request-line.h"
static int DetectHttpRequestLineSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectHttpRequestLineRegisterTests(void);
+#endif
static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx,
const DetectEngineTransforms *transforms,
Flow *_f, const uint8_t _flow_flags,
sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].url = "/rules/http-keywords.html#http-request-line";
sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].Match = NULL;
sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].Setup = DetectHttpRequestLineSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].RegisterTests = DetectHttpRequestLineRegisterTests;
-
+#endif
sigmatch_table[DETECT_AL_HTTP_REQUEST_LINE].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER;
DetectAppLayerInspectEngineRegister2("http_request_line",
PASS;
}
-#endif /* UNITTESTS */
-
static void DetectHttpRequestLineRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectHttpRequestLineTest01", DetectHttpRequestLineTest01);
UtRegisterTest("DetectHttpRequestLineTest02", DetectHttpRequestLineTest02);
UtRegisterTest("DetectHttpRequestLineTest03", DetectHttpRequestLineTest03);
-#endif /* UNITTESTS */
-
- return;
}
+#endif /* UNITTESTS */
/**
* @}
*/
#include "detect-http-response-line.h"
static int DetectHttpResponseLineSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectHttpResponseLineRegisterTests(void);
+#endif
static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx,
const DetectEngineTransforms *transforms,
Flow *_f, const uint8_t _flow_flags,
sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].desc = "content modifier to match only on the HTTP response line";
sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].url = "/rules/http-keywords.html#http-response-line";
sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].Setup = DetectHttpResponseLineSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].RegisterTests = DetectHttpResponseLineRegisterTests;
-
+#endif
sigmatch_table[DETECT_AL_HTTP_RESPONSE_LINE].flags |= SIGMATCH_NOOPT|SIGMATCH_INFO_STICKY_BUFFER;
DetectAppLayerInspectEngineRegister2("http_response_line",
PASS;
}
-#endif /* UNITTESTS */
-
void DetectHttpResponseLineRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectHttpResponseLineTest01", DetectHttpResponseLineTest01);
UtRegisterTest("DetectHttpResponseLineTest02", DetectHttpResponseLineTest02);
-#endif /* UNITTESTS */
-
- return;
}
+#endif /* UNITTESTS */
/**
* @}
*/
static int DetectIcmpIdMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectIcmpIdSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectIcmpIdRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectIcmpIdRegisterTests(void);
+#endif
void DetectIcmpIdFree(DetectEngineCtx *, void *);
static int PrefilterSetupIcmpId(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
static bool PrefilterIcmpIdIsPrefilterable(const Signature *s);
sigmatch_table[DETECT_ICMP_ID].Match = DetectIcmpIdMatch;
sigmatch_table[DETECT_ICMP_ID].Setup = DetectIcmpIdSetup;
sigmatch_table[DETECT_ICMP_ID].Free = DetectIcmpIdFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ICMP_ID].RegisterTests = DetectIcmpIdRegisterTests;
-
+#endif
sigmatch_table[DETECT_ICMP_ID].SupportsPrefilter = PrefilterIcmpIdIsPrefilterable;
sigmatch_table[DETECT_ICMP_ID].SetupPrefilter = PrefilterSetupIcmpId;
SCFree(p);
return result;
}
-#endif /* UNITTESTS */
-void DetectIcmpIdRegisterTests (void)
+static void DetectIcmpIdRegisterTests (void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectIcmpIdParseTest01", DetectIcmpIdParseTest01);
UtRegisterTest("DetectIcmpIdParseTest02", DetectIcmpIdParseTest02);
UtRegisterTest("DetectIcmpIdParseTest03", DetectIcmpIdParseTest03);
UtRegisterTest("DetectIcmpIdParseTest05", DetectIcmpIdParseTest05);
UtRegisterTest("DetectIcmpIdMatchTest01", DetectIcmpIdMatchTest01);
UtRegisterTest("DetectIcmpIdMatchTest02", DetectIcmpIdMatchTest02);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
static int DetectIcmpSeqMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectIcmpSeqSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectIcmpSeqRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectIcmpSeqRegisterTests(void);
+#endif
void DetectIcmpSeqFree(DetectEngineCtx *, void *);
static int PrefilterSetupIcmpSeq(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
static bool PrefilterIcmpSeqIsPrefilterable(const Signature *s);
sigmatch_table[DETECT_ICMP_SEQ].Match = DetectIcmpSeqMatch;
sigmatch_table[DETECT_ICMP_SEQ].Setup = DetectIcmpSeqSetup;
sigmatch_table[DETECT_ICMP_SEQ].Free = DetectIcmpSeqFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ICMP_SEQ].RegisterTests = DetectIcmpSeqRegisterTests;
-
+#endif
sigmatch_table[DETECT_ICMP_SEQ].SupportsPrefilter = PrefilterIcmpSeqIsPrefilterable;
sigmatch_table[DETECT_ICMP_SEQ].SetupPrefilter = PrefilterSetupIcmpSeq;
UTHFreePackets(&p, 1);
end:
return result;
-
}
-#endif /* UNITTESTS */
-void DetectIcmpSeqRegisterTests (void)
+static void DetectIcmpSeqRegisterTests (void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectIcmpSeqParseTest01", DetectIcmpSeqParseTest01);
UtRegisterTest("DetectIcmpSeqParseTest02", DetectIcmpSeqParseTest02);
UtRegisterTest("DetectIcmpSeqParseTest03", DetectIcmpSeqParseTest03);
UtRegisterTest("DetectIcmpSeqMatchTest01", DetectIcmpSeqMatchTest01);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectICodeMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectICodeSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectICodeRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectICodeRegisterTests(void);
+#endif
void DetectICodeFree(DetectEngineCtx *, void *);
static int PrefilterSetupICode(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
sigmatch_table[DETECT_ICODE].Match = DetectICodeMatch;
sigmatch_table[DETECT_ICODE].Setup = DetectICodeSetup;
sigmatch_table[DETECT_ICODE].Free = DetectICodeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ICODE].RegisterTests = DetectICodeRegisterTests;
-
+#endif
sigmatch_table[DETECT_ICODE].SupportsPrefilter = PrefilterICodeIsPrefilterable;
sigmatch_table[DETECT_ICODE].SetupPrefilter = PrefilterSetupICode;
return result;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectICode
*/
void DetectICodeRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectICodeParseTest01", DetectICodeParseTest01);
UtRegisterTest("DetectICodeParseTest02", DetectICodeParseTest02);
UtRegisterTest("DetectICodeParseTest03", DetectICodeParseTest03);
UtRegisterTest("DetectICodeParseTest07", DetectICodeParseTest07);
UtRegisterTest("DetectICodeParseTest08", DetectICodeParseTest08);
UtRegisterTest("DetectICodeMatchTest01", DetectICodeMatchTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectIdMatch (DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectIdSetup (DetectEngineCtx *, Signature *, const char *);
-void DetectIdRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectIdRegisterTests(void);
+#endif
void DetectIdFree(DetectEngineCtx *, void *);
static int PrefilterSetupId(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
sigmatch_table[DETECT_ID].Match = DetectIdMatch;
sigmatch_table[DETECT_ID].Setup = DetectIdSetup;
sigmatch_table[DETECT_ID].Free = DetectIdFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ID].RegisterTests = DetectIdRegisterTests;
-
+#endif
sigmatch_table[DETECT_ID].SupportsPrefilter = PrefilterIdIsPrefilterable;
sigmatch_table[DETECT_ID].SetupPrefilter = PrefilterSetupId;
end:
return result;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for DetectId
*/
void DetectIdRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectIdTestParse01", DetectIdTestParse01);
UtRegisterTest("DetectIdTestParse02", DetectIdTestParse02);
UtRegisterTest("DetectIdTestParse03", DetectIdTestParse03);
UtRegisterTest("DetectIdTestParse04", DetectIdTestParse04);
UtRegisterTest("DetectIdTestMatch01", DetectIdTestMatch01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectIpOptsMatch (DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectIpOptsSetup (DetectEngineCtx *, Signature *, const char *);
-void IpOptsRegisterTests(void);
+#ifdef UNITTESTS
+static void IpOptsRegisterTests(void);
+#endif
void DetectIpOptsFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_IPOPTS].Match = DetectIpOptsMatch;
sigmatch_table[DETECT_IPOPTS].Setup = DetectIpOptsSetup;
sigmatch_table[DETECT_IPOPTS].Free = DetectIpOptsFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_IPOPTS].RegisterTests = IpOptsRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
SCFree(p);
return 1;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for IpOpts
*/
void IpOptsRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("IpOptsTestParse01", IpOptsTestParse01);
UtRegisterTest("IpOptsTestParse02", IpOptsTestParse02);
UtRegisterTest("IpOptsTestParse03", IpOptsTestParse03);
UtRegisterTest("IpOptsTestParse04", IpOptsTestParse04);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static DetectParseRegex parse_regex;
static int DetectIPProtoSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectIPProtoRegisterTests(void);
+#endif
static void DetectIPProtoFree(DetectEngineCtx *, void *);
void DetectIPProtoRegister(void)
sigmatch_table[DETECT_IPPROTO].Match = NULL;
sigmatch_table[DETECT_IPPROTO].Setup = DetectIPProtoSetup;
sigmatch_table[DETECT_IPPROTO].Free = DetectIPProtoFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_IPPROTO].RegisterTests = DetectIPProtoRegisterTests;
+#endif
sigmatch_table[DETECT_IPPROTO].flags = SIGMATCH_QUOTES_OPTIONAL;
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
return result;
}
-#endif /* UNITTESTS */
-
/**
* \internal
* \brief Register ip_proto tests.
*/
static void DetectIPProtoRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectIPProtoTestParse01", DetectIPProtoTestParse01);
UtRegisterTest("DetectIPProtoTestParse02", DetectIPProtoTestParse02);
UtRegisterTest("DetectIPProtoTestSetup01", DetectIPProtoTestSetup01);
UtRegisterTest("DetectIPProtoTestSig1", DetectIPProtoTestSig1);
UtRegisterTest("DetectIPProtoTestSig2", DetectIPProtoTestSig2);
UtRegisterTest("DetectIPProtoTestSig3", DetectIPProtoTestSig3);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
const Signature *, const SigMatchCtx *);
static int DetectIPRepSetup (DetectEngineCtx *, Signature *, const char *);
void DetectIPRepFree (DetectEngineCtx *, void *);
-void IPRepRegisterTests(void);
+#ifdef UNITTESTS
+static void IPRepRegisterTests(void);
+#endif
void DetectIPRepRegister (void)
{
sigmatch_table[DETECT_IPREP].Match = DetectIPRepMatch;
sigmatch_table[DETECT_IPREP].Setup = DetectIPRepSetup;
sigmatch_table[DETECT_IPREP].Free = DetectIPRepFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_IPREP].RegisterTests = IPRepRegisterTests;
+#endif
/* this is compatible to ip-only signatures */
sigmatch_table[DETECT_IPREP].flags |= SIGMATCH_IPONLY_COMPAT;
HostShutdown();
return result;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for IPRep
*/
void IPRepRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectIPRepTest01", DetectIPRepTest01);
UtRegisterTest("DetectIPRepTest02", DetectIPRepTest02);
UtRegisterTest("DetectIPRepTest03", DetectIPRepTest03);
UtRegisterTest("DetectIPRepTest07", DetectIPRepTest07);
UtRegisterTest("DetectIPRepTest08", DetectIPRepTest08);
UtRegisterTest("DetectIPRepTest09", DetectIPRepTest09);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static DetectParseRegex parse_regex;
int DetectIsdataatSetup (DetectEngineCtx *, Signature *, const char *);
-void DetectIsdataatRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectIsdataatRegisterTests(void);
+#endif
void DetectIsdataatFree(DetectEngineCtx *, void *);
static int DetectEndsWithSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr);
sigmatch_table[DETECT_ISDATAAT].Match = NULL;
sigmatch_table[DETECT_ISDATAAT].Setup = DetectIsdataatSetup;
sigmatch_table[DETECT_ISDATAAT].Free = DetectIsdataatFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ISDATAAT].RegisterTests = DetectIsdataatRegisterTests;
-
+#endif
sigmatch_table[DETECT_ENDS_WITH].name = "endswith";
sigmatch_table[DETECT_ENDS_WITH].desc = "make sure the previous content matches exactly at the end of the buffer";
sigmatch_table[DETECT_ENDS_WITH].url = "/rules/payload-keywords.html#endswith";
end:
return result;
}
-#endif
/**
* \brief this function registers unit tests for DetectIsdataat
*/
void DetectIsdataatRegisterTests(void)
{
-#ifdef UNITTESTS
g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data");
UtRegisterTest("DetectIsdataatTestParse01", DetectIsdataatTestParse01);
UtRegisterTest("DetectIsdataatTestPacket01", DetectIsdataatTestPacket01);
UtRegisterTest("DetectIsdataatTestPacket02", DetectIsdataatTestPacket02);
UtRegisterTest("DetectIsdataatTestPacket03", DetectIsdataatTestPacket03);
-#endif
}
+#endif
\ No newline at end of file
static int DetectITypeMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectITypeSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectITypeRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectITypeRegisterTests(void);
+#endif
void DetectITypeFree(DetectEngineCtx *, void *);
static int PrefilterSetupIType(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
sigmatch_table[DETECT_ITYPE].Match = DetectITypeMatch;
sigmatch_table[DETECT_ITYPE].Setup = DetectITypeSetup;
sigmatch_table[DETECT_ITYPE].Free = DetectITypeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_ITYPE].RegisterTests = DetectITypeRegisterTests;
-
+#endif
sigmatch_table[DETECT_ITYPE].SupportsPrefilter = PrefilterITypeIsPrefilterable;
sigmatch_table[DETECT_ITYPE].SetupPrefilter = PrefilterSetupIType;
return result;
}
-
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectIType
*/
void DetectITypeRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectITypeParseTest01", DetectITypeParseTest01);
UtRegisterTest("DetectITypeParseTest02", DetectITypeParseTest02);
UtRegisterTest("DetectITypeParseTest03", DetectITypeParseTest03);
UtRegisterTest("DetectITypeParseTest07", DetectITypeParseTest07);
UtRegisterTest("DetectITypeParseTest08", DetectITypeParseTest08);
UtRegisterTest("DetectITypeMatchTest01", DetectITypeMatchTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
const SigMatchCtx *);
static int DetectKrb5ErrCodeSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectKrb5ErrCodeFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectKrb5ErrCodeRegisterTests (void);
+#endif
static int DetectEngineInspectKRB5Generic(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
*
* This function is called once in the 'lifetime' of the engine.
*/
-void DetectKrb5ErrCodeRegister(void) {
+void DetectKrb5ErrCodeRegister(void)
+{
sigmatch_table[DETECT_AL_KRB5_ERRCODE].name = "krb5_err_code";
sigmatch_table[DETECT_AL_KRB5_ERRCODE].desc = "match Kerberos 5 error code";
sigmatch_table[DETECT_AL_KRB5_ERRCODE].url = "/rules/kerberos-keywords.html#krb5-err-code";
sigmatch_table[DETECT_AL_KRB5_ERRCODE].AppLayerTxMatch = DetectKrb5ErrCodeMatch;
sigmatch_table[DETECT_AL_KRB5_ERRCODE].Setup = DetectKrb5ErrCodeSetup;
sigmatch_table[DETECT_AL_KRB5_ERRCODE].Free = DetectKrb5ErrCodeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_KRB5_ERRCODE].RegisterTests = DetectKrb5ErrCodeRegisterTests;
-
+#endif
DetectAppLayerInspectEngineRegister("krb5_err_code",
ALPROTO_KRB5, SIG_FLAG_TOSERVER, 0,
DetectEngineInspectKRB5Generic);
}
#ifdef UNITTESTS
-
/**
* \test description of the test
*/
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectKrb5ErrCode
*/
-static void DetectKrb5ErrCodeRegisterTests(void) {
-#ifdef UNITTESTS
+static void DetectKrb5ErrCodeRegisterTests(void)
+{
UtRegisterTest("DetectKrb5ErrCodeParseTest01", DetectKrb5ErrCodeParseTest01);
UtRegisterTest("DetectKrb5ErrCodeSignatureTest01",
DetectKrb5ErrCodeSignatureTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
const SigMatchCtx *);
static int DetectKrb5MsgTypeSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectKrb5MsgTypeFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectKrb5MsgTypeRegisterTests (void);
+#endif
static int DetectEngineInspectKRB5Generic(ThreadVars *tv,
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
*
* This function is called once in the 'lifetime' of the engine.
*/
-void DetectKrb5MsgTypeRegister(void) {
+void DetectKrb5MsgTypeRegister(void)
+{
sigmatch_table[DETECT_AL_KRB5_MSGTYPE].name = "krb5_msg_type";
sigmatch_table[DETECT_AL_KRB5_MSGTYPE].desc = "match Kerberos 5 message type";
sigmatch_table[DETECT_AL_KRB5_MSGTYPE].url = "/rules/kerberos-keywords.html#krb5-msg-type";
sigmatch_table[DETECT_AL_KRB5_MSGTYPE].AppLayerTxMatch = DetectKrb5MsgTypeMatch;
sigmatch_table[DETECT_AL_KRB5_MSGTYPE].Setup = DetectKrb5MsgTypeSetup;
sigmatch_table[DETECT_AL_KRB5_MSGTYPE].Free = DetectKrb5MsgTypeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_KRB5_MSGTYPE].RegisterTests = DetectKrb5MsgTypeRegisterTests;
-
+#endif
DetectAppLayerInspectEngineRegister("krb5_msg_type",
ALPROTO_KRB5, SIG_FLAG_TOSERVER, 0,
DetectEngineInspectKRB5Generic);
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectKrb5MsgType
*/
-static void DetectKrb5MsgTypeRegisterTests(void) {
-#ifdef UNITTESTS
+static void DetectKrb5MsgTypeRegisterTests(void)
+{
UtRegisterTest("DetectKrb5MsgTypeParseTest01", DetectKrb5MsgTypeParseTest01);
UtRegisterTest("DetectKrb5MsgTypeSignatureTest01",
DetectKrb5MsgTypeSignatureTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
#include "util-debug.h"
static int DetectL3ProtoSetup(DetectEngineCtx *, Signature *, const char *);
-
-void DetectL3protoRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectL3protoRegisterTests(void);
+#endif
void DetectL3ProtoRegister(void)
{
sigmatch_table[DETECT_L3PROTO].Match = NULL;
sigmatch_table[DETECT_L3PROTO].Setup = DetectL3ProtoSetup;
sigmatch_table[DETECT_L3PROTO].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_L3PROTO].RegisterTests = DetectL3protoRegisterTests;
-
- return;
+#endif
}
/**
* \internal
return result;
}
-
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectL3proto
*/
-void DetectL3protoRegisterTests(void)
+static void DetectL3protoRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectL3protoTestSig1", DetectL3protoTestSig1);
UtRegisterTest("DetectL3protoTestSig2", DetectL3protoTestSig2);
UtRegisterTest("DetectL3protoTestSig3", DetectL3protoTestSig3);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
sigmatch_table[DETECT_LUA].url = "/rules/rule-lua-scripting.html";
sigmatch_table[DETECT_LUA].Setup = DetectLuaSetupNoSupport;
sigmatch_table[DETECT_LUA].Free = NULL;
- sigmatch_table[DETECT_LUA].RegisterTests = NULL;
sigmatch_table[DETECT_LUA].flags = SIGMATCH_NOT_BUILT;
SCLogDebug("registering lua rule option");
void *state, void *txv, const Signature *s,
const SigMatchCtx *ctx);
static int DetectLuaSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectLuaRegisterTests(void);
+#endif
static void DetectLuaFree(DetectEngineCtx *, void *);
static int g_smtp_generic_list_id = 0;
sigmatch_table[DETECT_LUA].AppLayerTxMatch = DetectLuaAppTxMatch;
sigmatch_table[DETECT_LUA].Setup = DetectLuaSetup;
sigmatch_table[DETECT_LUA].Free = DetectLuaFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_LUA].RegisterTests = DetectLuaRegisterTests;
-
+#endif
g_smtp_generic_list_id = DetectBufferTypeRegister("smtp_generic");
DetectAppLayerInspectEngineRegister("smtp_generic",
return result;
}
-#endif
-
void DetectLuaRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("LuaMatchTest01", LuaMatchTest01);
UtRegisterTest("LuaMatchTest02", LuaMatchTest02);
UtRegisterTest("LuaMatchTest03", LuaMatchTest03);
UtRegisterTest("LuaMatchTest04", LuaMatchTest04);
UtRegisterTest("LuaMatchTest05", LuaMatchTest05);
UtRegisterTest("LuaMatchTest06", LuaMatchTest06);
-#endif
}
-
-#endif /* HAVE_LUAJIT */
+#endif
+#endif /* HAVE_LUAJIT */
\ No newline at end of file
static int DetectMarkPacket(DetectEngineThreadCtx *det_ctx, Packet *p,
const Signature *s, const SigMatchCtx *ctx);
void DetectMarkDataFree(DetectEngineCtx *, void *ptr);
+#if defined UNITTESTS && defined NFQ
+static void MarkRegisterTests(void);
+#endif
/**
* \brief Registration function for nfq_set_mark: keyword
sigmatch_table[DETECT_MARK].Match = DetectMarkPacket;
sigmatch_table[DETECT_MARK].Setup = DetectMarkSetup;
sigmatch_table[DETECT_MARK].Free = DetectMarkDataFree;
+#if defined UNITTESTS && defined NFQ
sigmatch_table[DETECT_MARK].RegisterTests = MarkRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
return 0;
}
-
-
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for Mark
*/
-void MarkRegisterTests(void)
+static void MarkRegisterTests(void)
{
-#if defined UNITTESTS && defined NFQ
UtRegisterTest("MarkTestParse01", MarkTestParse01);
UtRegisterTest("MarkTestParse02", MarkTestParse02);
UtRegisterTest("MarkTestParse03", MarkTestParse03);
UtRegisterTest("MarkTestParse04", MarkTestParse04);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
void DetectMarkRegister (void);
-/**
- * This function registers unit tests for Mark
- */
-
-void MarkRegisterTests(void);
-
#endif /*__DETECT_MARK_H__ */
#include "util-unittest.h"
static int DetectMetadataSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectMetadataRegisterTests(void);
+#endif
void DetectMetadataRegister (void)
{
sigmatch_table[DETECT_METADATA].Match = NULL;
sigmatch_table[DETECT_METADATA].Setup = DetectMetadataSetup;
sigmatch_table[DETECT_METADATA].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_METADATA].RegisterTests = DetectMetadataRegisterTests;
+#endif
}
/**
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectCipService
*/
static void DetectMetadataRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectMetadataParseTest01", DetectMetadataParseTest01);
UtRegisterTest("DetectMetadataParseTest02", DetectMetadataParseTest02);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
static int g_modbus_buffer_id = 0;
-
+#ifdef UNITTESTS
void DetectModbusRegisterTests(void);
+#endif
/** \internal
*
sigmatch_table[DETECT_AL_MODBUS].Match = NULL;
sigmatch_table[DETECT_AL_MODBUS].Setup = DetectModbusSetup;
sigmatch_table[DETECT_AL_MODBUS].Free = DetectModbusFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_MODBUS].RegisterTests = DetectModbusRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX_UNIT_ID, &unit_id_parse_regex);
DetectSetupParseRegexes(PARSE_REGEX_FUNCTION, &function_parse_regex);
DetectSetupParseRegexes(PARSE_REGEX_ACCESS, &access_parse_regex);
DetectEngineCtxFree(de_ctx);
PASS;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for DetectModbus
*/
void DetectModbusRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectModbusTest01 - Testing function",
DetectModbusTest01);
UtRegisterTest("DetectModbusTest02 - Testing function and subfunction",
DetectModbusTest12);
UtRegisterTest("DetectModbusTest13 - Testing a range of unit_id",
DetectModbusTest13);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
#include "detect-msg.h"
static int DetectMsgSetup (DetectEngineCtx *, Signature *, const char *);
-void DetectMsgRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectMsgRegisterTests(void);
+#endif
void DetectMsgRegister (void)
{
sigmatch_table[DETECT_MSG].Match = NULL;
sigmatch_table[DETECT_MSG].Setup = DetectMsgSetup;
sigmatch_table[DETECT_MSG].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_MSG].RegisterTests = DetectMsgRegisterTests;
+#endif
sigmatch_table[DETECT_MSG].flags = SIGMATCH_QUOTES_MANDATORY;
}
return result;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectMsg
*/
void DetectMsgRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectMsgParseTest01", DetectMsgParseTest01);
UtRegisterTest("DetectMsgParseTest02", DetectMsgParseTest02);
UtRegisterTest("DetectMsgParseTest03", DetectMsgParseTest03);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
static DetectNfsProcedureData *DetectNfsProcedureParse (const char *);
static int DetectNfsProcedureSetup (DetectEngineCtx *, Signature *s, const char *str);
static void DetectNfsProcedureFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectNfsProcedureRegisterTests(void);
+#endif
static int g_nfs_request_buffer_id = 0;
static int DetectEngineInspectNfsRequestGeneric(ThreadVars *tv,
sigmatch_table[DETECT_AL_NFS_PROCEDURE].AppLayerTxMatch = DetectNfsProcedureMatch;
sigmatch_table[DETECT_AL_NFS_PROCEDURE].Setup = DetectNfsProcedureSetup;
sigmatch_table[DETECT_AL_NFS_PROCEDURE].Free = DetectNfsProcedureFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_NFS_PROCEDURE].RegisterTests = DetectNfsProcedureRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief Register unit tests for nfs_procedure.
*/
void DetectNfsProcedureRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("ValidityTestParse01", ValidityTestParse01);
UtRegisterTest("ValidityTestParse02", ValidityTestParse02);
UtRegisterTest("ValidityTestParse03", ValidityTestParse03);
UtRegisterTest("ValidityTestParse13", ValidityTestParse13);
UtRegisterTest("ValidityTestParse14", ValidityTestParse14);
UtRegisterTest("ValidityTestParse15", ValidityTestParse15);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static DetectNfsVersionData *DetectNfsVersionParse (const char *);
static int DetectNfsVersionSetup (DetectEngineCtx *, Signature *s, const char *str);
static void DetectNfsVersionFree(DetectEngineCtx *de_ctx, void *);
+#ifdef UNITTESTS
static void DetectNfsVersionRegisterTests(void);
+#endif
static int g_nfs_request_buffer_id = 0;
static int DetectEngineInspectNfsRequestGeneric(ThreadVars *tv,
sigmatch_table[DETECT_AL_NFS_VERSION].AppLayerTxMatch = DetectNfsVersionMatch;
sigmatch_table[DETECT_AL_NFS_VERSION].Setup = DetectNfsVersionSetup;
sigmatch_table[DETECT_AL_NFS_VERSION].Free = DetectNfsVersionFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_NFS_VERSION].RegisterTests = DetectNfsVersionRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
DetectAppLayerInspectEngineRegister("nfs_request",
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief Register unit tests for nfs_procedure.
*/
void DetectNfsVersionRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("ValidityTestParse01", ValidityTestParse01);
UtRegisterTest("ValidityTestParse02", ValidityTestParse02);
UtRegisterTest("ValidityTestParse03", ValidityTestParse03);
UtRegisterTest("ValidityTestParse13", ValidityTestParse13);
UtRegisterTest("ValidityTestParse14", ValidityTestParse14);
UtRegisterTest("ValidityTestParse15", ValidityTestParse15);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
sigmatch_table[DETECT_NOALERT].name = "noalert";
sigmatch_table[DETECT_NOALERT].desc = "no alert will be generated by the rule";
sigmatch_table[DETECT_NOALERT].url = "/rules/flow-keywords.html";
- sigmatch_table[DETECT_NOALERT].Match = NULL;
sigmatch_table[DETECT_NOALERT].Setup = DetectNoalertSetup;
- sigmatch_table[DETECT_NOALERT].Free = NULL;
- sigmatch_table[DETECT_NOALERT].RegisterTests = NULL;
-
sigmatch_table[DETECT_NOALERT].flags |= SIGMATCH_NOOPT;
}
sigmatch_table[DETECT_NOCASE].name = "nocase";
sigmatch_table[DETECT_NOCASE].desc = "modify content match to be case insensitive";
sigmatch_table[DETECT_NOCASE].url = "/rules/payload-keywords.html#nocase";
- sigmatch_table[DETECT_NOCASE].Match = NULL;
sigmatch_table[DETECT_NOCASE].Setup = DetectNocaseSetup;
- sigmatch_table[DETECT_NOCASE].Free = NULL;
- sigmatch_table[DETECT_NOCASE].RegisterTests = NULL;
-
sigmatch_table[DETECT_NOCASE].flags |= SIGMATCH_NOOPT;
}
sigmatch_table[DETECT_OFFSET].name = "offset";
sigmatch_table[DETECT_OFFSET].desc = "designate from which byte in the payload will be checked to find a match";
sigmatch_table[DETECT_OFFSET].url = "/rules/payload-keywords.html#offset";
- sigmatch_table[DETECT_OFFSET].Match = NULL;
sigmatch_table[DETECT_OFFSET].Setup = DetectOffsetSetup;
- sigmatch_table[DETECT_OFFSET].Free = NULL;
- sigmatch_table[DETECT_OFFSET].RegisterTests = NULL;
}
int DetectOffsetSetup (DetectEngineCtx *de_ctx, Signature *s, const char *offsetstr)
static int DetectPcreSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectPcreFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
static void DetectPcreRegisterTests(void);
+#endif
void DetectPcreRegister (void)
{
sigmatch_table[DETECT_PCRE].Match = NULL;
sigmatch_table[DETECT_PCRE].Setup = DetectPcreSetup;
sigmatch_table[DETECT_PCRE].Free = DetectPcreFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_PCRE].RegisterTests = DetectPcreRegisterTests;
+#endif
sigmatch_table[DETECT_PCRE].flags = (SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION);
intmax_t val = 0;
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectPcre
*/
static void DetectPcreRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
g_http_header_buffer_id = DetectBufferTypeGetByName("http_header");
g_dce_stub_data_buffer_id = DetectBufferTypeGetByName("dce_stub_data");
UtRegisterTest("DetectPcreParseHttpHost", DetectPcreParseHttpHost);
UtRegisterTest("DetectPcreParseCaptureTest", DetectPcreParseCaptureTest);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
#include "util-unittest-helper.h"
static int DetectPktDataSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectPktDataTestRegister(void);
+#endif
/**
* \brief Registration function for keyword: file_data
{
sigmatch_table[DETECT_PKT_DATA].name = "pkt_data";
sigmatch_table[DETECT_PKT_DATA].Setup = DetectPktDataSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_PKT_DATA].RegisterTests = DetectPktDataTestRegister;
+#endif
sigmatch_table[DETECT_PKT_DATA].flags = SIGMATCH_NOOPT;
}
DetectEngineCtxFree(de_ctx);
PASS;
}
-#endif
static void DetectPktDataTestRegister(void)
{
-#ifdef UNITTESTS
g_file_data_buffer_id = DetectBufferTypeGetByName("file_data");
-
UtRegisterTest("DetectPktDataTest01", DetectPktDataTest01);
UtRegisterTest("DetectPktDataTest02", DetectPktDataTest02);
-#endif
}
-
+#endif
\ No newline at end of file
sigmatch_table[DETECT_PKTVAR].Match = DetectPktvarMatch;
sigmatch_table[DETECT_PKTVAR].Setup = DetectPktvarSetup;
sigmatch_table[DETECT_PKTVAR].Free = DetectPktvarFree;
- sigmatch_table[DETECT_PKTVAR].RegisterTests = NULL;
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
sigmatch_table[DETECT_PREFILTER].name = "prefilter";
sigmatch_table[DETECT_PREFILTER].desc = "force a condition to be used as prefilter";
sigmatch_table[DETECT_PREFILTER].url = "/rules/prefilter-keywords.html#prefilter";
- sigmatch_table[DETECT_PREFILTER].Match = NULL;
sigmatch_table[DETECT_PREFILTER].Setup = DetectPrefilterSetup;
- sigmatch_table[DETECT_PREFILTER].Free = NULL;
- sigmatch_table[DETECT_PREFILTER].RegisterTests = NULL;
-
sigmatch_table[DETECT_PREFILTER].flags |= SIGMATCH_NOOPT;
}
static DetectParseRegex parse_regex;
static int DetectPrioritySetup (DetectEngineCtx *, Signature *, const char *);
-void SCPriorityRegisterTests(void);
+#ifdef UNITTESTS
+static void PriorityRegisterTests(void);
+#endif
/**
* \brief Registers the handler functions for the "priority" keyword
sigmatch_table[DETECT_PRIORITY].desc = "rules with a higher priority will be examined first";
sigmatch_table[DETECT_PRIORITY].url = "/rules/meta.html#priority";
sigmatch_table[DETECT_PRIORITY].Setup = DetectPrioritySetup;
- sigmatch_table[DETECT_PRIORITY].RegisterTests = SCPriorityRegisterTests;
-
+#ifdef UNITTESTS
+ sigmatch_table[DETECT_PRIORITY].RegisterTests = PriorityRegisterTests;
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
DetectEngineCtxFree(de_ctx);
PASS;
}
-#endif /* UNITTESTS */
/**
* \brief This function registers unit tests for Classification Config API.
*/
-void SCPriorityRegisterTests(void)
+static void PriorityRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectPriorityTest01", DetectPriorityTest01);
UtRegisterTest("DetectPriorityTest02", DetectPriorityTest02);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
#include "util-profiling.h"
static int DetectReplaceSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectReplaceRegisterTests(void);
-
+#ifdef UNITTESTS
+static void DetectReplaceRegisterTests(void);
+#endif
static int DetectReplacePostMatch(DetectEngineThreadCtx *det_ctx,
Packet *p, const Signature *s, const SigMatchCtx *ctx);
sigmatch_table[DETECT_REPLACE].url = "/rules/payload-keywords.html#replace";
sigmatch_table[DETECT_REPLACE].Match = DetectReplacePostMatch;
sigmatch_table[DETECT_REPLACE].Setup = DetectReplaceSetup;
- sigmatch_table[DETECT_REPLACE].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_REPLACE].RegisterTests = DetectReplaceRegisterTests;
+#endif
sigmatch_table[DETECT_REPLACE].flags = (SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION);
}
return result;
}
-
-
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectContent
*/
void DetectReplaceRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
/* matching */
UtRegisterTest("DetectReplaceMatchTest01", DetectReplaceMatchTest01);
UtRegisterTest("DetectReplaceMatchTest02", DetectReplaceMatchTest02);
UtRegisterTest("DetectReplaceParseTest05", DetectReplaceParseTest05);
UtRegisterTest("DetectReplaceParseTest06", DetectReplaceParseTest06);
UtRegisterTest("DetectReplaceParseTest07", DetectReplaceParseTest07);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
sigmatch_table[DETECT_REV].name = "rev";
sigmatch_table[DETECT_REV].desc = "set version of the rule";
sigmatch_table[DETECT_REV].url = "/rules/meta.html#rev-revision";
- sigmatch_table[DETECT_REV].Match = NULL;
sigmatch_table[DETECT_REV].Setup = DetectRevSetup;
- sigmatch_table[DETECT_REV].Free = NULL;
- sigmatch_table[DETECT_REV].RegisterTests = NULL;
}
static int DetectRevSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
error:
return -1;
-}
-
+}
\ No newline at end of file
void *txv, const Signature *s,
const SigMatchCtx *ctx);
static int DetectRfbSecresultSetup (DetectEngineCtx *, Signature *, const char *);
-void RfbSecresultRegisterTests(void);
+#ifdef UNITTESTS
+static void RfbSecresultRegisterTests(void);
+#endif
void DetectRfbSecresultFree(DetectEngineCtx *, void *);
static int DetectEngineInspectRfbSecresultGeneric(ThreadVars *tv,
sigmatch_table[DETECT_AL_RFB_SECRESULT].AppLayerTxMatch = DetectRfbSecresultMatch;
sigmatch_table[DETECT_AL_RFB_SECRESULT].Setup = DetectRfbSecresultSetup;
sigmatch_table[DETECT_AL_RFB_SECRESULT].Free = DetectRfbSecresultFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_RFB_SECRESULT].RegisterTests = RfbSecresultRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
DetectAppLayerInspectEngineRegister("rfb.secresult",
return 1;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for RfbSecresult
*/
void RfbSecresultRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("RfbSecresultTestParse01", RfbSecresultTestParse01);
UtRegisterTest("RfbSecresultTestParse02", RfbSecresultTestParse02);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectRpcMatch (DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectRpcSetup (DetectEngineCtx *, Signature *, const char *);
-void DetectRpcRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectRpcRegisterTests(void);
+#endif
void DetectRpcFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_RPC].Match = DetectRpcMatch;
sigmatch_table[DETECT_RPC].Setup = DetectRpcSetup;
sigmatch_table[DETECT_RPC].Free = DetectRpcFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_RPC].RegisterTests = DetectRpcRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
end:
return result;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for DetectRpc
*/
-void DetectRpcRegisterTests(void)
+static void DetectRpcRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectRpcTestParse01", DetectRpcTestParse01);
UtRegisterTest("DetectRpcTestParse02", DetectRpcTestParse02);
UtRegisterTest("DetectRpcTestParse03", DetectRpcTestParse03);
UtRegisterTest("DetectRpcTestParse04", DetectRpcTestParse04);
UtRegisterTest("DetectRpcTestParse05", DetectRpcTestParse05);
UtRegisterTest("DetectRpcTestSig01", DetectRpcTestSig01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectSameipMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectSameipSetup(DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectSameipRegisterTests(void);
+#endif
/**
* \brief Registration function for sameip: keyword
sigmatch_table[DETECT_SAMEIP].url = "/rules/header-keywords.html#sameip";
sigmatch_table[DETECT_SAMEIP].Match = DetectSameipMatch;
sigmatch_table[DETECT_SAMEIP].Setup = DetectSameipSetup;
- sigmatch_table[DETECT_SAMEIP].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_SAMEIP].RegisterTests = DetectSameipRegisterTests;
+#endif
sigmatch_table[DETECT_SAMEIP].flags = SIGMATCH_NOOPT;
}
return result;
}
-#endif /* UNITTESTS */
-
/**
* \internal
* \brief This function registers unit tests for DetectSameip
*/
static void DetectSameipRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectSameipSigTest01", DetectSameipSigTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
#include "util-unittest.h"
static int DetectSidSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectSidRegisterTests(void);
+#endif
void DetectSidRegister (void)
{
sigmatch_table[DETECT_SID].url = "/rules/meta.html#sid-signature-id";
sigmatch_table[DETECT_SID].Match = NULL;
sigmatch_table[DETECT_SID].Setup = DetectSidSetup;
- sigmatch_table[DETECT_SID].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_SID].RegisterTests = DetectSidRegisterTests;
+#endif
}
static int DetectSidSetup (DetectEngineCtx *de_ctx, Signature *s, const char *sidstr)
return result;
}
-#endif
-
/**
* \brief Register DetectSid unit tests.
*/
static void DetectSidRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("SidTestParse01", SidTestParse01);
UtRegisterTest("SidTestParse02", SidTestParse02);
UtRegisterTest("SidTestParse03", SidTestParse03);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].name = KEYWORD_NAME;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].alias = KEYWORD_ALIAS;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].desc = BUFFER_NAME " sticky buffer";
- sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].RegisterTests = NULL;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].url = "/rules/" KEYWORD_DOC;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].Setup = DetectSshHasshServerStringSetup;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER_STRING].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].name = KEYWORD_NAME;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].alias = KEYWORD_ALIAS;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].desc = BUFFER_NAME " sticky buffer";
- sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].RegisterTests = NULL;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].url = "/rules/" KEYWORD_DOC;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].Setup = DetectSshHasshServerSetup;
sigmatch_table[DETECT_AL_SSH_HASSH_SERVER].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT;
sigmatch_table[DETECT_AL_SSH_HASSH_STRING].name = KEYWORD_NAME;
sigmatch_table[DETECT_AL_SSH_HASSH_STRING].alias = KEYWORD_ALIAS;
sigmatch_table[DETECT_AL_SSH_HASSH_STRING].desc = BUFFER_NAME " sticky buffer";
- sigmatch_table[DETECT_AL_SSH_HASSH_STRING].RegisterTests = NULL;
sigmatch_table[DETECT_AL_SSH_HASSH_STRING].url = "/rules/" KEYWORD_DOC;
sigmatch_table[DETECT_AL_SSH_HASSH_STRING].Setup = DetectSshHasshStringSetup;
sigmatch_table[DETECT_AL_SSH_HASSH_STRING].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT;
sigmatch_table[DETECT_AL_SSH_HASSH].name = KEYWORD_NAME;
sigmatch_table[DETECT_AL_SSH_HASSH].alias = KEYWORD_ALIAS;
sigmatch_table[DETECT_AL_SSH_HASSH].desc = BUFFER_NAME " sticky buffer";
- sigmatch_table[DETECT_AL_SSH_HASSH].RegisterTests = NULL;
sigmatch_table[DETECT_AL_SSH_HASSH].url = "/rules/" KEYWORD_DOC;
sigmatch_table[DETECT_AL_SSH_HASSH].Setup = DetectSshHasshSetup;
sigmatch_table[DETECT_AL_SSH_HASSH].flags |= SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_NOOPT;
Flow *, uint8_t, void *, void *,
const Signature *, const SigMatchCtx *);
static int DetectSshVersionSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectSshVersionRegisterTests(void);
+#endif
static void DetectSshVersionFree(DetectEngineCtx *, void *);
static int g_ssh_banner_list_id = 0;
sigmatch_table[DETECT_AL_SSH_PROTOVERSION].AppLayerTxMatch = DetectSshVersionMatch;
sigmatch_table[DETECT_AL_SSH_PROTOVERSION].Setup = DetectSshVersionSetup;
sigmatch_table[DETECT_AL_SSH_PROTOVERSION].Free = DetectSshVersionFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_SSH_PROTOVERSION].RegisterTests = DetectSshVersionRegisterTests;
+#endif
sigmatch_table[DETECT_AL_SSH_PROTOVERSION].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_INFO_DEPRECATED;
sigmatch_table[DETECT_AL_SSH_PROTOVERSION].alternative = DETECT_AL_SSH_PROTOCOL;
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectSshVersion
*/
-void DetectSshVersionRegisterTests(void)
+static void DetectSshVersionRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectSshVersionTestParse01", DetectSshVersionTestParse01);
UtRegisterTest("DetectSshVersionTestParse02", DetectSshVersionTestParse02);
UtRegisterTest("DetectSshVersionTestParse03", DetectSshVersionTestParse03);
DetectSshVersionTestDetect02);
UtRegisterTest("DetectSshVersionTestDetect03",
DetectSshVersionTestDetect03);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
Flow *, uint8_t, void *, void *,
const Signature *, const SigMatchCtx *);
static int DetectSshSoftwareVersionSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectSshSoftwareVersionRegisterTests(void);
+#endif
static void DetectSshSoftwareVersionFree(DetectEngineCtx *de_ctx, void *);
static int g_ssh_banner_list_id = 0;
sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].AppLayerTxMatch = DetectSshSoftwareVersionMatch;
sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].Setup = DetectSshSoftwareVersionSetup;
sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].Free = DetectSshSoftwareVersionFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].RegisterTests = DetectSshSoftwareVersionRegisterTests;
+#endif
sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].flags = SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_INFO_DEPRECATED;
sigmatch_table[DETECT_AL_SSH_SOFTWAREVERSION].alternative = DETECT_AL_SSH_SOFTWARE;
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectSshSoftwareVersion
*/
static void DetectSshSoftwareVersionRegisterTests(void)
{
-#ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectSshSoftwareVersionTestParse01",
DetectSshSoftwareVersionTestParse01);
UtRegisterTest("DetectSshSoftwareVersionTestParse02",
DetectSshSoftwareVersionTestDetect02);
UtRegisterTest("DetectSshSoftwareVersionTestDetect03",
DetectSshSoftwareVersionTestDetect03);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
const Signature *, const SigMatchCtx *);
static int DetectStreamSizeSetup (DetectEngineCtx *, Signature *, const char *);
void DetectStreamSizeFree(DetectEngineCtx *de_ctx, void *);
-void DetectStreamSizeRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectStreamSizeRegisterTests(void);
+#endif
/**
* \brief Registration function for stream_size: keyword
sigmatch_table[DETECT_STREAM_SIZE].Match = DetectStreamSizeMatch;
sigmatch_table[DETECT_STREAM_SIZE].Setup = DetectStreamSizeSetup;
sigmatch_table[DETECT_STREAM_SIZE].Free = DetectStreamSizeFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_STREAM_SIZE].RegisterTests = DetectStreamSizeRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
SCFree(p);
return result;
}
-#endif /* UNITTESTS */
/**
* \brief this function registers unit tests for DetectStreamSize
*/
void DetectStreamSizeRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectStreamSizeParseTest01", DetectStreamSizeParseTest01);
UtRegisterTest("DetectStreamSizeParseTest02", DetectStreamSizeParseTest02);
UtRegisterTest("DetectStreamSizeParseTest03", DetectStreamSizeParseTest03);
UtRegisterTest("DetectStreamSizeParseTest04", DetectStreamSizeParseTest04);
-#endif /* UNITTESTS */
}
-
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectTagMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectTagSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectTagRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectTagRegisterTests(void);
+#endif
void DetectTagDataFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_TAG].Match = DetectTagMatch;
sigmatch_table[DETECT_TAG].Setup = DetectTagSetup;
sigmatch_table[DETECT_TAG].Free = DetectTagDataFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TAG].RegisterTests = DetectTagRegisterTests;
+#endif
sigmatch_table[DETECT_TAG].flags |= SIGMATCH_IPONLY_COMPAT;
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
return result;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectTag
*/
void DetectTagRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTagTestParse01", DetectTagTestParse01);
UtRegisterTest("DetectTagTestParse02", DetectTagTestParse02);
UtRegisterTest("DetectTagTestParse03", DetectTagTestParse03);
UtRegisterTest("DetectTagTestParse05", DetectTagTestParse05);
DetectEngineTagRegisterTests();
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
/* Prototypes of functions registered in DetectTargetRegister below */
static int DetectTargetSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectTargetRegisterTests (void);
+#endif
/**
* \brief Registration function for target keyword
* shutdown, but also during rule reloads. */
sigmatch_table[DETECT_TARGET].Free = NULL;
/* registers unittests into the system */
+#ifdef UNITTESTS
sigmatch_table[DETECT_TARGET].RegisterTests = DetectTargetRegisterTests;
-
+#endif
/* set up the PCRE for keyword parsing */
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectTarget
*/
-void DetectTargetRegisterTests(void) {
-#ifdef UNITTESTS
+static void DetectTargetRegisterTests(void)
+{
UtRegisterTest("DetectTargetSignatureTest01",
DetectTargetSignatureTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectAckSetup(DetectEngineCtx *, Signature *, const char *);
static int DetectAckMatch(DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
+#ifdef UNITTESTS
static void DetectAckRegisterTests(void);
+#endif
static void DetectAckFree(DetectEngineCtx *, void *);
static int PrefilterSetupTcpAck(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
static bool PrefilterTcpAckIsPrefilterable(const Signature *s);
sigmatch_table[DETECT_ACK].SupportsPrefilter = PrefilterTcpAckIsPrefilterable;
sigmatch_table[DETECT_ACK].SetupPrefilter = PrefilterSetupTcpAck;
-
+#ifdef UNITTESTS
sigmatch_table[DETECT_ACK].RegisterTests = DetectAckRegisterTests;
+#endif
}
/**
return result;
}
-#endif /* UNITTESTS */
-
/**
* \internal
* \brief This function registers unit tests for DetectAck
*/
static void DetectAckRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectAckSigTest01", DetectAckSigTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static bool PrefilterTcpFlagsIsPrefilterable(const Signature *s);
static int PrefilterSetupTcpFlags(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
+#ifdef UNITTESTS
+static void FlagsRegisterTests(void);
+#endif
/**
* \brief Registration function for flags: keyword
sigmatch_table[DETECT_FLAGS].Match = DetectFlagsMatch;
sigmatch_table[DETECT_FLAGS].Setup = DetectFlagsSetup;
sigmatch_table[DETECT_FLAGS].Free = DetectFlagsFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_FLAGS].RegisterTests = FlagsRegisterTests;
-
+#endif
sigmatch_table[DETECT_FLAGS].SupportsPrefilter = PrefilterTcpFlagsIsPrefilterable;
sigmatch_table[DETECT_FLAGS].SetupPrefilter = PrefilterSetupTcpFlags;
return 0;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for Flags
*/
-void FlagsRegisterTests(void)
+static void FlagsRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("FlagsTestParse01", FlagsTestParse01);
UtRegisterTest("FlagsTestParse02", FlagsTestParse02);
UtRegisterTest("FlagsTestParse03", FlagsTestParse03);
UtRegisterTest("FlagsTestParse15", FlagsTestParse15);
UtRegisterTest("FlagsTestParse16", FlagsTestParse16);
UtRegisterTest("FlagsTestParse17", FlagsTestParse17);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
void DetectFlagsRegister (void);
-/**
- * This function registers unit tests for Flags
- */
-
-void FlagsRegisterTests(void);
-
int DetectFlagsSignatureNeedsSynPackets(const Signature *s);
int DetectFlagsSignatureNeedsSynOnlyPackets(const Signature *s);
static int DetectSeqSetup(DetectEngineCtx *, Signature *, const char *);
static int DetectSeqMatch(DetectEngineThreadCtx *,
Packet *, const Signature *, const SigMatchCtx *);
+#ifdef UNITTESTS
static void DetectSeqRegisterTests(void);
+#endif
static void DetectSeqFree(DetectEngineCtx *, void *);
static int PrefilterSetupTcpSeq(DetectEngineCtx *de_ctx, SigGroupHead *sgh);
static bool PrefilterTcpSeqIsPrefilterable(const Signature *s);
sigmatch_table[DETECT_SEQ].Match = DetectSeqMatch;
sigmatch_table[DETECT_SEQ].Setup = DetectSeqSetup;
sigmatch_table[DETECT_SEQ].Free = DetectSeqFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_SEQ].RegisterTests = DetectSeqRegisterTests;
-
+#endif
sigmatch_table[DETECT_SEQ].SupportsPrefilter = PrefilterTcpSeqIsPrefilterable;
sigmatch_table[DETECT_SEQ].SetupPrefilter = PrefilterSetupTcpSeq;
}
return result;
}
-#endif /* UNITTESTS */
-
/**
* \internal
* \brief This function registers unit tests for DetectSeq
*/
static void DetectSeqRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectSeqSigTest01", DetectSeqSigTest01);
UtRegisterTest("DetectSeqSigTest02", DetectSeqSigTest02);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectWindowMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
static int DetectWindowSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectWindowRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectWindowRegisterTests(void);
+#endif
void DetectWindowFree(DetectEngineCtx *, void *);
/**
sigmatch_table[DETECT_WINDOW].Match = DetectWindowMatch;
sigmatch_table[DETECT_WINDOW].Setup = DetectWindowSetup;
sigmatch_table[DETECT_WINDOW].Free = DetectWindowFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_WINDOW].RegisterTests = DetectWindowRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
}
return result;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectWindow
*/
void DetectWindowRegisterTests(void)
{
- #ifdef UNITTESTS /* UNITTESTS */
UtRegisterTest("DetectWindowTestParse01", DetectWindowTestParse01);
UtRegisterTest("DetectWindowTestParse02", DetectWindowTestParse02);
UtRegisterTest("DetectWindowTestParse03", DetectWindowTestParse03);
UtRegisterTest("DetectWindowTestParse04", DetectWindowTestParse04);
UtRegisterTest("DetectWindowTestPacket01", DetectWindowTestPacket01);
- #endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx,
const Signature *s, const SigMatchData *smd,
Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
+#ifdef UNITTESTS
static void DetectTemplateRustBufferRegisterTests(void);
+#endif
static int g_template_rust_id = 0;
void DetectTemplateRustBufferRegister(void)
"Template content modififier to match on the template buffers";
sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].Setup =
DetectTemplateRustBufferSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].RegisterTests =
DetectTemplateRustBufferRegisterTests;
-
+#endif
sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].flags |= SIGMATCH_NOOPT;
/* register inspect engines */
PASS;
}
-#endif
-
static void DetectTemplateRustBufferRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTemplateRustBufferTest",
DetectTemplateRustBufferTest);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
const Signature *, const SigMatchCtx *);
static int DetectThresholdSetup(DetectEngineCtx *, Signature *, const char *);
static void DetectThresholdFree(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
+static void ThresholdRegisterTests(void);
+#endif
/**
* \brief Registration function for threshold: keyword
sigmatch_table[DETECT_THRESHOLD].Match = DetectThresholdMatch;
sigmatch_table[DETECT_THRESHOLD].Setup = DetectThresholdSetup;
sigmatch_table[DETECT_THRESHOLD].Free = DetectThresholdFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_THRESHOLD].RegisterTests = ThresholdRegisterTests;
+#endif
/* this is compatible to ip-only signatures */
sigmatch_table[DETECT_THRESHOLD].flags |= SIGMATCH_IPONLY_COMPAT;
PASS;
}
-#endif /* UNITTESTS */
-
-void ThresholdRegisterTests(void)
+static void ThresholdRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("ThresholdTestParse01", ThresholdTestParse01);
UtRegisterTest("ThresholdTestParse02", ThresholdTestParse02);
UtRegisterTest("ThresholdTestParse03", ThresholdTestParse03);
UtRegisterTest("DetectThresholdTestSig12", DetectThresholdTestSig12);
UtRegisterTest("DetectThresholdTestSig13", DetectThresholdTestSig13);
UtRegisterTest("DetectThresholdTestSig14", DetectThresholdTestSig14);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
/**
* @}
void DetectThresholdRegister(void);
-/**
- * This function registers unit tests for Threshold
- */
-
-void ThresholdRegisterTests(void);
-
#endif /*__DETECT_THRESHOLD_H__ */
Flow *, uint8_t, void *, void *,
const Signature *, const SigMatchCtx *);
static int DetectTlsSubjectSetup (DetectEngineCtx *, Signature *, const char *);
-static void DetectTlsSubjectRegisterTests(void);
static void DetectTlsSubjectFree(DetectEngineCtx *, void *);
static int DetectTlsIssuerDNMatch (DetectEngineThreadCtx *,
Flow *, uint8_t, void *, void *,
const Signature *, const SigMatchCtx *);
static int DetectTlsIssuerDNSetup (DetectEngineCtx *, Signature *, const char *);
-static void DetectTlsIssuerDNRegisterTests(void);
static void DetectTlsIssuerDNFree(DetectEngineCtx *, void *);
static int DetectTlsFingerprintMatch (DetectEngineThreadCtx *,
sigmatch_table[DETECT_AL_TLS_SUBJECT].AppLayerTxMatch = DetectTlsSubjectMatch;
sigmatch_table[DETECT_AL_TLS_SUBJECT].Setup = DetectTlsSubjectSetup;
sigmatch_table[DETECT_AL_TLS_SUBJECT].Free = DetectTlsSubjectFree;
- sigmatch_table[DETECT_AL_TLS_SUBJECT].RegisterTests = DetectTlsSubjectRegisterTests;
sigmatch_table[DETECT_AL_TLS_SUBJECT].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION;
sigmatch_table[DETECT_AL_TLS_SUBJECT].alternative = DETECT_AL_TLS_CERT_SUBJECT;
sigmatch_table[DETECT_AL_TLS_ISSUERDN].AppLayerTxMatch = DetectTlsIssuerDNMatch;
sigmatch_table[DETECT_AL_TLS_ISSUERDN].Setup = DetectTlsIssuerDNSetup;
sigmatch_table[DETECT_AL_TLS_ISSUERDN].Free = DetectTlsIssuerDNFree;
- sigmatch_table[DETECT_AL_TLS_ISSUERDN].RegisterTests = DetectTlsIssuerDNRegisterTests;
sigmatch_table[DETECT_AL_TLS_ISSUERDN].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION;
sigmatch_table[DETECT_AL_TLS_ISSUERDN].alternative = DETECT_AL_TLS_CERT_ISSUER;
sigmatch_table[DETECT_AL_TLS_FINGERPRINT].AppLayerTxMatch = DetectTlsFingerprintMatch;
sigmatch_table[DETECT_AL_TLS_FINGERPRINT].Setup = DetectTlsFingerprintSetup;
sigmatch_table[DETECT_AL_TLS_FINGERPRINT].Free = DetectTlsFingerprintFree;
- sigmatch_table[DETECT_AL_TLS_FINGERPRINT].RegisterTests = NULL;
sigmatch_table[DETECT_AL_TLS_FINGERPRINT].flags = SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION;
sigmatch_table[DETECT_AL_TLS_FINGERPRINT].alternative = DETECT_AL_TLS_CERT_FINGERPRINT;
sigmatch_table[DETECT_AL_TLS_STORE].url = "/rules/tls-keywords.html#tls-store";
sigmatch_table[DETECT_AL_TLS_STORE].Match = DetectTlsStorePostMatch;
sigmatch_table[DETECT_AL_TLS_STORE].Setup = DetectTlsStoreSetup;
- sigmatch_table[DETECT_AL_TLS_STORE].Free = NULL;
- sigmatch_table[DETECT_AL_TLS_STORE].RegisterTests = NULL;
sigmatch_table[DETECT_AL_TLS_STORE].flags |= SIGMATCH_NOOPT;
DetectSetupParseRegexes(PARSE_REGEX, &subject_parse_regex);
SCFree(id_d);
}
-/**
- * \brief this function registers unit tests for DetectTlsSubject
- */
-static void DetectTlsSubjectRegisterTests(void)
-{
-}
-
/**
* \brief match the specified IssuerDN on a tls session
*
ssl_state->server_connp.cert_log_flag |= SSL_TLS_LOG_PEM;
SCReturnInt(1);
-}
-
-
-/**
- * \brief this function registers unit tests for DetectTlsIssuerDN
- */
-static void DetectTlsIssuerDNRegisterTests(void)
-{
-}
+}
\ No newline at end of file
static int DetectTosSetup(DetectEngineCtx *, Signature *, const char *);
static int DetectTosMatch(DetectEngineThreadCtx *, Packet *,
const Signature *, const SigMatchCtx *);
+#ifdef UNITTESTS
static void DetectTosRegisterTests(void);
+#endif
static void DetectTosFree(DetectEngineCtx *, void *);
#define DETECT_IPTOS_MIN 0
sigmatch_table[DETECT_TOS].Match = DetectTosMatch;
sigmatch_table[DETECT_TOS].Setup = DetectTosSetup;
sigmatch_table[DETECT_TOS].Free = DetectTosFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TOS].RegisterTests = DetectTosRegisterTests;
+#endif
sigmatch_table[DETECT_TOS].flags =
(SIGMATCH_QUOTES_OPTIONAL|SIGMATCH_HANDLE_NEGATION);
sigmatch_table[DETECT_TOS].url =
return result;
}
-#endif
-
void DetectTosRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTosTest01", DetectTosTest01);
UtRegisterTest("DetectTosTest02", DetectTosTest02);
UtRegisterTest("DetectTosTest04", DetectTosTest04);
UtRegisterTest("DetectTosTest09", DetectTosTest09);
UtRegisterTest("DetectTosTest10", DetectTosTest10);
UtRegisterTest("DetectTosTest12", DetectTosTest12);
-#endif
return;
}
+#endif
\ No newline at end of file
#include "util-print.h"
static int DetectTransformCompressWhitespaceSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectTransformCompressWhitespaceRegisterTests(void);
-
+#endif
static void TransformCompressWhitespace(InspectionBuffer *buffer, void *options);
void DetectTransformCompressWhitespaceRegister(void)
TransformCompressWhitespace;
sigmatch_table[DETECT_TRANSFORM_COMPRESS_WHITESPACE].Setup =
DetectTransformCompressWhitespaceSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TRANSFORM_COMPRESS_WHITESPACE].RegisterTests =
DetectTransformCompressWhitespaceRegisterTests;
-
+#endif
sigmatch_table[DETECT_TRANSFORM_COMPRESS_WHITESPACE].flags |= SIGMATCH_NOOPT;
}
PASS;
}
-#endif
-
static void DetectTransformCompressWhitespaceRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTransformCompressWhitespaceTest01",
DetectTransformCompressWhitespaceTest01);
UtRegisterTest("DetectTransformCompressWhitespaceTest02",
DetectTransformCompressWhitespaceTest02);
-#endif
}
+#endif
\ No newline at end of file
#include "util-memcpy.h"
static int DetectTransformDotPrefixSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectTransformDotPrefixRegisterTests(void);
-
+#endif
static void TransformDotPrefix(InspectionBuffer *buffer, void *options);
void DetectTransformDotPrefixRegister(void)
"/rules/transforms.html#dotprefix";
sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].Transform = TransformDotPrefix;
sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].Setup = DetectTransformDotPrefixSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].RegisterTests =
DetectTransformDotPrefixRegisterTests;
-
+#endif
sigmatch_table[DETECT_TRANSFORM_DOTPREFIX].flags |= SIGMATCH_NOOPT;
}
DetectEngineCtxFree(de_ctx);
PASS;
}
-#endif
static void DetectTransformDotPrefixRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTransformDotPrefixTest01", DetectTransformDotPrefixTest01);
UtRegisterTest("DetectTransformDotPrefixTest02", DetectTransformDotPrefixTest02);
UtRegisterTest("DetectTransformDotPrefixTest03", DetectTransformDotPrefixTest03);
-#endif
}
+#endif
\ No newline at end of file
static int DetectTransformToMd5Setup (DetectEngineCtx *, Signature *, const char *);
#ifdef HAVE_NSS
+#ifdef UNITTESTS
static void DetectTransformToMd5RegisterTests(void);
+#endif
static void TransformToMd5(InspectionBuffer *buffer, void *options);
#endif
#ifdef HAVE_NSS
sigmatch_table[DETECT_TRANSFORM_MD5].Transform =
TransformToMd5;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TRANSFORM_MD5].RegisterTests =
DetectTransformToMd5RegisterTests;
+#endif
#endif
sigmatch_table[DETECT_TRANSFORM_MD5].flags |= SIGMATCH_NOOPT;
}
PASS;
}
-#endif
-
static void DetectTransformToMd5RegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTransformToMd5Test01",
DetectTransformToMd5Test01);
-#endif
}
#endif
+#endif
\ No newline at end of file
static int DetectTransformToSha1Setup (DetectEngineCtx *, Signature *, const char *);
#ifdef HAVE_NSS
+#ifdef UNITTESTS
static void DetectTransformToSha1RegisterTests(void);
+#endif
static void TransformToSha1(InspectionBuffer *buffer, void *options);
#endif
#ifdef HAVE_NSS
sigmatch_table[DETECT_TRANSFORM_SHA1].Transform =
TransformToSha1;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TRANSFORM_SHA1].RegisterTests =
DetectTransformToSha1RegisterTests;
+#endif
#endif
sigmatch_table[DETECT_TRANSFORM_SHA1].flags |= SIGMATCH_NOOPT;
}
PASS;
}
-#endif
-
static void DetectTransformToSha1RegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTransformToSha1Test01",
DetectTransformToSha1Test01);
-#endif
}
#endif
+#endif
\ No newline at end of file
static int DetectTransformToSha256Setup (DetectEngineCtx *, Signature *, const char *);
#ifdef HAVE_NSS
+#ifdef UNITTESTS
static void DetectTransformToSha256RegisterTests(void);
+#endif
static void TransformToSha256(InspectionBuffer *buffer, void *options);
#endif
#ifdef HAVE_NSS
sigmatch_table[DETECT_TRANSFORM_SHA256].Transform =
TransformToSha256;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TRANSFORM_SHA256].RegisterTests =
DetectTransformToSha256RegisterTests;
+#endif
#endif
sigmatch_table[DETECT_TRANSFORM_SHA256].flags |= SIGMATCH_NOOPT;
}
PASS;
}
-#endif
-
static void DetectTransformToSha256RegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTransformToSha256Test01",
DetectTransformToSha256Test01);
-#endif
}
#endif
+#endif
\ No newline at end of file
#include "util-print.h"
static int DetectTransformStripWhitespaceSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectTransformStripWhitespaceRegisterTests(void);
-
+#endif
static void TransformStripWhitespace(InspectionBuffer *buffer, void *options);
static bool TransformStripWhitespaceValidate(const uint8_t *content, uint16_t content_len, void *options);
TransformStripWhitespaceValidate;
sigmatch_table[DETECT_TRANSFORM_STRIP_WHITESPACE].Setup =
DetectTransformStripWhitespaceSetup;
+#ifdef UNITTESTS
sigmatch_table[DETECT_TRANSFORM_STRIP_WHITESPACE].RegisterTests =
DetectTransformStripWhitespaceRegisterTests;
-
+#endif
sigmatch_table[DETECT_TRANSFORM_STRIP_WHITESPACE].flags |= SIGMATCH_NOOPT;
}
PASS;
}
-#endif
-
static void DetectTransformStripWhitespaceRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectTransformStripWhitespaceTest01",
DetectTransformStripWhitespaceTest01);
UtRegisterTest("DetectTransformStripWhitespaceTest02",
DetectTransformStripWhitespaceTest02);
UtRegisterTest("DetectTransformStripWhitespaceTest03",
DetectTransformStripWhitespaceTest03);
-#endif
}
+#endif
\ No newline at end of file
/* prototypes */
static int DetectUricontentSetup (DetectEngineCtx *, Signature *, const char *);
+#ifdef UNITTESTS
static void DetectUricontentRegisterTests(void);
+#endif
static void DetectUricontentFree(DetectEngineCtx *de_ctx, void *);
static int g_http_uri_buffer_id = 0;
sigmatch_table[DETECT_URICONTENT].Match = NULL;
sigmatch_table[DETECT_URICONTENT].Setup = DetectUricontentSetup;
sigmatch_table[DETECT_URICONTENT].Free = DetectUricontentFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_URICONTENT].RegisterTests = DetectUricontentRegisterTests;
+#endif
sigmatch_table[DETECT_URICONTENT].flags = (SIGMATCH_QUOTES_MANDATORY|SIGMATCH_HANDLE_NEGATION);
sigmatch_table[DETECT_URICONTENT].alternative = DETECT_HTTP_URI;
PASS;
}
-#endif /* UNITTESTS */
-
static void DetectUricontentRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("HTTPUriTest01", HTTPUriTest01);
UtRegisterTest("HTTPUriTest02", HTTPUriTest02);
UtRegisterTest("HTTPUriTest03", HTTPUriTest03);
UtRegisterTest("DetectUricontentIsdataatParseTest",
DetectUricontentIsdataatParseTest);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
/*prototypes*/
static int DetectUrilenSetup (DetectEngineCtx *, Signature *, const char *);
-void DetectUrilenFree (DetectEngineCtx *, void *);
-void DetectUrilenRegisterTests (void);
-
+static void DetectUrilenFree (DetectEngineCtx *, void *);
+#ifdef UNITTESTS
+static void DetectUrilenRegisterTests (void);
+#endif
static int g_http_uri_buffer_id = 0;
static int g_http_raw_uri_buffer_id = 0;
sigmatch_table[DETECT_AL_URILEN].Match = NULL;
sigmatch_table[DETECT_AL_URILEN].Setup = DetectUrilenSetup;
sigmatch_table[DETECT_AL_URILEN].Free = DetectUrilenFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_AL_URILEN].RegisterTests = DetectUrilenRegisterTests;
-
+#endif
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
g_http_uri_buffer_id = DetectBufferTypeRegister("http_uri");
static DetectUrilenData *DetectUrilenParse (const char *urilenstr)
{
-
DetectUrilenData *urilend = NULL;
char *arg1 = NULL;
char *arg2 = NULL;
*
* \param ptr pointer to DetectUrilenData
*/
-void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr)
+static void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr)
{
if (ptr == NULL)
return;
return result;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for DetectUrilen
*/
void DetectUrilenRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("DetectUrilenParseTest01", DetectUrilenParseTest01);
UtRegisterTest("DetectUrilenParseTest02", DetectUrilenParseTest02);
UtRegisterTest("DetectUrilenParseTest03", DetectUrilenParseTest03);
UtRegisterTest("DetectUrilenParseTest10", DetectUrilenParseTest10);
UtRegisterTest("DetectUrilenSetpTest01", DetectUrilenSetpTest01);
UtRegisterTest("DetectUrilenSigTest01", DetectUrilenSigTest01);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
#include "util-unittest.h"
static int DetectWithinSetup(DetectEngineCtx *, Signature *, const char *);
-void DetectWithinRegisterTests(void);
+#ifdef UNITTESTS
+static void DetectWithinRegisterTests(void);
+#endif
void DetectWithinRegister(void)
{
sigmatch_table[DETECT_WITHIN].url = "/rules/payload-keywords.html#within";
sigmatch_table[DETECT_WITHIN].Match = NULL;
sigmatch_table[DETECT_WITHIN].Setup = DetectWithinSetup;
- sigmatch_table[DETECT_WITHIN].Free = NULL;
+#ifdef UNITTESTS
sigmatch_table[DETECT_WITHIN].RegisterTests = DetectWithinRegisterTests;
+#endif
}
/** \brief Setup within pattern (content/uricontent) modifier.
PASS;
}
-#endif /* UNITTESTS */
-
void DetectWithinRegisterTests(void)
{
- #ifdef UNITTESTS
UtRegisterTest("DetectWithinTestPacket01", DetectWithinTestPacket01);
UtRegisterTest("DetectWithinTestPacket02", DetectWithinTestPacket02);
UtRegisterTest("DetectWithinTestVarSetup", DetectWithinTestVarSetup);
- #endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
static int DetectXbitMatch (DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *);
static int DetectXbitSetup (DetectEngineCtx *, Signature *, const char *);
-void DetectXbitFree (DetectEngineCtx *, void *);
-void XBitsRegisterTests(void);
+#ifdef UNITTESTS
+static void XBitsRegisterTests(void);
+#endif
+static void DetectXbitFree (DetectEngineCtx *, void *);
void DetectXbitsRegister (void)
{
sigmatch_table[DETECT_XBITS].Match = DetectXbitMatch;
sigmatch_table[DETECT_XBITS].Setup = DetectXbitSetup;
sigmatch_table[DETECT_XBITS].Free = DetectXbitFree;
+#ifdef UNITTESTS
sigmatch_table[DETECT_XBITS].RegisterTests = XBitsRegisterTests;
+#endif
/* this is compatible to ip-only signatures */
sigmatch_table[DETECT_XBITS].flags |= SIGMATCH_IPONLY_COMPAT;
return -1;
}
-void DetectXbitFree (DetectEngineCtx *de_ctx, void *ptr)
+static void DetectXbitFree (DetectEngineCtx *de_ctx, void *ptr)
{
DetectXbitsData *fd = (DetectXbitsData *)ptr;
PASS;
}
-#endif /* UNITTESTS */
-
/**
* \brief this function registers unit tests for XBits
*/
-void XBitsRegisterTests(void)
+static void XBitsRegisterTests(void)
{
-#ifdef UNITTESTS
UtRegisterTest("XBitsTestParse01", XBitsTestParse01);
UtRegisterTest("XBitsTestSig01", XBitsTestSig01);
UtRegisterTest("XBitsTestSig02", XBitsTestSig02);
-#endif /* UNITTESTS */
}
+#endif /* UNITTESTS */
\ No newline at end of file
int (*SetupPrefilter)(DetectEngineCtx *de_ctx, struct SigGroupHead_ *sgh);
void (*Free)(DetectEngineCtx *, void *);
+#ifdef UNITTESTS
void (*RegisterTests)(void);
-
+#endif
uint16_t flags;
/* coccinelle: SigTableElmt:flags:SIGMATCH_ */