suricata
detect-engine-build.c File Reference
Include dependency graph for detect-engine-build.c:

Go to the source code of this file.

Data Structures

struct  UniquePortPoint_
 

Macros

#define DETECT_PGSCORE_RULE_PORT_PRIORITIZED   111 /* Rule port group contains a priority port */
 
#define DETECT_PGSCORE_RULE_MPM_FAST_PATTERN   99 /* Rule contains an MPM fast pattern */
 
#define DETECT_PGSCORE_RULE_MPM_NEGATED   77 /* Rule contains a negated MPM */
 
#define DETECT_PGSCORE_RULE_NO_MPM   55 /* Rule does not contain MPM */
 
#define DETECT_PGSCORE_RULE_SYN_ONLY   33 /* Rule needs SYN check */
 
#define MASK_TCP_INITDEINIT_FLAGS   (TH_SYN|TH_RST|TH_FIN)
 
#define MASK_TCP_UNUSUAL_FLAGS   (TH_URG|TH_ECN|TH_CWR)
 
#define UNDEFINED_PORT   0
 
#define RANGE_PORT   1
 
#define SINGLE_PORT   2
 

Typedefs

typedef struct UniquePortPoint_ UniquePortPoint
 

Functions

void SigCleanSignatures (DetectEngineCtx *de_ctx)
 
SignatureSigFindSignatureBySidGid (DetectEngineCtx *de_ctx, uint32_t sid, uint32_t gid)
 Find a specific signature by sid and gid.
 
int SignatureIsFilestoring (const Signature *s)
 Check if a signature contains the filestore keyword.
 
int SignatureIsFilemagicInspecting (const Signature *s)
 Check if a signature contains the filemagic keyword.
 
int SignatureIsFileMd5Inspecting (const Signature *s)
 Check if a signature contains the filemd5 keyword.
 
int SignatureIsFileSha1Inspecting (const Signature *s)
 Check if a signature contains the filesha1 keyword.
 
int SignatureIsFileSha256Inspecting (const Signature *s)
 Check if a signature contains the filesha256 keyword.
 
int SignatureIsFilesizeInspecting (const Signature *s)
 Check if a signature contains the filesize keyword.
 
int SignatureIsIPOnly (DetectEngineCtx *de_ctx, const Signature *s)
 Test is a initialized signature is IP only.
 
void PacketCreateMask (Packet *p, SignatureMask *mask, AppProto alproto, bool app_decoder_events)
 
void SignatureSetType (DetectEngineCtx *de_ctx, Signature *s)
 
int SigPrepareStage1 (DetectEngineCtx *de_ctx)
 Preprocess signature, classify ip-only, etc, build sig array.
 
int SigPrepareStage2 (DetectEngineCtx *de_ctx)
 Fill the global src group head, with the sigs included.
 
int SigPrepareStage3 (DetectEngineCtx *de_ctx)
 
int SigAddressCleanupStage1 (DetectEngineCtx *de_ctx)
 
int SigPrepareStage4 (DetectEngineCtx *de_ctx)
 finalize preparing sgh's
 
int SigGroupBuild (DetectEngineCtx *de_ctx)
 Convert the signature list into the runtime match structure.
 
int SigGroupCleanup (DetectEngineCtx *de_ctx)
 

Variables

bool rule_engine_analysis_set
 

Macro Definition Documentation

◆ DETECT_PGSCORE_RULE_MPM_FAST_PATTERN

#define DETECT_PGSCORE_RULE_MPM_FAST_PATTERN   99 /* Rule contains an MPM fast pattern */

Definition at line 51 of file detect-engine-build.c.

◆ DETECT_PGSCORE_RULE_MPM_NEGATED

#define DETECT_PGSCORE_RULE_MPM_NEGATED   77 /* Rule contains a negated MPM */

Definition at line 52 of file detect-engine-build.c.

◆ DETECT_PGSCORE_RULE_NO_MPM

#define DETECT_PGSCORE_RULE_NO_MPM   55 /* Rule does not contain MPM */

Definition at line 53 of file detect-engine-build.c.

◆ DETECT_PGSCORE_RULE_PORT_PRIORITIZED

#define DETECT_PGSCORE_RULE_PORT_PRIORITIZED   111 /* Rule port group contains a priority port */

Definition at line 50 of file detect-engine-build.c.

◆ DETECT_PGSCORE_RULE_SYN_ONLY

#define DETECT_PGSCORE_RULE_SYN_ONLY   33 /* Rule needs SYN check */

Definition at line 54 of file detect-engine-build.c.

◆ MASK_TCP_INITDEINIT_FLAGS

#define MASK_TCP_INITDEINIT_FLAGS   (TH_SYN|TH_RST|TH_FIN)

Definition at line 414 of file detect-engine-build.c.

◆ MASK_TCP_UNUSUAL_FLAGS

#define MASK_TCP_UNUSUAL_FLAGS   (TH_URG|TH_ECN|TH_CWR)

Definition at line 415 of file detect-engine-build.c.

◆ RANGE_PORT

#define RANGE_PORT   1

Definition at line 1325 of file detect-engine-build.c.

◆ SINGLE_PORT

#define SINGLE_PORT   2

Definition at line 1326 of file detect-engine-build.c.

◆ UNDEFINED_PORT

#define UNDEFINED_PORT   0

Definition at line 1324 of file detect-engine-build.c.

Typedef Documentation

◆ UniquePortPoint

Function Documentation

◆ PacketCreateMask()

◆ SigAddressCleanupStage1()

◆ SigCleanSignatures()

void SigCleanSignatures ( DetectEngineCtx de_ctx)

Definition at line 56 of file detect-engine-build.c.

References de_ctx, DetectEngineResetMaxSigId(), Signature_::next, DetectEngineCtx_::sig_list, and SigFree().

Referenced by DetectEngineCtxFree(), and UTHPacketMatchSig().

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

◆ SigFindSignatureBySidGid()

Signature * SigFindSignatureBySidGid ( DetectEngineCtx de_ctx,
uint32_t  sid,
uint32_t  gid 
)

Find a specific signature by sid and gid.

Parameters
de_ctxdetection engine ctx
sidthe signature id
gidthe signature group id
Return values
ssig found
NULLsig not found

Definition at line 80 of file detect-engine-build.c.

References de_ctx, and DetectEngineCtx_::sig_list.

◆ SigGroupBuild()

◆ SigGroupCleanup()

int SigGroupCleanup ( DetectEngineCtx de_ctx)

Definition at line 2275 of file detect-engine-build.c.

References de_ctx, and SigAddressCleanupStage1().

Referenced by DetectEngineCtxFree(), UTHMatchPackets(), and UTHPacketMatchSig().

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

◆ SignatureIsFilemagicInspecting()

int SignatureIsFilemagicInspecting ( const Signature s)

Check if a signature contains the filemagic keyword.

Parameters
ssignature
Return values
0no
1yes

Definition at line 120 of file detect-engine-build.c.

References Signature_::file_flags, and FILE_SIG_NEED_MAGIC.

Referenced by SigGroupHeadSetupFiles().

Here is the caller graph for this function:

◆ SignatureIsFileMd5Inspecting()

int SignatureIsFileMd5Inspecting ( const Signature s)

Check if a signature contains the filemd5 keyword.

Parameters
ssignature
Return values
0no
1yes

Definition at line 139 of file detect-engine-build.c.

References Signature_::file_flags, and FILE_SIG_NEED_MD5.

Referenced by SigGroupHeadSetupFiles().

Here is the caller graph for this function:

◆ SignatureIsFileSha1Inspecting()

int SignatureIsFileSha1Inspecting ( const Signature s)

Check if a signature contains the filesha1 keyword.

Parameters
ssignature
Return values
0no
1yes

Definition at line 155 of file detect-engine-build.c.

References Signature_::file_flags, and FILE_SIG_NEED_SHA1.

Referenced by SigGroupHeadSetupFiles().

Here is the caller graph for this function:

◆ SignatureIsFileSha256Inspecting()

int SignatureIsFileSha256Inspecting ( const Signature s)

Check if a signature contains the filesha256 keyword.

Parameters
ssignature
Return values
0no
1yes

Definition at line 171 of file detect-engine-build.c.

References Signature_::file_flags, and FILE_SIG_NEED_SHA256.

Referenced by SigGroupHeadSetupFiles().

Here is the caller graph for this function:

◆ SignatureIsFilesizeInspecting()

int SignatureIsFilesizeInspecting ( const Signature s)

Check if a signature contains the filesize keyword.

Parameters
ssignature
Return values
0no
1yes

Definition at line 187 of file detect-engine-build.c.

References Signature_::file_flags, and FILE_SIG_NEED_SIZE.

Referenced by SigGroupHeadSetupFiles().

Here is the caller graph for this function:

◆ SignatureIsFilestoring()

int SignatureIsFilestoring ( const Signature s)

Check if a signature contains the filestore keyword.

Parameters
ssignature
Return values
0no
1yes

Definition at line 101 of file detect-engine-build.c.

References Signature_::flags, and SIG_FLAG_FILESTORE.

Referenced by SigGroupHeadSetupFiles().

Here is the caller graph for this function:

◆ SignatureIsIPOnly()

◆ SignatureSetType()

◆ SigPrepareStage1()

◆ SigPrepareStage2()

int SigPrepareStage2 ( DetectEngineCtx de_ctx)

Fill the global src group head, with the sigs included.

Parameters
de_ctxPointer to the Detection Engine Context whose Signatures have to be processed
Return values
0On success
-1On failure

Definition at line 1887 of file detect-engine-build.c.

References de_ctx, DetectEngineCtx_::flow_gh, SignatureInitData_::hook, Signature_::id, Signature_::init_data, DetectEngineCtx_::io_ctx, IPOnlyAddSignature(), IPOnlyInit(), IPOnlyPrepare(), IPOnlyPrint(), Signature_::next, SignatureHook_::ph, SignatureHook_::pkt, SCLogDebug, SIG_FLAG_TOCLIENT, SIG_FLAG_TOSERVER, DetectEngineCtx_::sig_list, SIG_TYPE_DEONLY, SIG_TYPE_IPONLY, SIG_TYPE_PKT, SIGNATURE_HOOK_PKT_PRE_FLOW, SIGNATURE_HOOK_PKT_PRE_STREAM, SIGNATURE_HOOK_TYPE_PKT, SignatureHook_::t, DetectEngineLookupFlow_::tcp, SignatureHook_::type, Signature_::type, and DetectEngineLookupFlow_::udp.

Referenced by SigGroupBuild().

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

◆ SigPrepareStage3()

int SigPrepareStage3 ( DetectEngineCtx de_ctx)

Definition at line 1963 of file detect-engine-build.c.

References de_ctx.

Referenced by SigGroupBuild().

Here is the caller graph for this function:

◆ SigPrepareStage4()

Variable Documentation

◆ rule_engine_analysis_set

bool rule_engine_analysis_set
extern

Definition at line 56 of file detect-engine-loader.c.