suricata
detect-engine.c File Reference
#include "suricata-common.h"
#include "suricata.h"
#include "detect.h"
#include "flow.h"
#include "flow-private.h"
#include "flow-util.h"
#include "flow-worker.h"
#include "conf.h"
#include "conf-yaml-loader.h"
#include "datasets.h"
#include "app-layer-parser.h"
#include "app-layer-events.h"
#include "app-layer-htp.h"
#include "detect-parse.h"
#include "detect-engine-sigorder.h"
#include "detect-engine-build.h"
#include "detect-engine-siggroup.h"
#include "detect-engine-address.h"
#include "detect-engine-port.h"
#include "detect-engine-prefilter.h"
#include "detect-engine-mpm.h"
#include "detect-engine-iponly.h"
#include "detect-engine-tag.h"
#include "detect-engine-frame.h"
#include "detect-engine-file.h"
#include "detect-engine.h"
#include "detect-engine-state.h"
#include "detect-engine-payload.h"
#include "detect-fast-pattern.h"
#include "detect-byte-extract.h"
#include "detect-content.h"
#include "detect-uricontent.h"
#include "detect-tcphdr.h"
#include "detect-engine-threshold.h"
#include "detect-engine-content-inspection.h"
#include "detect-engine-loader.h"
#include "detect-engine-alert.h"
#include "util-classification-config.h"
#include "util-reference-config.h"
#include "util-threshold-config.h"
#include "util-error.h"
#include "util-hash.h"
#include "util-byte.h"
#include "util-debug.h"
#include "util-unittest.h"
#include "util-action.h"
#include "util-magic.h"
#include "util-signal.h"
#include "util-spm.h"
#include "util-device-private.h"
#include "util-var-name.h"
#include "util-path.h"
#include "util-profiling.h"
#include "util-validate.h"
#include "util-hash-string.h"
#include "util-enum.h"
#include "util-conf.h"
#include "tm-threads.h"
#include "runmodes.h"
#include "reputation.h"
#include "util-hash-lookup3.h"

Go to the source code of this file.

Data Structures

struct  DetectEngineSyncer_
 
struct  TenantLoaderCtx_
 

Macros

#define DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT   3000
 

Typedefs

typedef struct DetectEngineSyncer_ DetectEngineSyncer
 
typedef struct TenantLoaderCtx_ TenantLoaderCtx
 

Enumerations

enum  DetectEngineSyncState { IDLE , RELOAD }
 

Functions

const char * DetectTableToString (enum DetectTable table)
 
void DetectPktInspectEngineRegister (const char *name, InspectionBufferGetPktDataPtr GetPktData, InspectionBufferPktInspectFunc Callback)
 register inspect engine at start up time
 
void DetectAppLayerInspectEngineRegister (const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
 Registers an app inspection engine.
 
void DetectAppLayerInspectEngineRegisterSingle (const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionSingleBufferGetDataPtr GetData)
 
void DetectEngineFrameInspectEngineRegister (DetectEngineCtx *de_ctx, const char *name, int dir, InspectionBufferFrameInspectFunc Callback, AppProto alproto, uint8_t type)
 register inspect engine at start up time
 
int DetectEngineAppInspectionEngine2Signature (DetectEngineCtx *de_ctx, Signature *s)
 
void DetectEngineAppInspectionEngineSignatureFree (DetectEngineCtx *de_ctx, Signature *s)
 free app inspect engines for a signature
 
int DetectBufferTypeMaxId (void)
 
int DetectBufferTypeRegister (const char *name)
 
void DetectBufferTypeSupportsMultiInstance (const char *name)
 
void DetectBufferTypeSupportsFrames (const char *name)
 
void DetectBufferTypeSupportsPacket (const char *name)
 
void DetectBufferTypeSupportsMpm (const char *name)
 
void DetectBufferTypeSupportsTransformations (const char *name)
 
int DetectBufferTypeGetByName (const char *name)
 
const DetectBufferTypeDetectEngineBufferTypeGetById (const DetectEngineCtx *de_ctx, const int id)
 
const char * DetectEngineBufferTypeGetNameById (const DetectEngineCtx *de_ctx, const int id)
 
int DetectEngineBufferTypeRegisterWithFrameEngines (DetectEngineCtx *de_ctx, const char *name, const int direction, const AppProto alproto, const uint8_t frame_type)
 
int DetectEngineBufferTypeRegister (DetectEngineCtx *de_ctx, const char *name)
 
void DetectBufferTypeSetDescriptionByName (const char *name, const char *desc)
 
const char * DetectEngineBufferTypeGetDescriptionById (const DetectEngineCtx *de_ctx, const int id)
 
const char * DetectBufferTypeGetDescriptionByName (const char *name)
 
void DetectEngineBufferTypeSupportsFrames (DetectEngineCtx *de_ctx, const char *name)
 
void DetectEngineBufferTypeSupportsPacket (DetectEngineCtx *de_ctx, const char *name)
 
void DetectEngineBufferTypeSupportsMpm (DetectEngineCtx *de_ctx, const char *name)
 
void DetectEngineBufferTypeSupportsTransformations (DetectEngineCtx *de_ctx, const char *name)
 
bool DetectEngineBufferTypeSupportsMultiInstanceGetById (const DetectEngineCtx *de_ctx, const int id)
 
bool DetectEngineBufferTypeSupportsPacketGetById (const DetectEngineCtx *de_ctx, const int id)
 
bool DetectEngineBufferTypeSupportsMpmGetById (const DetectEngineCtx *de_ctx, const int id)
 
bool DetectEngineBufferTypeSupportsFramesGetById (const DetectEngineCtx *de_ctx, const int id)
 
void DetectBufferTypeRegisterSetupCallback (const char *name, void(*SetupCallback)(const DetectEngineCtx *, Signature *))
 
void DetectEngineBufferRunSetupCallback (const DetectEngineCtx *de_ctx, const int id, Signature *s)
 
void DetectBufferTypeRegisterValidateCallback (const char *name, bool(*ValidateCallback)(const Signature *, const char **sigerror, const DetectBufferType *))
 
bool DetectEngineBufferRunValidateCallback (const DetectEngineCtx *de_ctx, const int id, const Signature *s, const char **sigerror)
 
bool DetectBufferIsPresent (const Signature *s, const uint32_t buf_id)
 
bool DetectEngineBufferTypeValidateTransform (DetectEngineCtx *de_ctx, int sm_list, const uint8_t *content, uint16_t content_len, const char **namestr)
 Check content byte array compatibility with transforms.
 
void DetectBufferTypeCloseRegistration (void)
 
int DetectEngineBufferTypeGetByIdTransforms (DetectEngineCtx *de_ctx, const int id, TransformData *transforms, int transform_cnt)
 
bool DetectEnginePktInspectionRun (ThreadVars *tv, DetectEngineThreadCtx *det_ctx, const Signature *s, Flow *f, Packet *p, uint8_t *alert_flags)
 
int DetectEnginePktInspectionSetup (Signature *s)
 
int DetectEngineReloadStart (void)
 
int DetectEngineReloadIsStart (void)
 
void DetectEngineReloadSetIdle (void)
 
int DetectEngineReloadIsIdle (void)
 
uint8_t DetectEngineInspectGenericList (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 Do the content inspection & validation for a signature.
 
uint8_t DetectEngineInspectBufferSingle (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 Do the content inspection & validation for a signature.
 
uint8_t DetectEngineInspectBufferGeneric (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 Do the content inspection & validation for a signature.
 
void DetectAppLayerMultiRegister (const char *name, AppProto alproto, uint32_t dir, int progress, InspectionMultiBufferGetDataPtr GetData, int priority)
 
InspectionBufferDetectGetSingleData (struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Flow *f, const uint8_t flow_flags, void *txv, const int list_id, InspectionSingleBufferGetDataPtr GetBuf)
 
InspectionBufferDetectGetMultiData (struct DetectEngineThreadCtx_ *det_ctx, const DetectEngineTransforms *transforms, Flow *f, const uint8_t flow_flags, void *txv, const int list_id, uint32_t index, InspectionMultiBufferGetDataPtr GetBuf)
 
uint8_t DetectEngineInspectMultiBufferGeneric (DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const DetectEngineAppInspectionEngine *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
 
int DetectEngineInspectPktBufferGeneric (DetectEngineThreadCtx *det_ctx, const DetectEnginePktInspectionEngine *engine, const Signature *s, Packet *p, uint8_t *_alert_flags)
 Do the content inspection & validation for a signature.
 
void InjectPacketsForFlush (ThreadVars **detect_tvs, int no_of_detect_tvs)
 
bool DetectEngineMpmCachingEnabled (void)
 
const char * DetectEngineMpmCachingGetPath (void)
 
DetectEngineCtxDetectEngineCtxInitStubForMT (void)
 
DetectEngineCtxDetectEngineCtxInitStubForDD (void)
 
DetectEngineCtxDetectEngineCtxInit (void)
 
DetectEngineCtxDetectEngineCtxInitWithPrefix (const char *prefix, uint32_t tenant_id)
 
void DetectEngineCtxFree (DetectEngineCtx *de_ctx)
 Free a DetectEngineCtx::
 
void DetectEngineResetMaxSigId (DetectEngineCtx *de_ctx)
 
TmEcode DetectEngineThreadCtxInit (ThreadVars *tv, void *initdata, void **data)
 initialize thread specific detection engine context
 
DetectEngineThreadCtxDetectEngineThreadCtxInitForReload (ThreadVars *tv, DetectEngineCtx *new_de_ctx, int mt)
 
TmEcode DetectEngineThreadCtxDeinit (ThreadVars *tv, void *data)
 
int DetectRegisterThreadCtxFuncs (DetectEngineCtx *de_ctx, const char *name, void *(*InitFunc)(void *), void *data, void(*FreeFunc)(void *), int mode)
 Register Thread keyword context Funcs.
 
int DetectUnregisterThreadCtxFuncs (DetectEngineCtx *de_ctx, void *data, const char *name)
 Remove Thread keyword context registration.
 
void * DetectThreadCtxGetKeywordThreadCtx (DetectEngineThreadCtx *det_ctx, int id)
 Retrieve thread local keyword ctx by id.
 
int DetectRegisterThreadCtxGlobalFuncs (const char *name, void *(*InitFunc)(void *), void *data, void(*FreeFunc)(void *))
 Register Thread keyword context Funcs (Global)
 
void * DetectThreadCtxGetGlobalKeywordThreadCtx (DetectEngineThreadCtx *det_ctx, int id)
 Retrieve thread local keyword ctx by id.
 
int DetectEngineEnabled (void)
 Check if detection is enabled.
 
uint32_t DetectEngineGetVersion (void)
 
void DetectEngineBumpVersion (void)
 
DetectEngineCtxDetectEngineGetCurrent (void)
 
DetectEngineCtxDetectEngineReference (DetectEngineCtx *de_ctx)
 
bool DetectEngineMultiTenantEnabled (void)
 
int DetectEngineLoadTenantBlocking (uint32_t tenant_id, const char *yaml)
 Load a tenant and wait for loading to complete.
 
int DetectEngineReloadTenantBlocking (uint32_t tenant_id, const char *yaml, int reload_cnt)
 Reload a tenant and wait for loading to complete.
 
int DetectEngineReloadTenantsBlocking (const int reload_cnt)
 Reload all tenants and wait for loading to complete.
 
int DetectEngineMultiTenantSetup (const bool unix_socket)
 setup multi-detect / multi-tenancy
 
int DetectEngineTenantRegisterLivedev (uint32_t tenant_id, int device_id)
 
int DetectEngineTenantRegisterVlanId (uint32_t tenant_id, uint16_t vlan_id)
 
int DetectEngineTenantUnregisterVlanId (uint32_t tenant_id, uint16_t vlan_id)
 
int DetectEngineTenantRegisterPcapFile (uint32_t tenant_id)
 
int DetectEngineTenantUnregisterPcapFile (uint32_t tenant_id)
 
DetectEngineCtxDetectEngineGetByTenantId (uint32_t tenant_id)
 
void DetectEngineDeReference (DetectEngineCtx **de_ctx)
 
int DetectEngineAddToMaster (DetectEngineCtx *de_ctx)
 
int DetectEngineMoveToFreeList (DetectEngineCtx *de_ctx)
 
void DetectEnginePruneFreeList (void)
 
void DetectEngineClearMaster (void)
 
int DetectEngineReload (const SCInstance *suri)
 Reload the detection engine.
 
int DetectEngineMTApply (void)
 
void DetectEngineSetParseMetadata (void)
 
void DetectEngineUnsetParseMetadata (void)
 
int DetectEngineMustParseMetadata (void)
 
const char * DetectSigmatchListEnumToString (enum DetectSigmatchListEnum type)
 
void DetectEngineSetEvent (DetectEngineThreadCtx *det_ctx, uint8_t e)
 
bool DetectMd5ValidateCallback (const Signature *s, const char **sigerror, const DetectBufferType *map)
 
void SCDetectEngineRegisterRateFilterCallback (SCDetectRateFilterFunc fn, void *arg)
 Register a callback when a rate_filter has been applied to an alert.
 
int DetectEngineThreadCtxGetJsonContext (DetectEngineThreadCtx *det_ctx)
 
void DetectEngineRegisterTests (void)
 

Variables

const struct SignatureProperties signature_properties [SIG_TYPE_MAX]
 

Detailed Description

Macro Definition Documentation

◆ DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT

#define DETECT_ENGINE_DEFAULT_INSPECTION_RECURSION_LIMIT   3000

Definition at line 95 of file detect-engine.c.

Typedef Documentation

◆ DetectEngineSyncer

◆ TenantLoaderCtx

Enumeration Type Documentation

◆ DetectEngineSyncState

Enumerator
IDLE 

ready to start a reload

RELOAD 

command main thread to do the reload

Definition at line 1882 of file detect-engine.c.

Function Documentation

◆ DetectAppLayerInspectEngineRegister()

void DetectAppLayerInspectEngineRegister ( const char *  name,
AppProto  alproto,
uint32_t  dir,
int  progress,
InspectEngineFuncPtr  Callback2,
InspectionBufferGetDataPtr  GetData 
)

Registers an app inspection engine.

Parameters
nameName of the detection list
alprotoApp layer protocol for which we will register the engine.
directionThe direction for the engine: SIG_FLAG_TOSERVER or SIG_FLAG_TOCLIENT
progressMinimal progress value for inspect engine to run
CallbackThe engine callback.

Definition at line 272 of file detect-engine.c.

References DetectEngineAppInspectionEngine_::alproto, DetectEngineAppInspectionEngine_::Callback, DEBUG_VALIDATE_BUG_ON, DetectBufferTypeGetByName(), DetectEngineAppInspectionEngine_::dir, DetectEngineAppInspectionEngine_::GetData, name, DetectEngineAppInspectionEngine_::next, DetectEngineAppInspectionEngine_::progress, SIG_FLAG_TOCLIENT, SIG_FLAG_TOSERVER, DetectEngineAppInspectionEngine_::sm_list, and DetectEngineAppInspectionEngine_::v2.

Referenced by DetectAppLayerEventRegister(), DetectAppLayerStateRegister(), DetectDceIfaceRegister(), DetectDceStubDataRegister(), DetectDNP3Register(), DetectDnsResponseRegister(), DetectFileRegisterFileProtocols(), DetectFtpdataRegister(), DetectFtpDynamicPortRegister(), DetectFtpModeRegister(), DetectFtpReplyReceivedRegister(), DetectHttp2Register(), DetectHttpClientBodyRegister(), DetectHttpCookieRegister(), DetectHttpHeaderNamesRegister(), DetectHttpHeaderRegister(), DetectHttpHHRegister(), DetectHttpMethodRegister(), DetectHttpProtocolRegister(), DetectHttpRawHeaderRegister(), DetectHttpRequestLineRegister(), DetectHttpResponseLineRegister(), DetectHttpStartRegister(), DetectHttpStatCodeRegister(), DetectHttpStatMsgRegister(), DetectHttpUARegister(), DetectHttpUriRegister(), DetectIkeChosenSaRegister(), DetectIkeExchTypeRegister(), DetectIkeKeyExchangePayloadLengthRegister(), DetectIkeKeyExchangeRegister(), DetectIkeNoncePayloadLengthRegister(), DetectIkeNonceRegister(), DetectIkeSpiRegister(), DetectJa4HashRegister(), DetectKrb5ErrCodeRegister(), DetectKrb5MsgTypeRegister(), DetectKrb5TicketEncryptionRegister(), DetectLuaRegister(), DetectModbusRegister(), DetectNfsProcedureRegister(), DetectQuicSniRegister(), DetectQuicUaRegister(), DetectQuicVersionRegister(), DetectRegisterAppLayerHookLists(), DetectSipMethodRegister(), DetectSipUriRegister(), DetectSmbNamedPipeRegister(), DetectSmbNtlmsspDomainRegister(), DetectSmbNtlmsspUserRegister(), DetectSmbShareRegister(), DetectSmbVersionRegister(), DetectSshHasshRegister(), DetectSshHasshServerRegister(), DetectSshHasshServerStringRegister(), DetectSshHasshStringRegister(), DetectSshProtocolRegister(), DetectSshSoftwareRegister(), DetectSslStateRegister(), DetectTlsFingerprintRegister(), DetectTlsIssuerRegister(), DetectTlsJa3HashRegister(), DetectTlsJa3SHashRegister(), DetectTlsJa3SStringRegister(), DetectTlsJa3StringRegister(), DetectTlsRandomBytesRegister(), DetectTlsRandomRegister(), DetectTlsRandomTimeRegister(), DetectTlsRegister(), DetectTlsSerialRegister(), DetectTlsSniRegister(), DetectTlsSubjectRegister(), SCDetectHelperBufferRegister(), and SCDetectSMTPRegister().

Here is the call graph for this function:

◆ DetectAppLayerInspectEngineRegisterSingle()

◆ DetectAppLayerMultiRegister()

◆ DetectBufferIsPresent()

bool DetectBufferIsPresent ( const Signature s,
const uint32_t  buf_id 
)

◆ DetectBufferTypeCloseRegistration()

void DetectBufferTypeCloseRegistration ( void  )

Definition at line 1655 of file detect-engine.c.

References BUG_ON.

Referenced by SigTableSetup().

Here is the caller graph for this function:

◆ DetectBufferTypeGetByName()

int DetectBufferTypeGetByName ( const char *  name)

Definition at line 1277 of file detect-engine.c.

References DetectBufferType_::id, and name.

Referenced by DcePayloadRegisterTests(), DetectAppLayerEventRegister(), DetectAppLayerInspectEngineRegister(), DetectAppLayerInspectEngineRegisterSingle(), DetectAppLayerStateRegister(), DetectDceStubDataRegister(), DetectDnsResponseRegister(), DetectEngineAppInspectionEngine2Signature(), DetectFiledataRegister(), DetectFrameMpmRegister(), DetectFtpbounceRegister(), DetectFtpCommandDataRegister(), DetectFtpCompletionCodeRegister(), DetectFtpdataRegister(), DetectFtpDynamicPortRegister(), DetectFtpModeRegister(), DetectFtpReplyReceivedRegister(), DetectFtpReplyRegister(), DetectHttp2Register(), DetectHttpClientBodyRegister(), DetectHttpCookieRegister(), DetectHttpHeaderNamesRegister(), DetectHttpHeaderRegister(), DetectHttpHHRegister(), DetectHttpMethodRegister(), DetectHttpProtocolRegister(), DetectHttpRawHeaderRegister(), DetectHttpRequestHeaderRegister(), DetectHttpRequestLineRegister(), DetectHttpResponseHeaderRegister(), DetectHttpResponseLineRegister(), DetectHttpStartRegister(), DetectHttpStatCodeRegister(), DetectHttpStatMsgRegister(), DetectHttpUARegister(), DetectHttpUriRegister(), DetectIkeChosenSaRegister(), DetectIkeExchTypeRegister(), DetectIkeKeyExchangePayloadLengthRegister(), DetectIkeKeyExchangeRegister(), DetectIkeNoncePayloadLengthRegister(), DetectIkeNonceRegister(), DetectIkeSpiRegister(), DetectIkeVendorRegister(), DetectJa4HashRegister(), DetectKrb5CNameRegister(), DetectKrb5SNameRegister(), DetectModbusRegister(), DetectNfsProcedureRegister(), DetectNfsVersionRegister(), DetectPktInspectEngineRegister(), DetectPktMpmRegister(), DetectQuicCyuHashRegister(), DetectQuicCyuStringRegister(), DetectQuicSniRegister(), DetectQuicUaRegister(), DetectQuicVersionRegister(), DetectSipMethodRegister(), DetectSipUriRegister(), DetectSmbNamedPipeRegister(), DetectSmbNtlmsspDomainRegister(), DetectSmbNtlmsspUserRegister(), DetectSmbShareRegister(), DetectSshHasshRegister(), DetectSshHasshServerRegister(), DetectSshHasshServerStringRegister(), DetectSshHasshStringRegister(), DetectSshProtocolRegister(), DetectSshSoftwareRegister(), DetectTlsAlpnRegister(), DetectTlsCertChainLenRegister(), DetectTlsCertsRegister(), DetectTlsFingerprintRegister(), DetectTlsIssuerRegister(), DetectTlsJa3HashRegister(), DetectTlsJa3SHashRegister(), DetectTlsJa3SStringRegister(), DetectTlsJa3StringRegister(), DetectTlsRandomBytesRegister(), DetectTlsRandomRegister(), DetectTlsRandomTimeRegister(), DetectTlsSerialRegister(), DetectTlsSniRegister(), DetectTlsSubjectAltNameRegister(), DetectTlsSubjectRegister(), DetectTlsValidityRegister(), SCDetectHelperBufferMpmRegister(), SCDetectHelperMultiBufferProgressMpmRegister(), and SCDetectSMTPRegister().

◆ DetectBufferTypeGetDescriptionByName()

const char * DetectBufferTypeGetDescriptionByName ( const char *  name)

Definition at line 1394 of file detect-engine.c.

References DetectBufferType_::description, and name.

◆ DetectBufferTypeMaxId()

int DetectBufferTypeMaxId ( void  )

Definition at line 1034 of file detect-engine.c.

◆ DetectBufferTypeRegister()

◆ DetectBufferTypeRegisterSetupCallback()

void DetectBufferTypeRegisterSetupCallback ( const char *  name,
void(*)(const DetectEngineCtx *, Signature *)  SetupCallback 
)

◆ DetectBufferTypeRegisterValidateCallback()

void DetectBufferTypeRegisterValidateCallback ( const char *  name,
bool(*)(const Signature *, const char **sigerror, const DetectBufferType *)  ValidateCallback 
)

◆ DetectBufferTypeSetDescriptionByName()

void DetectBufferTypeSetDescriptionByName ( const char *  name,
const char *  desc 
)

Definition at line 1374 of file detect-engine.c.

References BUG_ON, DetectBufferType_::description, name, and strlcpy().

Referenced by DetectDnsResponseRegister(), DetectFiledataRegister(), DetectFilenameRegister(), DetectFtpCommandDataRegister(), DetectFtpCompletionCodeRegister(), DetectFtpDynamicPortRegister(), DetectFtpModeRegister(), DetectFtpReplyRegister(), DetectHttp2Register(), DetectHttpClientBodyRegister(), DetectHttpCookieRegister(), DetectHttpHeaderNamesRegister(), DetectHttpHeaderRegister(), DetectHttpHHRegister(), DetectHttpMethodRegister(), DetectHttpProtocolRegister(), DetectHttpRawHeaderRegister(), DetectHttpRequestHeaderRegister(), DetectHttpRequestLineRegister(), DetectHttpResponseHeaderRegister(), DetectHttpResponseLineRegister(), DetectHttpStartRegister(), DetectHttpStatCodeRegister(), DetectHttpStatMsgRegister(), DetectHttpUARegister(), DetectHttpUriRegister(), DetectIkeKeyExchangeRegister(), DetectIkeNonceRegister(), DetectIkeSpiRegister(), DetectJa4HashRegister(), DetectKrb5CNameRegister(), DetectKrb5SNameRegister(), DetectQuicCyuHashRegister(), DetectQuicCyuStringRegister(), DetectSipMethodRegister(), DetectSipUriRegister(), DetectSshHasshRegister(), DetectSshHasshServerRegister(), DetectSshHasshServerStringRegister(), DetectSshHasshStringRegister(), DetectSshProtocolRegister(), DetectSshSoftwareRegister(), DetectSslStateRegister(), DetectTlsAlpnRegister(), DetectTlsCertsRegister(), DetectTlsFingerprintRegister(), DetectTlsIssuerRegister(), DetectTlsJa3HashRegister(), DetectTlsJa3SHashRegister(), DetectTlsJa3SStringRegister(), DetectTlsJa3StringRegister(), DetectTlsRandomBytesRegister(), DetectTlsRandomRegister(), DetectTlsRandomTimeRegister(), DetectTlsSerialRegister(), DetectTlsSniRegister(), DetectTlsSubjectAltNameRegister(), DetectTlsSubjectRegister(), SCDetectHelperBufferMpmRegister(), SCDetectHelperMultiBufferProgressMpmRegister(), and SCDetectSMTPRegister().

Here is the call graph for this function:

◆ DetectBufferTypeSupportsFrames()

void DetectBufferTypeSupportsFrames ( const char *  name)

Definition at line 1237 of file detect-engine.c.

References BUG_ON, DetectBufferTypeRegister(), DetectBufferType_::frame, DetectBufferType_::id, name, and SCLogDebug.

Referenced by DetectFrameMpmRegister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectBufferTypeSupportsMpm()

void DetectBufferTypeSupportsMpm ( const char *  name)

Definition at line 1257 of file detect-engine.c.

References BUG_ON, DetectBufferTypeRegister(), DetectBufferType_::id, DetectBufferType_::mpm, name, and SCLogDebug.

Referenced by DetectFrameMpmRegister(), and DetectPktMpmRegister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectBufferTypeSupportsMultiInstance()

◆ DetectBufferTypeSupportsPacket()

void DetectBufferTypeSupportsPacket ( const char *  name)

◆ DetectBufferTypeSupportsTransformations()

void DetectBufferTypeSupportsTransformations ( const char *  name)

Definition at line 1267 of file detect-engine.c.

References BUG_ON, DetectBufferTypeRegister(), DetectBufferType_::id, name, SCLogDebug, and DetectBufferType_::supports_transforms.

Referenced by DetectFrameMpmRegister(), and DetectPktMpmRegister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineAddToMaster()

int DetectEngineAddToMaster ( DetectEngineCtx de_ctx)

Definition at line 4662 of file detect-engine.c.

References de_ctx, DetectEngineMasterCtx_::lock, SCLogDebug, SCMutexLock, and SCMutexUnlock.

Referenced by DetectEngineReload(), and PostConfLoadedDetectSetup().

Here is the caller graph for this function:

◆ DetectEngineAppInspectionEngine2Signature()

int DetectEngineAppInspectionEngine2Signature ( DetectEngineCtx de_ctx,
Signature s 
)
Note
for the file inspect engine, the id DE_STATE_ID_FILE_INSPECT is assigned.

Definition at line 800 of file detect-engine.c.

References DetectEngineAppInspectionEngine_::alproto, SignatureHook_::alproto, SignatureHook_::app, Signature_::app_inspect, DetectEngineCtx_::app_inspect_engines, SignatureHook_::app_progress, SignatureInitData_::buffer_index, SignatureInitData_::buffers, BUG_ON, DetectEngineTransforms::cnt, de_ctx, DE_STATE_FLAG_BASE, DETECT_SM_LIST_PMATCH, DetectBufferTypeGetByName(), DetectEngineBufferTypeGetById(), DetectEngineBufferTypeGetNameById(), DetectEngineAppInspectionEngine_::dir, FatalError, Signature_::flags, DetectBufferType_::frame, DetectEngineCtx_::frame_inspect_engines, SignatureInitDataBuffer_::head, SignatureInitData_::hook, DetectEngineAppInspectionEngine_::id, DetectBufferType_::id, SignatureInitDataBuffer_::id, Signature_::id, Signature_::init_data, SignatureInitData_::init_flags, SignatureInitData_::mpm_sm, SignatureInitData_::mpm_sm_list, DetectBufferType_::name, DetectEngineAppInspectionEngine_::next, DetectEnginePktInspectionEngine::next, DetectEngineFrameInspectionEngine::next, SignatureInitDataBuffer_::only_tc, SignatureInitDataBuffer_::only_ts, DetectBufferType_::packet, DetectBufferType_::parent_id, DetectEngineCtx_::pkt_inspect_engines, DetectEngineAppInspectionEngine_::progress, SCLogDebug, SIG_FLAG_FLUSH, SIG_FLAG_INIT_NEED_FLUSH, SIG_FLAG_INIT_STATE_MATCH, SIG_FLAG_TOCLIENT, SIG_FLAG_TOSERVER, SIG_FLAG_TXBOTHDIR, SigMatchList2DataArray(), SIGNATURE_HOOK_TYPE_APP, DetectEngineAppInspectionEngine_::sm_list, DetectEnginePktInspectionEngine::sm_list, DetectEngineFrameInspectionEngine::sm_list, SignatureHook_::sm_list, SignatureInitData_::smlists, SignatureHook_::t, DetectBufferType_::transforms, and SignatureHook_::type.

Here is the call graph for this function:

◆ DetectEngineAppInspectionEngineSignatureFree()

void DetectEngineAppInspectionEngineSignatureFree ( DetectEngineCtx de_ctx,
Signature s 
)

free app inspect engines for a signature

For lists that are registered multiple times, like http_header and http_cookie, making the engines owner of the lists is complicated. Multiple engines in a sig may be pointing to the same list. To address this the 'free' code needs to be extra careful about not double freeing, so it takes an approach to first fill an array of the to-free pointers before freeing them.

Definition at line 928 of file detect-engine.c.

References Signature_::app_inspect, BUG_ON, SigMatchData_::ctx, de_ctx, Signature_::frame_inspect, SigTableElmt_::Free, SigMatchData_::is_last, next, DetectEngineAppInspectionEngine_::next, DetectEnginePktInspectionEngine::next, DetectEngineFrameInspectionEngine::next, Signature_::pkt_inspect, SCFree, sigmatch_table, DetectEngineAppInspectionEngine_::smd, DetectEnginePktInspectionEngine::smd, DetectEngineFrameInspectionEngine::smd, and SigMatchData_::type.

Referenced by SigFree().

Here is the caller graph for this function:

◆ DetectEngineBufferRunSetupCallback()

void DetectEngineBufferRunSetupCallback ( const DetectEngineCtx de_ctx,
const int  id,
Signature s 
)

Definition at line 1481 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), and DetectBufferType_::SetupCallback.

Referenced by SigPrepareStage1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBufferRunValidateCallback()

bool DetectEngineBufferRunValidateCallback ( const DetectEngineCtx de_ctx,
const int  id,
const Signature s,
const char **  sigerror 
)

Definition at line 1500 of file detect-engine.c.

References DetectEngineTransforms::cnt, de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::transforms, and DetectBufferType_::ValidateCallback.

Here is the call graph for this function:

◆ DetectEngineBufferTypeGetById()

◆ DetectEngineBufferTypeGetByIdTransforms()

◆ DetectEngineBufferTypeGetDescriptionById()

const char * DetectEngineBufferTypeGetDescriptionById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1385 of file detect-engine.c.

References de_ctx, DetectBufferType_::description, and DetectEngineBufferTypeGetById().

Referenced by EngineAnalysisFP().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBufferTypeGetNameById()

const char * DetectEngineBufferTypeGetNameById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1307 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), and DetectBufferType_::name.

Referenced by DetectEngineAppInspectionEngine2Signature(), DumpPatterns(), EngineAnalysisFP(), EngineAnalysisRules2(), RetrieveFPForSig(), and SCDetectBufferSetActiveList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBufferTypeRegister()

int DetectEngineBufferTypeRegister ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1364 of file detect-engine.c.

References de_ctx, DetectBufferType_::id, and name.

Referenced by DetectEngineFrameInspectEngineRegister(), and DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeRegisterWithFrameEngines()

int DetectEngineBufferTypeRegisterWithFrameEngines ( DetectEngineCtx de_ctx,
const char *  name,
const int  direction,
const AppProto  alproto,
const uint8_t  frame_type 
)

◆ DetectEngineBufferTypeSupportsFrames()

void DetectEngineBufferTypeSupportsFrames ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1403 of file detect-engine.c.

References BUG_ON, de_ctx, DetectBufferType_::frame, DetectBufferType_::id, name, and SCLogDebug.

Referenced by DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsFramesGetById()

bool DetectEngineBufferTypeSupportsFramesGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1462 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::frame, and SCLogDebug.

Referenced by SignatureSetType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsMpm()

void DetectEngineBufferTypeSupportsMpm ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1419 of file detect-engine.c.

References BUG_ON, de_ctx, DetectBufferType_::id, DetectBufferType_::mpm, name, and SCLogDebug.

Referenced by DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsMpmGetById()

bool DetectEngineBufferTypeSupportsMpmGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1453 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::mpm, and SCLogDebug.

Referenced by DetectGetLastSMFromMpmLists(), and FastPatternSupportEnabledForSigMatchList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsMultiInstanceGetById()

bool DetectEngineBufferTypeSupportsMultiInstanceGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1435 of file detect-engine.c.

References BOOL2STR, de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::multi_instance, and SCLogDebug.

Referenced by DetectBufferGetActiveList(), and SCDetectBufferSetActiveList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsPacket()

void DetectEngineBufferTypeSupportsPacket ( DetectEngineCtx de_ctx,
const char *  name 
)

◆ DetectEngineBufferTypeSupportsPacketGetById()

bool DetectEngineBufferTypeSupportsPacketGetById ( const DetectEngineCtx de_ctx,
const int  id 
)

Definition at line 1444 of file detect-engine.c.

References de_ctx, DetectEngineBufferTypeGetById(), DetectBufferType_::packet, and SCLogDebug.

Referenced by SignatureSetType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBufferTypeSupportsTransformations()

void DetectEngineBufferTypeSupportsTransformations ( DetectEngineCtx de_ctx,
const char *  name 
)

Definition at line 1427 of file detect-engine.c.

References BUG_ON, de_ctx, DetectBufferType_::id, name, SCLogDebug, and DetectBufferType_::supports_transforms.

Referenced by DetectEngineFrameMpmRegister().

Here is the caller graph for this function:

◆ DetectEngineBufferTypeValidateTransform()

bool DetectEngineBufferTypeValidateTransform ( DetectEngineCtx de_ctx,
int  sm_list,
const uint8_t *  content,
uint16_t  content_len,
const char **  namestr 
)

Check content byte array compatibility with transforms.

The "content" array is presented to the transforms so that each transform may validate that it's compatible with the transform.

When a transform indicates the byte array is incompatible, none of the subsequent transforms, if any, are invoked. This means the first validation failure terminates the loop.

Parameters
de_ctxDetection engine context.
sm_listThe SM list id.
contentThe byte array being validated
namestrreturns the name of the transform that is incompatible with content.
Return values
true(false) If any of the transforms indicate the byte array is (is not) compatible.

Definition at line 1539 of file detect-engine.c.

References BUG_ON, DetectEngineTransforms::cnt, de_ctx, DetectEngineBufferTypeGetById(), SigTableElmt_::name, TransformData_::options, sigmatch_table, TransformData_::transform, DetectEngineTransforms::transforms, DetectBufferType_::transforms, and SigTableElmt_::TransformValidate.

Referenced by DetectContentSetup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineBumpVersion()

void DetectEngineBumpVersion ( void  )

Definition at line 3836 of file detect-engine.c.

References DetectEngineMasterCtx_::lock, SCLogDebug, SCMutexLock, SCMutexUnlock, and DetectEngineMasterCtx_::version.

Referenced by DetectEngineMTApply(), DetectEngineReload(), and PostConfLoadedDetectSetup().

Here is the caller graph for this function:

◆ DetectEngineClearMaster()

void DetectEngineClearMaster ( void  )

Definition at line 4762 of file detect-engine.c.

References DEBUG_VALIDATE_BUG_ON, DetectEnginePruneFreeList(), DetectEngineMasterCtx_::list, DetectEngineMasterCtx_::lock, next, DetectEngineCtx_::next, DetectEngineCtx_::ref_cnt, SCLogDebug, SCMutexLock, and SCMutexUnlock.

Referenced by GlobalsDestroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineCtxFree()

void DetectEngineCtxFree ( DetectEngineCtx de_ctx)

Free a DetectEngineCtx::

Parameters
de_ctxDetectEngineCtx:: to be freed

Definition at line 2641 of file detect-engine.c.

References DetectEngineCtx_::config_prefix, MpmTableElmt_::ConfigDeinit, de_ctx, DetectAddressMapFree(), DetectEngineFreeFastPatternList(), DetectMetadataHashFree(), DetectParseDupSigHashFree(), DetectPortCleanupList(), DetectEngineCtx_::filedata_config, HashTableFree(), DetectEngineCtx_::mpm_cfg, DetectEngineCtx_::mpm_matcher, mpm_table, MpmFactoryDeRegisterAllMpmCtxProfiles(), MpmStoreFree(), DetectEngineCtx_::non_pf_engine_names, DetectEngineCtx_::profile_keyword_ctx, DetectEngineCtx_::profile_sgh_ctx, DetectEngineCtx_::requirements, SCClassConfDeinit(), SCClassConfDeInitContext(), SCConfDump(), SCConfGetNode(), SCConfNodeRemove(), SCFree, SCProfilingKeywordDestroyCtx(), SCProfilingPrefilterDestroyCtx(), SCProfilingSghDestroyCtx(), SCRConfDeInitContext(), SCReferenceConfDeinit(), SCSigSignatureOrderingModuleCleanup(), DetectEngineCtx_::sig_array, SigCleanSignatures(), SigGroupCleanup(), SigGroupHeadHashFree(), DetectEngineCtx_::sm_types_prefilter, DetectEngineCtx_::sm_types_silent_error, DetectEngineCtx_::spm_global_thread_ctx, SpmDestroyGlobalThreadCtx(), SRepDestroy(), DetectEngineCtx_::tcp_priorityports, DetectEngineCtx_::tenant_path, and DetectEngineCtx_::udp_priorityports.

Referenced by DetectEnginePruneFreeList(), DetectEngineReload(), LLVMFuzzerTestOneInput(), UTHGenericTest(), UTHPacketMatchSig(), UTHPacketMatchSigMpm(), and UTHParseSignature().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineCtxInit()

DetectEngineCtx * DetectEngineCtxInit ( void  )

◆ DetectEngineCtxInitStubForDD()

DetectEngineCtx * DetectEngineCtxInitStubForDD ( void  )

Definition at line 2597 of file detect-engine.c.

References DETECT_ENGINE_TYPE_DD_STUB.

Referenced by PostConfLoadedDetectSetup().

Here is the caller graph for this function:

◆ DetectEngineCtxInitStubForMT()

DetectEngineCtx * DetectEngineCtxInitStubForMT ( void  )

Definition at line 2592 of file detect-engine.c.

References DETECT_ENGINE_TYPE_MT_STUB.

Referenced by DetectEngineMTApply(), and PostConfLoadedDetectSetup().

Here is the caller graph for this function:

◆ DetectEngineCtxInitWithPrefix()

DetectEngineCtx * DetectEngineCtxInitWithPrefix ( const char *  prefix,
uint32_t  tenant_id 
)

Definition at line 2607 of file detect-engine.c.

References DETECT_ENGINE_TYPE_NORMAL, and DetectEngineCtxInit().

Referenced by DetectEngineReload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineDeReference()

void DetectEngineDeReference ( DetectEngineCtx **  de_ctx)

Definition at line 4638 of file detect-engine.c.

References de_ctx, and DEBUG_VALIDATE_BUG_ON.

Referenced by DetectEngineReload(), DetectEngineThreadCtxInitForReload(), GlobalsDestroy(), and SCDetectEngineRegisterRateFilterCallback().

Here is the caller graph for this function:

◆ DetectEngineEnabled()

int DetectEngineEnabled ( void  )

Check if detection is enabled.

Return values
booltrue or false

Definition at line 3812 of file detect-engine.c.

References DetectEngineMasterCtx_::list, DetectEngineMasterCtx_::lock, SCMutexLock, and SCMutexUnlock.

◆ DetectEngineFrameInspectEngineRegister()

◆ DetectEngineGetByTenantId()

◆ DetectEngineGetCurrent()

◆ DetectEngineGetVersion()

uint32_t DetectEngineGetVersion ( void  )

◆ DetectEngineInspectBufferGeneric()

uint8_t DetectEngineInspectBufferGeneric ( DetectEngineCtx de_ctx,
DetectEngineThreadCtx det_ctx,
const DetectEngineAppInspectionEngine engine,
const Signature s,
Flow f,
uint8_t  flags,
void *  alstate,
void *  txv,
uint64_t  tx_id 
)

Do the content inspection & validation for a signature.

Parameters
de_ctxDetection engine context
det_ctxDetection engine thread context
sSignature to inspect
fFlow
flagsapp layer flags
stateApp layer state
Return values
0no match.
1match.
2Sig can't match.

Definition at line 2057 of file detect-engine.c.

References Flow_::alproto, AppLayerParserGetStateProgress(), de_ctx, DETECT_CI_FLAGS_END, DETECT_CI_FLAGS_START, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE, DETECT_ENGINE_INSPECT_SIG_CANT_MATCH, DETECT_ENGINE_INSPECT_SIG_MATCH, DETECT_ENGINE_INSPECT_SIG_NO_MATCH, DetectEngineContentInspection(), flags, InspectionBuffer::flags, DetectEngineAppInspectionEngine_::GetData, InspectionBuffer::inspect, InspectionBuffer::inspect_len, InspectionBuffer::inspect_offset, DetectEngineAppInspectionEngine_::match_on_null, DetectEngineAppInspectionEngine_::mpm, offset, DetectEngineAppInspectionEngine_::progress, Flow_::proto, SCLogDebug, DetectEngineAppInspectionEngine_::sm_list, DetectEngineAppInspectionEngine_::smd, DetectEngineAppInspectionEngine_::transforms, unlikely, and DetectEngineAppInspectionEngine_::v2.

Referenced by DetectDceStubDataRegister(), DetectHttpCookieRegister(), DetectHttpHeaderNamesRegister(), DetectHttpHeaderRegister(), DetectHttpHHRegister(), DetectHttpMethodRegister(), DetectHttpProtocolRegister(), DetectHttpRawHeaderRegister(), DetectHttpRequestLineRegister(), DetectHttpResponseLineRegister(), DetectHttpStartRegister(), DetectHttpStatCodeRegister(), DetectHttpStatMsgRegister(), DetectHttpUARegister(), DetectHttpUriRegister(), DetectIkeKeyExchangeRegister(), DetectIkeNonceRegister(), DetectIkeSpiRegister(), DetectJa4HashRegister(), DetectQuicSniRegister(), DetectQuicUaRegister(), DetectQuicVersionRegister(), DetectSipMethodRegister(), DetectSipUriRegister(), DetectSmbNamedPipeRegister(), DetectSmbNtlmsspDomainRegister(), DetectSmbNtlmsspUserRegister(), DetectSmbShareRegister(), DetectSshHasshRegister(), DetectSshHasshServerRegister(), DetectSshHasshServerStringRegister(), DetectSshHasshStringRegister(), DetectSshProtocolRegister(), DetectSshSoftwareRegister(), DetectTlsFingerprintRegister(), DetectTlsIssuerRegister(), DetectTlsJa3HashRegister(), DetectTlsJa3SHashRegister(), DetectTlsJa3SStringRegister(), DetectTlsJa3StringRegister(), DetectTlsRandomBytesRegister(), DetectTlsRandomRegister(), DetectTlsRandomTimeRegister(), DetectTlsSerialRegister(), DetectTlsSniRegister(), DetectTlsSubjectRegister(), and SCDetectSMTPRegister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineInspectBufferSingle()

uint8_t DetectEngineInspectBufferSingle ( DetectEngineCtx de_ctx,
DetectEngineThreadCtx det_ctx,
const DetectEngineAppInspectionEngine engine,
const Signature s,
Flow f,
uint8_t  flags,
void *  alstate,
void *  txv,
uint64_t  tx_id 
)

◆ DetectEngineInspectGenericList()

uint8_t DetectEngineInspectGenericList ( DetectEngineCtx de_ctx,
DetectEngineThreadCtx det_ctx,
const struct DetectEngineAppInspectionEngine_ engine,
const Signature s,
Flow f,
uint8_t  flags,
void *  alstate,
void *  txv,
uint64_t  tx_id 
)

◆ DetectEngineInspectMultiBufferGeneric()

◆ DetectEngineInspectPktBufferGeneric()

◆ DetectEngineLoadTenantBlocking()

int DetectEngineLoadTenantBlocking ( uint32_t  tenant_id,
const char *  yaml 
)

Load a tenant and wait for loading to complete.

Definition at line 4136 of file detect-engine.c.

References DetectLoadersSync().

Here is the call graph for this function:

◆ DetectEngineMoveToFreeList()

int DetectEngineMoveToFreeList ( DetectEngineCtx de_ctx)

Definition at line 4722 of file detect-engine.c.

References de_ctx, DetectEngineMasterCtx_::lock, SCMutexLock, and SCMutexUnlock.

Referenced by DetectEngineReload(), and GlobalsDestroy().

Here is the caller graph for this function:

◆ DetectEngineMpmCachingEnabled()

bool DetectEngineMpmCachingEnabled ( void  )

Definition at line 2462 of file detect-engine.c.

References SCConfGetBool().

Referenced by DetectEngineMpmCachingGetPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineMpmCachingGetPath()

const char * DetectEngineMpmCachingGetPath ( void  )

Definition at line 2471 of file detect-engine.c.

References DetectEngineMpmCachingEnabled(), SCConfGet(), and SCLogInfo.

Here is the call graph for this function:

◆ DetectEngineMTApply()

◆ DetectEngineMultiTenantEnabled()

bool DetectEngineMultiTenantEnabled ( void  )

◆ DetectEngineMultiTenantSetup()

int DetectEngineMultiTenantSetup ( const bool  unix_socket)

◆ DetectEngineMustParseMetadata()

int DetectEngineMustParseMetadata ( void  )

Definition at line 4980 of file detect-engine.c.

Referenced by DetectMetadataHashInit().

Here is the caller graph for this function:

◆ DetectEnginePktInspectionRun()

bool DetectEnginePktInspectionRun ( ThreadVars tv,
DetectEngineThreadCtx det_ctx,
const Signature s,
Flow f,
Packet p,
uint8_t *  alert_flags 
)

◆ DetectEnginePktInspectionSetup()

◆ DetectEnginePruneFreeList()

void DetectEnginePruneFreeList ( void  )

Definition at line 4732 of file detect-engine.c.

References DetectEngineCtxFree(), DetectEngineMasterCtx_::free_list, DetectEngineMasterCtx_::lock, next, DetectEngineCtx_::next, DetectEngineCtx_::ref_cnt, SCLogDebug, SCMutexLock, and SCMutexUnlock.

Referenced by DetectEngineClearMaster(), DetectEngineMTApply(), and DetectEngineReload().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineReference()

DetectEngineCtx * DetectEngineReference ( DetectEngineCtx de_ctx)

Definition at line 3868 of file detect-engine.c.

References de_ctx, and DetectEngineCtx_::ref_cnt.

Referenced by DetectEngineThreadCtxInitForReload().

Here is the caller graph for this function:

◆ DetectEngineRegisterTests()

void DetectEngineRegisterTests ( void  )

Definition at line 5295 of file detect-engine.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ DetectEngineReload()

◆ DetectEngineReloadIsIdle()

int DetectEngineReloadIsIdle ( void  )

◆ DetectEngineReloadIsStart()

int DetectEngineReloadIsStart ( void  )

Definition at line 1910 of file detect-engine.c.

References DetectEngineSyncer_::m, RELOAD, SCMutexLock, SCMutexUnlock, and DetectEngineSyncer_::state.

Referenced by SuricataMainLoop().

Here is the caller graph for this function:

◆ DetectEngineReloadSetIdle()

void DetectEngineReloadSetIdle ( void  )

Definition at line 1922 of file detect-engine.c.

References IDLE, DetectEngineSyncer_::m, SCMutexLock, SCMutexUnlock, and DetectEngineSyncer_::state.

Referenced by SuricataMainLoop().

Here is the caller graph for this function:

◆ DetectEngineReloadStart()

int DetectEngineReloadStart ( void  )

Definition at line 1896 of file detect-engine.c.

References IDLE, DetectEngineSyncer_::m, RELOAD, SCMutexLock, SCMutexUnlock, and DetectEngineSyncer_::state.

Referenced by SuricataMainLoop().

Here is the caller graph for this function:

◆ DetectEngineReloadTenantBlocking()

int DetectEngineReloadTenantBlocking ( uint32_t  tenant_id,
const char *  yaml,
int  reload_cnt 
)

Reload a tenant and wait for loading to complete.

Definition at line 4150 of file detect-engine.c.

References DetectLoadersSync().

Here is the call graph for this function:

◆ DetectEngineReloadTenantsBlocking()

int DetectEngineReloadTenantsBlocking ( const int  reload_cnt)

Reload all tenants and wait for loading to complete.

Definition at line 4164 of file detect-engine.c.

References DetectLoadersSync().

Here is the call graph for this function:

◆ DetectEngineResetMaxSigId()

void DetectEngineResetMaxSigId ( DetectEngineCtx de_ctx)

Definition at line 3053 of file detect-engine.c.

References de_ctx, and DetectEngineCtx_::signum.

Referenced by SigCleanSignatures().

Here is the caller graph for this function:

◆ DetectEngineSetEvent()

void DetectEngineSetEvent ( DetectEngineThreadCtx det_ctx,
uint8_t  e 
)

◆ DetectEngineSetParseMetadata()

void DetectEngineSetParseMetadata ( void  )

Definition at line 4970 of file detect-engine.c.

◆ DetectEngineTenantRegisterLivedev()

int DetectEngineTenantRegisterLivedev ( uint32_t  tenant_id,
int  device_id 
)

Definition at line 4579 of file detect-engine.c.

References TENANT_SELECTOR_LIVEDEV.

◆ DetectEngineTenantRegisterPcapFile()

int DetectEngineTenantRegisterPcapFile ( uint32_t  tenant_id)

Definition at line 4595 of file detect-engine.c.

References SCLogInfo, and TENANT_SELECTOR_DIRECT.

◆ DetectEngineTenantRegisterVlanId()

int DetectEngineTenantRegisterVlanId ( uint32_t  tenant_id,
uint16_t  vlan_id 
)

Definition at line 4585 of file detect-engine.c.

References TENANT_SELECTOR_VLAN.

◆ DetectEngineTenantUnregisterPcapFile()

int DetectEngineTenantUnregisterPcapFile ( uint32_t  tenant_id)

Definition at line 4601 of file detect-engine.c.

References SCLogInfo, and TENANT_SELECTOR_DIRECT.

◆ DetectEngineTenantUnregisterVlanId()

int DetectEngineTenantUnregisterVlanId ( uint32_t  tenant_id,
uint16_t  vlan_id 
)

Definition at line 4590 of file detect-engine.c.

References TENANT_SELECTOR_VLAN.

◆ DetectEngineThreadCtxDeinit()

TmEcode DetectEngineThreadCtxDeinit ( ThreadVars tv,
void *  data 
)

Definition at line 3608 of file detect-engine.c.

References HashTableFree(), DetectEngineThreadCtx_::mt_det_ctxs_hash, SCLogWarning, and TM_ECODE_OK.

Referenced by DetectEngineThreadCtxInit(), LLVMFuzzerTestOneInput(), UTHMatchPackets(), UTHMatchPacketsWithResults(), UTHPacketMatchSig(), and UTHPacketMatchSigMpm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineThreadCtxGetJsonContext()

◆ DetectEngineThreadCtxInit()

TmEcode DetectEngineThreadCtxInit ( ThreadVars tv,
void *  initdata,
void **  data 
)

initialize thread specific detection engine context

Note
there is a special case when using delayed detect. In this case the function is called twice per thread. The first time the rules are not yet loaded. de_ctx->delayed_detect_initialized will be 0. The 2nd time they will be loaded. de_ctx->delayed_detect_initialized will be 1. This is needed to do the per thread counter registration before the packet runtime starts. In delayed detect mode, the first call will return a NULL ptr through the data ptr.
Parameters
tvThreadVars for this thread
initdatapointer to de_ctx
data[out]pointer to store our thread detection ctx
Return values
TM_ECODE_OKif all went well
TM_ECODE_FAILEDon serious errors

alert counter setup

Definition at line 3372 of file detect-engine.c.

References DetectEngineThreadCtx_::counter_alerts, DetectEngineThreadCtx_::counter_alerts_overflow, DetectEngineThreadCtx_::counter_alerts_suppressed, DetectEngineThreadCtx_::counter_fnonmpm_list, DetectEngineThreadCtx_::counter_match_list, DetectEngineThreadCtx_::counter_mpm_list, DetectEngineThreadCtx_::counter_nonmpm_list, DetectEngineThreadCtx_::de_ctx, DETECT_ENGINE_TYPE_NORMAL, DETECT_ENGINE_TYPE_TENANT, DetectEngineGetCurrent(), DetectEngineMultiTenantEnabled(), DetectEngineThreadCtxDeinit(), DetectEngineThreadCtx_::json_content, DetectEngineThreadCtx_::json_content_capacity, DetectEngineThreadCtx_::json_content_len, DetectEngineThreadCtx_::lua_blocked_function_errors, DetectEngineThreadCtx_::lua_instruction_limit_errors, DetectEngineThreadCtx_::lua_memory_limit_errors, DetectEngineThreadCtx_::lua_rule_errors, RunmodeIsUnittests(), SCCalloc, StatsRegisterAvgCounter(), StatsRegisterCounter(), TM_ECODE_FAILED, TM_ECODE_OK, DetectEngineThreadCtx_::tv, tv, DetectEngineCtx_::type, and unlikely.

Referenced by UTHMatchPackets(), UTHMatchPacketsWithResults(), UTHPacketMatchSig(), and UTHPacketMatchSigMpm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectEngineThreadCtxInitForReload()

◆ DetectEngineUnsetParseMetadata()

void DetectEngineUnsetParseMetadata ( void  )

Definition at line 4975 of file detect-engine.c.

◆ DetectGetMultiData()

InspectionBuffer * DetectGetMultiData ( struct DetectEngineThreadCtx_ det_ctx,
const DetectEngineTransforms transforms,
Flow f,
const uint8_t  flow_flags,
void *  txv,
const int  list_id,
uint32_t  index,
InspectionMultiBufferGetDataPtr  GetBuf 
)

Definition at line 2133 of file detect-engine.c.

References DETECT_CI_FLAGS_SINGLE, InspectionBuffer::flags, InspectionBuffer::initialized, InspectionBufferMultipleForListGet(), InspectionBufferSetupMulti(), and InspectionBufferSetupMultiEmpty().

Referenced by DetectEngineInspectMultiBufferGeneric().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectGetSingleData()

InspectionBuffer * DetectGetSingleData ( struct DetectEngineThreadCtx_ det_ctx,
const DetectEngineTransforms transforms,
Flow f,
const uint8_t  flow_flags,
void *  txv,
const int  list_id,
InspectionSingleBufferGetDataPtr  GetBuf 
)

Definition at line 2116 of file detect-engine.c.

References InspectionBuffer::inspect, InspectionBufferGet(), and InspectionBufferSetupAndApplyTransforms().

Referenced by DetectEngineInspectBufferSingle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetectMd5ValidateCallback()

◆ DetectPktInspectEngineRegister()

◆ DetectRegisterThreadCtxFuncs()

int DetectRegisterThreadCtxFuncs ( DetectEngineCtx de_ctx,
const char *  name,
void *(*)(void *)  InitFunc,
void *  data,
void(*)(void *)  FreeFunc,
int  mode 
)

Register Thread keyword context Funcs.

Parameters
de_ctxdetection engine to register in
namekeyword name for error printing
InitFuncfunction ptr
datakeyword init data to pass to Func. Can be NULL.
FreeFuncfunction ptr
mode0 normal (ctx per keyword instance) 1 shared (one ctx per det_ct)
Return values
idfor retrieval of ctx at runtime
-1on error
Note
make sure "data" remains valid and it free'd elsewhere. It's recommended to store it in the keywords global ctx so that it's freed when the de_ctx is freed.

Definition at line 3666 of file detect-engine.c.

References BUG_ON, DetectEngineThreadKeywordCtxItem_::data, de_ctx, DetectEngineThreadKeywordCtxItem_::FreeFunc, HashListTableAdd(), HashListTableInit(), HashListTableLookup(), DetectEngineThreadKeywordCtxItem_::id, DetectEngineThreadKeywordCtxItem_::InitFunc, DetectEngineCtx_::keyword_hash, DetectEngineCtx_::keyword_id, DetectEngineThreadKeywordCtxItem_::name, name, SCCalloc, SCFree, and unlikely.

Here is the call graph for this function:

◆ DetectRegisterThreadCtxGlobalFuncs()

int DetectRegisterThreadCtxGlobalFuncs ( const char *  name,
void *(*)(void *)  InitFunc,
void *  data,
void(*)(void *)  FreeFunc 
)

Register Thread keyword context Funcs (Global)

IDs stay static over reloads and between tenants

Parameters
namekeyword name for error printing
InitFuncfunction ptr
FreeFuncfunction ptr
Return values
idfor retrieval of ctx at runtime
-1on error

Definition at line 3756 of file detect-engine.c.

References BUG_ON, DetectEngineThreadKeywordCtxItem_::data, DetectEngineThreadKeywordCtxItem_::FreeFunc, id, DetectEngineThreadKeywordCtxItem_::id, DetectEngineThreadKeywordCtxItem_::InitFunc, DetectEngineMasterCtx_::keyword_id, DetectEngineMasterCtx_::keyword_list, DetectEngineThreadKeywordCtxItem_::name, name, DetectEngineThreadKeywordCtxItem_::next, SCCalloc, and unlikely.

Referenced by DetectHttpHeaderNamesRegister(), DetectHttpHeaderRegister(), DetectHttpRequestHeaderRegister(), DetectHttpResponseHeaderRegister(), and DetectHttpStartRegister().

Here is the caller graph for this function:

◆ DetectSigmatchListEnumToString()

◆ DetectTableToString()

◆ DetectThreadCtxGetGlobalKeywordThreadCtx()

void * DetectThreadCtxGetGlobalKeywordThreadCtx ( DetectEngineThreadCtx det_ctx,
int  id 
)

Retrieve thread local keyword ctx by id.

Parameters
det_ctxdetection engine thread ctx to retrieve the ctx from
idid of the ctx returned by DetectRegisterThreadCtxInitFunc at keyword init.
Return values
ctxor NULL on error

Definition at line 3800 of file detect-engine.c.

References DetectEngineThreadCtx_::global_keyword_ctxs_array, DetectEngineThreadCtx_::global_keyword_ctxs_size, and id.

Referenced by HttpHeaderGetBufferSpace().

Here is the caller graph for this function:

◆ DetectThreadCtxGetKeywordThreadCtx()

void * DetectThreadCtxGetKeywordThreadCtx ( DetectEngineThreadCtx det_ctx,
int  id 
)

Retrieve thread local keyword ctx by id.

Parameters
det_ctxdetection engine thread ctx to retrieve the ctx from
idid of the ctx returned by DetectRegisterThreadCtxInitFunc at keyword init.
Return values
ctxor NULL on error

Definition at line 3736 of file detect-engine.c.

References id, DetectEngineThreadCtx_::keyword_ctxs_array, and DetectEngineThreadCtx_::keyword_ctxs_size.

Referenced by DetectLuaMatchBuffer(), and DetectPcrePayloadMatch().

Here is the caller graph for this function:

◆ DetectUnregisterThreadCtxFuncs()

int DetectUnregisterThreadCtxFuncs ( DetectEngineCtx de_ctx,
void *  data,
const char *  name 
)

Remove Thread keyword context registration.

Parameters
de_ctxdetection engine to deregister from
det_ctxdetection engine thread context to deregister from
datakeyword init data to pass to Func. Can be NULL.
namekeyword name for error printing
Return values
1Item unregistered
0otherwise
Note
make sure "data" remains valid and it free'd elsewhere. It's recommended to store it in the keywords global ctx so that it's freed when the de_ctx is freed.

Definition at line 3718 of file detect-engine.c.

References DetectEngineThreadKeywordCtxItem_::data, de_ctx, HashListTableRemove(), DetectEngineCtx_::keyword_hash, and name.

Here is the call graph for this function:

◆ InjectPacketsForFlush()

void InjectPacketsForFlush ( ThreadVars **  detect_tvs,
int  no_of_detect_tvs 
)

◆ SCDetectEngineRegisterRateFilterCallback()

void SCDetectEngineRegisterRateFilterCallback ( SCDetectRateFilterFunc  cb,
void *  arg 
)

Register a callback when a rate_filter has been applied to an alert.

This callback is added to the current detection engine and will be copied to all future detection engines over rule reloads.

Definition at line 5061 of file detect-engine.c.

References de_ctx, DetectEngineDeReference(), DetectEngineGetCurrent(), DetectEngineCtx_::rate_filter_callback_arg, and DetectEngineCtx_::RateFilterCallback.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ signature_properties