suricata
detect-engine-analyzer.c File Reference
#include "suricata-common.h"
#include "suricata.h"
#include "rust.h"
#include "detect.h"
#include "detect-parse.h"
#include "detect-engine.h"
#include "detect-engine-analyzer.h"
#include "detect-engine-mpm.h"
#include "conf.h"
#include "detect-content.h"
#include "detect-flow.h"
#include "detect-tcp-flags.h"
#include "feature.h"
#include "util-print.h"
#include "util-time.h"
#include "util-validate.h"
#include "util-conf.h"
Include dependency graph for detect-engine-analyzer.c:

Go to the source code of this file.

Data Structures

struct  FpPatternStats_
 
struct  DetectEngineAnalyzerItems
 
struct  ExposedItemSeen
 
struct  RuleAnalyzer
 

Macros

#define DETECT_PERCENT_ENCODING_REGEX   "%[0-9|a-f|A-F]{2}"
 
#define CHECK(pat)   if (strlen((pat)) <= len && memcmp((pat), buf, MIN(len, strlen((pat)))) == 0) return true;
 

Typedefs

typedef struct FpPatternStats_ FpPatternStats
 
typedef struct DetectEngineAnalyzerItems DetectEngineAnalyzerItems
 
typedef struct RuleAnalyzer RuleAnalyzer
 

Functions

void EngineAnalysisFP (const DetectEngineCtx *de_ctx, const Signature *s, char *line)
 
int SetupFPAnalyzer (void)
 Sets up the fast pattern analyzer according to the config. More...
 
int SetupRuleAnalyzer (void)
 Sets up the rule analyzer according to the config. More...
 
void CleanupFPAnalyzer (void)
 
void CleanupRuleAnalyzer (void)
 
int PerCentEncodingSetup ()
 Compiles regex for rule analysis. More...
 
void EngineAnalysisRulesFailure (char *line, char *file, int lineno)
 
void EngineAnalysisRules2 (const DetectEngineCtx *de_ctx, const Signature *s)
 
void DumpPatterns (DetectEngineCtx *de_ctx)
 
void EngineAnalysisRules (const DetectEngineCtx *de_ctx, const Signature *s, const char *line)
 Prints analysis of loaded rules. More...
 

Variables

DetectEngineAnalyzerItems analyzer_items []
 
int16_t analyzer_item_map [256]
 
struct ExposedItemSeen exposed_item_seen_list []
 
SCMutex g_rules_analyzer_write_m = SCMUTEX_INITIALIZER
 

Detailed Description

Author
Eileen Donlon emdon.nosp@m.lo@g.nosp@m.mail..nosp@m.com
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Rule analyzers for the detection engine

Definition in file detect-engine-analyzer.c.

Macro Definition Documentation

◆ CHECK

#define CHECK (   pat)    if (strlen((pat)) <= len && memcmp((pat), buf, MIN(len, strlen((pat)))) == 0) return true;

Definition at line 600 of file detect-engine-analyzer.c.

◆ DETECT_PERCENT_ENCODING_REGEX

#define DETECT_PERCENT_ENCODING_REGEX   "%[0-9|a-f|A-F]{2}"

Typedef Documentation

◆ DetectEngineAnalyzerItems

◆ FpPatternStats

◆ RuleAnalyzer

typedef struct RuleAnalyzer RuleAnalyzer

Function Documentation

◆ CleanupFPAnalyzer()

void CleanupFPAnalyzer ( void  )

Definition at line 393 of file detect-engine-analyzer.c.

◆ CleanupRuleAnalyzer()

void CleanupRuleAnalyzer ( void  )

Definition at line 417 of file detect-engine-analyzer.c.

◆ DumpPatterns()

◆ EngineAnalysisFP()

◆ EngineAnalysisRules()

void EngineAnalysisRules ( const DetectEngineCtx de_ctx,
const Signature s,
const char *  line 
)

Prints analysis of loaded rules.

   Warns if potential rule issues are detected. For example,
   warns if a rule uses a construct that may perform poorly,
   e.g. pcre without content or with http_method content only;
   warns if a rule uses a construct that may not be consistent with intent,
   e.g. client side ports only, http and content without any http_* modifiers, etc.
Parameters
sPointer to the signature.

Definition at line 1114 of file detect-engine-analyzer.c.

◆ EngineAnalysisRules2()

◆ EngineAnalysisRulesFailure()

void EngineAnalysisRulesFailure ( char *  line,
char *  file,
int  lineno 
)

Definition at line 552 of file detect-engine-analyzer.c.

◆ PerCentEncodingSetup()

int PerCentEncodingSetup ( )

Compiles regex for rule analysis.

Return values
1if successful
0if on error

Definition at line 435 of file detect-engine-analyzer.c.

◆ SetupFPAnalyzer()

int SetupFPAnalyzer ( void  )

Sets up the fast pattern analyzer according to the config.

Return values
1If rule analyzer successfully enabled.
0If not enabled.

Definition at line 287 of file detect-engine-analyzer.c.

◆ SetupRuleAnalyzer()

int SetupRuleAnalyzer ( void  )

Sets up the rule analyzer according to the config.

Return values
1if rule analyzer successfully enabled
0if not enabled

Definition at line 337 of file detect-engine-analyzer.c.

References ConfGetNode(), ConfNodeLookupChildValue(), and ConfValIsTrue().

Here is the call graph for this function:

Variable Documentation

◆ analyzer_item_map

int16_t analyzer_item_map[256]

Definition at line 122 of file detect-engine-analyzer.c.

◆ analyzer_items

DetectEngineAnalyzerItems analyzer_items[]

Definition at line 75 of file detect-engine-analyzer.c.

◆ exposed_item_seen_list

struct ExposedItemSeen exposed_item_seen_list[]
Initial value:
= {
{ .bufname = "http_method"},
{ .bufname = "file_data"}
}

Definition at line 122 of file detect-engine-analyzer.c.

◆ g_rules_analyzer_write_m

SCMutex g_rules_analyzer_write_m = SCMUTEX_INITIALIZER

Definition at line 689 of file detect-engine-analyzer.c.

Referenced by DumpPatterns().