]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
8 years agodoc: prefilter keyword and config 2310/head
Victor Julien [Thu, 29 Sep 2016 12:17:22 +0000 (14:17 +0200)] 
doc: prefilter keyword and config

8 years agohttp_header: don't separately inspect trailer yet
Victor Julien [Wed, 28 Sep 2016 06:46:27 +0000 (08:46 +0200)] 
http_header: don't separately inspect trailer yet

Currently the regular 'Header' inspection code will run each time
after the HTTP progress moved beyond 'headers'. This will include
the trailers if there are any.

Leave the code in place as this model will change in the not too
distant future.

8 years agohttp_header: only run trailer mpm if we have trailers
Victor Julien [Tue, 27 Sep 2016 15:24:02 +0000 (17:24 +0200)] 
http_header: only run trailer mpm if we have trailers

8 years agohttp: track if request/response have trailers
Victor Julien [Tue, 27 Sep 2016 15:16:38 +0000 (17:16 +0200)] 
http: track if request/response have trailers

8 years agoprefilter: use array of engines per sgh
Victor Julien [Tue, 27 Sep 2016 11:46:08 +0000 (13:46 +0200)] 
prefilter: use array of engines per sgh

Instead of the linked list of engines setup an array
with the engines. This should provide better locality.

Also shrink the engine structure so that we can fit
2 on a cacheline.

Remove the FreeFunc from the runtime engines. Engines
now have a 'gid' (global id) that can be used to look
up the registered Free function.

8 years agoprefilter: clean up setup code
Victor Julien [Tue, 27 Sep 2016 09:56:58 +0000 (11:56 +0200)] 
prefilter: clean up setup code

8 years agodetect: reshuffle keyword registration order
Victor Julien [Fri, 23 Sep 2016 09:25:38 +0000 (11:25 +0200)] 
detect: reshuffle keyword registration order

The order of keyword registration currently affects inspect engine
registration order and ultimately the order of inspect engines per
rule. Which in turn affects state keeping.

This patch makes sure the ordering is the same as with older
releases.

8 years agodetect: clean up inspect engine registration
Victor Julien [Fri, 23 Sep 2016 08:01:02 +0000 (10:01 +0200)] 
detect: clean up inspect engine registration

8 years agodetect app-layer-event: clean up registration
Victor Julien [Fri, 23 Sep 2016 07:56:23 +0000 (09:56 +0200)] 
detect app-layer-event: clean up registration

Move engine and registration into the keyword file.

Register as 'ALPROTO_UNKNOWN' instead of per alproto. The
registration will only apply it to those rules that have
events set.

8 years agodetect: remove empty app registration table
Victor Julien [Fri, 23 Sep 2016 07:37:54 +0000 (09:37 +0200)] 
detect: remove empty app registration table

8 years agotemplate_buffer: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 07:35:53 +0000 (09:35 +0200)] 
template_buffer: register inspect engine from keyword

8 years agofile detect: register inspect engines from keyword
Victor Julien [Fri, 23 Sep 2016 07:21:07 +0000 (09:21 +0200)] 
file detect: register inspect engines from keyword

8 years agomodbus detect: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 07:11:33 +0000 (09:11 +0200)] 
modbus detect: register inspect engine from keyword

8 years agodns detect: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 07:02:38 +0000 (09:02 +0200)] 
dns detect: register inspect engine from keyword

8 years agotls_cert_issuer: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 06:47:00 +0000 (08:47 +0200)] 
tls_cert_issuer: register inspect engine from keyword

8 years agotls_cert_subject: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 06:45:29 +0000 (08:45 +0200)] 
tls_cert_subject: register inspect engine from keyword

8 years agotls_sni: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 06:43:25 +0000 (08:43 +0200)] 
tls_sni: register inspect engine from keyword

8 years agohttp_stat_code: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 06:38:37 +0000 (08:38 +0200)] 
http_stat_code: register inspect engine from keyword

8 years agohttp_stat_msg: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 06:30:57 +0000 (08:30 +0200)] 
http_stat_msg: register inspect engine from keyword

8 years agofile_data: register inspect engine from keyword
Victor Julien [Fri, 23 Sep 2016 06:20:51 +0000 (08:20 +0200)] 
file_data: register inspect engine from keyword

8 years agohttp_raw_host: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 16:05:52 +0000 (18:05 +0200)] 
http_raw_host: register inspect engine from keyword

8 years agohttp_host: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:51:25 +0000 (17:51 +0200)] 
http_host: register inspect engine from keyword

8 years agohttp_user_agent: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:47:54 +0000 (17:47 +0200)] 
http_user_agent: register inspect engine from keyword

8 years agohttp_raw_uri: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:39:06 +0000 (17:39 +0200)] 
http_raw_uri: register inspect engine from keyword

8 years agohttp_cookie: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:35:59 +0000 (17:35 +0200)] 
http_cookie: register inspect engine from keyword

8 years agohttp_method: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:33:20 +0000 (17:33 +0200)] 
http_method: register inspect engine from keyword

8 years agohttp_raw_header: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:27:57 +0000 (17:27 +0200)] 
http_raw_header: register inspect engine from keyword

8 years agohttp_header: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:22:20 +0000 (17:22 +0200)] 
http_header: register inspect engine from keyword

8 years agohttp_client_body: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:19:05 +0000 (17:19 +0200)] 
http_client_body: register inspect engine from keyword

8 years agohttp_uri: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:13:03 +0000 (17:13 +0200)] 
http_uri: register inspect engine from keyword

8 years agohttp_response_line: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:06:43 +0000 (17:06 +0200)] 
http_response_line: register inspect engine from keyword

8 years agohttp_request_line: register inspect engine from keyword
Victor Julien [Thu, 22 Sep 2016 15:02:39 +0000 (17:02 +0200)] 
http_request_line: register inspect engine from keyword

8 years agodetect-engine: new registration call
Victor Julien [Thu, 22 Sep 2016 15:00:29 +0000 (17:00 +0200)] 
detect-engine: new registration call

Make it more in line with MPM registration.

8 years agodetect mpm: small optimization
Victor Julien [Thu, 22 Sep 2016 07:09:11 +0000 (09:09 +0200)] 
detect mpm: small optimization

8 years agodetect-mpm: cleanup
Victor Julien [Wed, 21 Sep 2016 20:50:13 +0000 (22:50 +0200)] 
detect-mpm: cleanup

8 years agodetect-engine: improved inspect engines
Victor Julien [Wed, 21 Sep 2016 15:43:41 +0000 (17:43 +0200)] 
detect-engine: improved inspect engines

Inspect engines are called per signature per sigmatch list. Most
wrap around DetectEngineContentInspection, but it's more generic.

Until now, the inspect engines were setup in a large per ipproto,
per alproto, per direction table. For stateful inspection each
engine needed a global flag.

This approach had a number of issues:
1. inefficient: each inspection round walked the table and then
   checked if the inspect engine was even needed for the current
   rule.
2. clumsy registration with global flag registration.
3. global flag space was approaching the need for 64 bits
4. duplicate registration for alprotos supporting both TCP and
   TCP (DNS).

This patch introduces a new approach.

First, it does away with the per ipproto engines. This wasn't used.

Second, it adds a per signature list of inspect engine containing
only those engines that actually apply to the rule.

Third, it gets rid of the global flags and replaces it with flags
assigned per rule per engine.

8 years agodetect state: reorganize flags
Victor Julien [Wed, 21 Sep 2016 14:17:20 +0000 (16:17 +0200)] 
detect state: reorganize flags

List the common non-buffer specific flags on top.

8 years agohttp_response_body: implement keyword with mpm
Victor Julien [Thu, 8 Sep 2016 13:19:40 +0000 (15:19 +0200)] 
http_response_body: implement keyword with mpm

Implemented as 'stickybuffer'.

8 years agohttp_request_line: implement keyword and mpm
Victor Julien [Thu, 8 Sep 2016 10:35:44 +0000 (12:35 +0200)] 
http_request_line: implement keyword and mpm

Implemented as 'stickybuffer'.

Move all logic into the keyword file and remove bad tests that tested
URI instead of request line.

8 years agofast_pattern: register app layer mpms automatically
Victor Julien [Sat, 17 Sep 2016 12:44:09 +0000 (14:44 +0200)] 
fast_pattern: register app layer mpms automatically

Allow for duplicate registrations for the same list. After the first
registration new calls will be ignored.

8 years agompm: remove empty app_mpms table
Victor Julien [Sat, 17 Sep 2016 11:08:16 +0000 (13:08 +0200)] 
mpm: remove empty app_mpms table

8 years agotls: register mpm from keywords
Victor Julien [Sat, 17 Sep 2016 11:06:32 +0000 (13:06 +0200)] 
tls: register mpm from keywords

8 years agodns_query: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 11:05:18 +0000 (13:05 +0200)] 
dns_query: register mpm from keyword

8 years agohttp_cookie: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 11:03:39 +0000 (13:03 +0200)] 
http_cookie: register mpm from keyword

8 years agohttp_raw_host: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 11:01:32 +0000 (13:01 +0200)] 
http_raw_host: register mpm from keyword

8 years agohttp_host: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 10:26:17 +0000 (12:26 +0200)] 
http_host: register mpm from keyword

8 years agohttp_client_body: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 10:22:59 +0000 (12:22 +0200)] 
http_client_body: register mpm from keyword

8 years agohttp_stat_code: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 10:21:22 +0000 (12:21 +0200)] 
http_stat_code: register mpm from keyword

8 years agohttp_stat_msg: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:49:17 +0000 (11:49 +0200)] 
http_stat_msg: register mpm from keyword

8 years agofile_data: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:47:29 +0000 (11:47 +0200)] 
file_data: register mpm from keyword

8 years agohttp_method: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:43:08 +0000 (11:43 +0200)] 
http_method: register mpm from keyword

8 years agohttp_raw_header: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:41:35 +0000 (11:41 +0200)] 
http_raw_header: register mpm from keyword

8 years agohttp_user_agent: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:39:46 +0000 (11:39 +0200)] 
http_user_agent: register mpm from keyword

8 years agohttp_header: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:37:30 +0000 (11:37 +0200)] 
http_header: register mpm from keyword

8 years agohttp_raw_uri: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:33:16 +0000 (11:33 +0200)] 
http_raw_uri: register mpm from keyword

8 years agohttp_uri: register mpm from keyword
Victor Julien [Sat, 17 Sep 2016 09:28:25 +0000 (11:28 +0200)] 
http_uri: register mpm from keyword

8 years agompm: add App Layer MPM registery
Victor Julien [Fri, 16 Sep 2016 16:52:59 +0000 (18:52 +0200)] 
mpm: add App Layer MPM registery

Register keywords globally at start up.

Create a map of the registery per detection engine. This we need because
the sgh_mpm_context value is set per detect engine.

Remove APP_MPMS_MAX.

8 years agodetect: simplify content inspection types
Victor Julien [Wed, 14 Sep 2016 21:12:08 +0000 (23:12 +0200)] 
detect: simplify content inspection types

Instead of a type per buffer type, pass just 3 possible types:
packet, stream, state.

The individual types weren't used. State is just there to be
not packet and not stream.

8 years agoprefilter: cleanup and optimization
Victor Julien [Fri, 26 Aug 2016 16:49:17 +0000 (18:49 +0200)] 
prefilter: cleanup and optimization

8 years agoprofiling: more prefilter profiling
Victor Julien [Thu, 25 Aug 2016 16:36:26 +0000 (18:36 +0200)] 
profiling: more prefilter profiling

8 years agodetect: config opt to enable keyword prefilters
Victor Julien [Fri, 26 Aug 2016 14:10:59 +0000 (16:10 +0200)] 
detect: config opt to enable keyword prefilters

8 years agoprefilter: in profiling print totals
Victor Julien [Fri, 26 Aug 2016 12:24:16 +0000 (14:24 +0200)] 
prefilter: in profiling print totals

8 years agoprefilter: alloc CLS aligned memory
Victor Julien [Fri, 26 Aug 2016 10:45:47 +0000 (12:45 +0200)] 
prefilter: alloc CLS aligned memory

8 years agodetect mpm: consider sgh direction when adding rules
Victor Julien [Fri, 26 Aug 2016 08:14:06 +0000 (10:14 +0200)] 
detect mpm: consider sgh direction when adding rules

8 years agoprefilter: move payload engines into separate list
Victor Julien [Thu, 25 Aug 2016 15:55:33 +0000 (17:55 +0200)] 
prefilter: move payload engines into separate list

8 years agodetect-ack: extra match support
Victor Julien [Thu, 25 Aug 2016 13:13:25 +0000 (15:13 +0200)] 
detect-ack: extra match support

8 years agodetect-seq: extra match support
Victor Julien [Thu, 25 Aug 2016 13:13:16 +0000 (15:13 +0200)] 
detect-seq: extra match support

8 years agodetect-ttl: extra match support
Victor Julien [Thu, 25 Aug 2016 13:12:59 +0000 (15:12 +0200)] 
detect-ttl: extra match support

8 years agodetect-id: extra match support
Victor Julien [Thu, 25 Aug 2016 13:12:51 +0000 (15:12 +0200)] 
detect-id: extra match support

8 years agodetect-dsize: extra match support
Victor Julien [Thu, 25 Aug 2016 13:12:39 +0000 (15:12 +0200)] 
detect-dsize: extra match support

8 years agodetect-flags: prefilter extra match support
Victor Julien [Thu, 25 Aug 2016 11:04:25 +0000 (13:04 +0200)] 
detect-flags: prefilter extra match support

8 years agodetect-flow: prefilter extra match support
Victor Julien [Thu, 25 Aug 2016 11:04:15 +0000 (13:04 +0200)] 
detect-flow: prefilter extra match support

8 years agoprefilter: add 'extra match' logic to packet engines
Victor Julien [Thu, 25 Aug 2016 10:59:33 +0000 (12:59 +0200)] 
prefilter: add 'extra match' logic to packet engines

Many of the packet engines are very generic. Rules are generally more
limited.

A rule like 'alert tcp any any -> any 888 (flags:S; sid:1;)' would still
be inspected against every SYN packet in most cases (it depends a bit on
rule grouping though).

This extra match logic adds an additional check to these packet engines.
It can add a check based on alproto, source port and dest port. It uses
only one of these 3. Priority order is src port > alproto > dst port.

For the ports only 'single' ports are used at this time.

8 years agodetect mpm: negated setup fix
Victor Julien [Tue, 23 Aug 2016 14:47:35 +0000 (16:47 +0200)] 
detect mpm: negated setup fix

8 years agodetect-icmp-id: prefilter
Victor Julien [Mon, 22 Aug 2016 16:44:08 +0000 (18:44 +0200)] 
detect-icmp-id: prefilter

8 years agodetect-icmp-seq: prefilter
Victor Julien [Mon, 22 Aug 2016 16:44:00 +0000 (18:44 +0200)] 
detect-icmp-seq: prefilter

8 years agodetect-icode: implement as u8 hash prefilter
Victor Julien [Mon, 22 Aug 2016 14:29:48 +0000 (16:29 +0200)] 
detect-icode: implement as u8 hash prefilter

8 years agodetect-itype: implement as u8 hash prefilter
Victor Julien [Mon, 22 Aug 2016 13:21:55 +0000 (15:21 +0200)] 
detect-itype: implement as u8 hash prefilter

8 years agodetect-id: implement prefilter
Victor Julien [Sat, 20 Aug 2016 15:02:13 +0000 (17:02 +0200)] 
detect-id: implement prefilter

8 years agodetect-icode: implement prefilter
Victor Julien [Sat, 20 Aug 2016 14:26:37 +0000 (16:26 +0200)] 
detect-icode: implement prefilter

8 years agodetect-itype: implement prefilter
Victor Julien [Sat, 20 Aug 2016 13:59:22 +0000 (15:59 +0200)] 
detect-itype: implement prefilter

8 years agodetect-ttl: implement prefilter
Victor Julien [Sat, 20 Aug 2016 11:25:37 +0000 (13:25 +0200)] 
detect-ttl: implement prefilter

8 years agodetect-seq: implement prefilter
Victor Julien [Sat, 20 Aug 2016 11:11:01 +0000 (13:11 +0200)] 
detect-seq: implement prefilter

8 years agodetect-flow: implement prefilter
Victor Julien [Sat, 20 Aug 2016 11:05:09 +0000 (13:05 +0200)] 
detect-flow: implement prefilter

8 years agoprefilter: implement basic prefilter priority order
Victor Julien [Sat, 20 Aug 2016 11:04:22 +0000 (13:04 +0200)] 
prefilter: implement basic prefilter priority order

8 years agodetect-fragoffset: implement prefilter
Victor Julien [Sat, 20 Aug 2016 09:00:43 +0000 (11:00 +0200)] 
detect-fragoffset: implement prefilter

8 years agodetect analyzer: give minimal prefilter info
Victor Julien [Fri, 19 Aug 2016 15:04:51 +0000 (17:04 +0200)] 
detect analyzer: give minimal prefilter info

8 years agodetect-dsize: enable prefilter support
Victor Julien [Fri, 19 Aug 2016 14:34:38 +0000 (16:34 +0200)] 
detect-dsize: enable prefilter support

Enable prefilter support for the dsize keyword.

8 years agoprefilter: implement fragbits
Victor Julien [Thu, 18 Aug 2016 12:20:41 +0000 (14:20 +0200)] 
prefilter: implement fragbits

8 years agoprefilter: engine for ack rules
Victor Julien [Fri, 15 Jul 2016 13:34:06 +0000 (15:34 +0200)] 
prefilter: engine for ack rules

Rules for the 'ack' keyword are uncommon, but if used inspected
against almost every packet.

8 years agoprefilter: engine for tcp flags keyword
Victor Julien [Thu, 14 Jul 2016 15:17:31 +0000 (17:17 +0200)] 
prefilter: engine for tcp flags keyword

If there are many rules for TCP flags these rules would be inspected
against each TCP packet. Even though the flags check is not expensive,
the combined cost of inspecting multiple rules against each and every
packet is high.

This patch implements a prefilter engine for flags. If a rule group
has rules looking for specific flags and engine for that flag or
flags combination is set up. This way those rules are only inspected
if the flag is actually present in the packet.

8 years agoprofiling: support prefilter engines
Victor Julien [Sat, 20 Aug 2016 12:54:37 +0000 (14:54 +0200)] 
profiling: support prefilter engines

8 years agoprefilter: intro common engine for u8 matches
Victor Julien [Mon, 22 Aug 2016 13:21:19 +0000 (15:21 +0200)] 
prefilter: intro common engine for u8 matches

8 years agoprefilter: common funcs for packet header prefilters
Victor Julien [Fri, 19 Aug 2016 08:03:21 +0000 (10:03 +0200)] 
prefilter: common funcs for packet header prefilters

8 years agoprefilter: show prefilter capability in --list-keywords
Victor Julien [Thu, 1 Sep 2016 13:07:31 +0000 (15:07 +0200)] 
prefilter: show prefilter capability in --list-keywords

8 years agoprefilter: implement prefilter keyword
Victor Julien [Thu, 14 Jul 2016 15:10:00 +0000 (17:10 +0200)] 
prefilter: implement prefilter keyword

Introduce prefilter keyword to force a keyword to be used as prefilter.

e.g.
alert tcp any any -> any any (content:"A"; flags:R; prefilter; sid:1;)
alert tcp any any -> any any (content:"A"; flags:R; sid:2;)
alert tcp any any -> any any (content:"A"; dsize:1; prefilter; sid:3;)
alert tcp any any -> any any (content:"A"; dsize:1; sid:4;)

In sid 2 and 4 the content keyword is used in the MPM engine.
In sid 1 and 3 the flags and dsize keywords will be used.

8 years agodetect cleanup: remove sgh mpm_ctx pointers
Victor Julien [Sun, 10 Jul 2016 09:33:27 +0000 (11:33 +0200)] 
detect cleanup: remove sgh mpm_ctx pointers

8 years agosgh: remove unused flags
Victor Julien [Sat, 9 Jul 2016 07:16:24 +0000 (09:16 +0200)] 
sgh: remove unused flags

8 years agotls: mpm prefilter engines
Victor Julien [Sat, 9 Jul 2016 07:05:58 +0000 (09:05 +0200)] 
tls: mpm prefilter engines

8 years agosmtp file_data: mpm prefilter engine
Victor Julien [Sat, 9 Jul 2016 06:47:45 +0000 (08:47 +0200)] 
smtp file_data: mpm prefilter engine