]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agodoc: update eve/alert/metadata configuration 3205/head
Jason Ish [Tue, 30 Jan 2018 21:09:17 +0000 (15:09 -0600)] 
doc: update eve/alert/metadata configuration

7 years agoeve/alert: new metadata configuration (sane defaults)
Jason Ish [Tue, 30 Jan 2018 21:40:26 +0000 (15:40 -0600)] 
eve/alert: new metadata configuration (sane defaults)

Under eve/alert, introduce a new metadata configuration
section. If no provided, or simply yes defaults will be used.
Otherwise this a map with fields that can be toggled on and
off. The defaults are:

outputs:
  - eve-log:
      types:
        - alert:
            metadata:
              app-layer: true
              flow: true
              rule:
                raw: false
                metadata: true

To enable something that is disabled by default, or to disable
something that is enabled by default, only that key need to
be changed, everything else will keep its default value.

7 years agoconf: new function: ConfNodeHasChildren
Jason Ish [Tue, 30 Jan 2018 21:22:10 +0000 (15:22 -0600)] 
conf: new function: ConfNodeHasChildren

Test if a configuration node has any children, indicating
that it is a non-empty map or sequence.

7 years agoeve/alert: include rule text in alert output
Martin Natano [Fri, 11 Aug 2017 16:11:09 +0000 (18:11 +0200)] 
eve/alert: include rule text in alert output

For SIEM analysis it is often useful to refer to the actual rules to
find out why a specific alert has been triggered when the signature
message does not convey enough information.

Turn on the new rule flag to include the rule text in eve alert output.
The feature is turned off by default.

With a rule like this:

    alert dns $HOME_NET any -> 8.8.8.8 any (msg:"Google DNS server contacted"; sid:42;)

The eve alert output might look something like this (pretty-printed for
readability):

    {
      "timestamp": "2017-08-14T12:35:05.830812+0200",
      "flow_id": 1919856770919772,
      "in_iface": "eth0",
      "event_type": "alert",
      "src_ip": "10.20.30.40",
      "src_port": 50968,
      "dest_ip": "8.8.8.8",
      "dest_port": 53,
      "proto": "UDP",
      "alert": {
        "action": "allowed",
        "gid": 1,
        "signature_id": 42,
        "rev": 0,
        "signature": "Google DNS server contacted",
        "category": "",
        "severity": 3,
        "rule": "alert dns $HOME_NET any -> 8.8.8.8 any (msg:\"Google DNS server contacted\"; sid:43;)"
      },
      "app_proto": "dns",
      "flow": {
        "pkts_toserver": 1,
        "pkts_toclient": 0,
        "bytes_toserver": 81,
        "bytes_toclient": 0,
        "start": "2017-08-14T12:35:05.830812+0200"
      }
    }

Feature #2020

7 years agodoc: documentation update on metadata
Eric Leblond [Thu, 26 Oct 2017 08:31:46 +0000 (10:31 +0200)] 
doc: documentation update on metadata

7 years agodetect-metadata: add a string storage to de_ctx
Eric Leblond [Sat, 4 Nov 2017 15:10:15 +0000 (11:10 -0400)] 
detect-metadata: add a string storage to de_ctx

To avoid to have a lot of string allocations, we use a hash table
stored in de_ctx to point to existing string instead of duplicating
them.

7 years agosuricata: init output before detection
Eric Leblond [Sat, 4 Nov 2017 15:06:16 +0000 (11:06 -0400)] 
suricata: init output before detection

As we need to know if we should parse the signature metadata, we
have to parse the output configuration before initializing the
detection engine.

7 years agooutput-json-alert: conditionaly output metadata
Eric Leblond [Fri, 21 Apr 2017 17:42:04 +0000 (19:42 +0200)] 
output-json-alert: conditionaly output metadata

Metadata of the signature can now conditionaly put in the alert
events. This will allow user to get more context about the events
generated by the alert.

detect-metadata: conditional parsing

Only parses metadata if an output module will use the information.
Patch also adds a unittest to check metadata is not parsed if not
asked to.

output-json-alert: optional output keys as array

Update rule metadata configuration to have an option to output
value as array. Also adds an option to log only a series of keys
as array. This is useful in the case of some ruleset where from
instance the `tag` key is used multiple time.

(Jason Ish) rule metadata: always log as lists

After review of rule metadata, we can't make assumptions
on what should be a list or not. So log everything as a list.

7 years agodetect-metadata: add unit test
Eric Leblond [Wed, 25 Oct 2017 19:46:05 +0000 (21:46 +0200)] 
detect-metadata: add unit test

7 years agodetect-metadata: store metadata key value pairs
Eric Leblond [Wed, 14 Dec 2016 16:59:23 +0000 (17:59 +0100)] 
detect-metadata: store metadata key value pairs

This patch updates the Signature structure so it contains the
metadata under a key value form.
Later patch will make that dictionary available in the events.

7 years agotravis/rust: update rust minimum to 1.21 3202/head
Victor Julien [Tue, 30 Jan 2018 16:28:47 +0000 (17:28 +0100)] 
travis/rust: update rust minimum to 1.21

Ubuntu LTS and CentOS7/EPEL has upgraded to 1.21.

Update highest known working version to 1.23.

7 years agoautogen/rust: remove Cargo.lock 3201/head
Victor Julien [Tue, 30 Jan 2018 11:20:42 +0000 (12:20 +0100)] 
autogen/rust: remove Cargo.lock

Remove Cargo.lock to avoid issues when updating Cargo.toml

7 years agorust: update dependencies
Victor Julien [Mon, 29 Jan 2018 14:02:13 +0000 (15:02 +0100)] 
rust: update dependencies

7 years agorust: don't gen C headers if Rust isn't enabled
Victor Julien [Mon, 29 Jan 2018 13:16:01 +0000 (14:16 +0100)] 
rust: don't gen C headers if Rust isn't enabled

7 years agodoc: breakout eve-log section to a partial file
Jason Ish [Thu, 25 Jan 2018 22:20:32 +0000 (16:20 -0600)] 
doc: breakout eve-log section to a partial file

Both the suricata.yaml and eve configuration sections
included the eve-log section from suricata.yaml. First,
sync these up with the actual suricata.yaml then break
it out into its own file, so only one file needs to
be kept in sync with the actual configuration file.

7 years agoeve/alert: log metadata be default
Jason Ish [Thu, 25 Jan 2018 21:33:31 +0000 (15:33 -0600)] 
eve/alert: log metadata be default

By default log metadata.

Remove toggles for individual protocol types and just use a
single toggle to control including the app-layer with the
alert.

The metadata (currently app-layer and flow) can be disabled
by setting metadata to a falsey value, but its removed
from the default configuration (but wil be in docs)

7 years agoeve/metadata: log flowvars as a list of k/v pairs
Jason Ish [Thu, 25 Jan 2018 20:55:55 +0000 (14:55 -0600)] 
eve/metadata: log flowvars as a list of k/v pairs

To match the pktvars output.

7 years agoeve/metadata: special handling for traffic-id labels
Jason Ish [Thu, 25 Jan 2018 20:49:38 +0000 (14:49 -0600)] 
eve/metadata: special handling for traffic-id labels

Give traffic/id and traffic/label flowbits special handling
in the eve output. Instead of just logging them as flowbits,
give them their own top level object.

{
  "traffic": {
    "id": ["id0", "id1"],
    "label": ["label0", "label1"]
  }
}

7 years agodoc: update eve-log section for metadata
Jason Ish [Thu, 25 Jan 2018 14:52:47 +0000 (08:52 -0600)] 
doc: update eve-log section for metadata

7 years agooutput-json-vars: rename to metadata
Jason Ish [Wed, 24 Jan 2018 22:40:11 +0000 (16:40 -0600)] 
output-json-vars: rename to metadata

No functional change, just rename of files and functions
to reflect the metadata event type now used.

7 years agojson-vars: rename to metadata and use new metadata format
Jason Ish [Wed, 24 Jan 2018 20:51:03 +0000 (14:51 -0600)] 
json-vars: rename to metadata and use new metadata format

7 years agoeve: netflow: global metadata config
Jason Ish [Mon, 11 Dec 2017 21:50:54 +0000 (15:50 -0600)] 
eve: netflow: global metadata config

7 years agoeve: http: global metadata config
Jason Ish [Mon, 11 Dec 2017 21:50:42 +0000 (15:50 -0600)] 
eve: http: global metadata config

7 years agoeve: flow: global metadata config
Jason Ish [Mon, 11 Dec 2017 21:50:36 +0000 (15:50 -0600)] 
eve: flow: global metadata config

7 years agoeve: dns: global metadata config
Jason Ish [Mon, 11 Dec 2017 21:50:30 +0000 (15:50 -0600)] 
eve: dns: global metadata config

7 years agoeve: alert: global metadata config
Jason Ish [Mon, 11 Dec 2017 21:50:25 +0000 (15:50 -0600)] 
eve: alert: global metadata config

Also, remove vars as a subtype. Adding the top level metadata
field is an eve lebel parameter, not alert now.

7 years agoeve: drop: global metadata config
Jason Ish [Mon, 11 Dec 2017 21:50:18 +0000 (15:50 -0600)] 
eve: drop: global metadata config

7 years agoeve: email: respect global metadata config
Jason Ish [Mon, 11 Dec 2017 21:50:07 +0000 (15:50 -0600)] 
eve: email: respect global metadata config

7 years agoeve: nfs: respect global metadata config
Jason Ish [Mon, 11 Dec 2017 21:49:57 +0000 (15:49 -0600)] 
eve: nfs: respect global metadata config

7 years agoeve: smtp: respect global metadata config
Jason Ish [Mon, 11 Dec 2017 21:49:51 +0000 (15:49 -0600)] 
eve: smtp: respect global metadata config

7 years agoeve: dnp3: respect global metadata config
Jason Ish [Mon, 11 Dec 2017 21:49:45 +0000 (15:49 -0600)] 
eve: dnp3: respect global metadata config

7 years agoeve: ssh: respect global metadata config
Jason Ish [Mon, 11 Dec 2017 21:49:40 +0000 (15:49 -0600)] 
eve: ssh: respect global metadata config

7 years agoeve: tls: respect global metadata config
Jason Ish [Mon, 11 Dec 2017 21:49:34 +0000 (15:49 -0600)] 
eve: tls: respect global metadata config

7 years agoeve: metadata setting to enable/disable metadata
Jason Ish [Mon, 11 Dec 2017 21:48:14 +0000 (15:48 -0600)] 
eve: metadata setting to enable/disable metadata

This is a top level metadata object containing flowbits,
flowints, pktvars and flowvars.

Enabling it at the top level enables it for all log types.

7 years agoeve: top level metadata object
Jason Ish [Mon, 11 Dec 2017 16:16:47 +0000 (10:16 -0600)] 
eve: top level metadata object

Contains:
- flowbits (as array)
- flowints (map)
- flowvars (map)
- pktvars (map)

7 years agohtp: minor debug addition
Victor Julien [Mon, 29 Jan 2018 15:45:33 +0000 (16:45 +0100)] 
htp: minor debug addition

7 years agohtp: remove unused field from tx state
Victor Julien [Fri, 26 Jan 2018 11:05:35 +0000 (12:05 +0100)] 
htp: remove unused field from tx state

7 years agohtp: remove used body operation field
Victor Julien [Fri, 26 Jan 2018 11:00:15 +0000 (12:00 +0100)] 
htp: remove used body operation field

7 years agohtp: code cleanups
Victor Julien [Fri, 26 Jan 2018 10:53:27 +0000 (11:53 +0100)] 
htp: code cleanups

7 years agohtp: remove usused file flags
Victor Julien [Fri, 26 Jan 2018 10:48:55 +0000 (11:48 +0100)] 
htp: remove usused file flags

7 years agohtp: remove usused flags
Victor Julien [Fri, 26 Jan 2018 10:41:03 +0000 (11:41 +0100)] 
htp: remove usused flags

7 years agostream: improve overlap detection
Victor Julien [Fri, 26 Jan 2018 08:14:16 +0000 (09:14 +0100)] 
stream: improve overlap detection

Improve detection of overlapping different data. Keep some data around
even if it was already ACK'd to check if packets have overlap.

7 years agohtp: allow HTTP pickup of response data
Victor Julien [Sun, 12 Nov 2017 08:16:17 +0000 (09:16 +0100)] 
htp: allow HTTP pickup of response data

Now that libhtp can pick up sessions that start with a response
we can enable support for it as well.

7 years agohttp: add tests for malformed response lines
Victor Julien [Sun, 12 Nov 2017 08:15:33 +0000 (09:15 +0100)] 
http: add tests for malformed response lines

7 years agostream: set event for suspected data injection during 3whs
Victor Julien [Wed, 24 Jan 2018 15:37:27 +0000 (16:37 +0100)] 
stream: set event for suspected data injection during 3whs

This rule will match on the STREAM_3WHS_ACK_DATA_INJECT, that is
set if we're:
- in IPS mode
- get a data packet from the server
- that matches the exact SEQ/ACK expectations for the 3whs

The action of the rule is set to drop as the stream engine will drop.
So the rule action is actually not needed, but for consistency it
is drop.

7 years agostream: handle data on incomplete 3whs
Victor Julien [Wed, 24 Jan 2018 14:59:57 +0000 (15:59 +0100)] 
stream: handle data on incomplete 3whs

If we have only seen the SYN and SYN/ACK of the 3whs, accept from
server data if it perfectly matches the SEQ/ACK expectations. This
might happen in 2 scenarios:

1. packet loss: if we lost the final ACK, we may get data that fits
   this pattern (e.g. a SMTP EHLO message).

2. MOTS/MITM packet injection: an attacker can send a data packet
   together with its SYN/ACK packet. The client due to timing almost
   certainly gets the SYN/ACK before considering the data packet,
   and will respond with the final ACK before processing the data
   packet.

In IDS mode we will accept the data packet and rely on the reassembly
engine to warn us if the packet was indeed injected.

In IPS mode we will drop the packet. In the packet loss case we will
rely on retransmissions to get the session back up and running. For
the injection case we blocked this injection attempt.

7 years agostream: still inspect packets dropped by stream
Victor Julien [Wed, 24 Jan 2018 14:59:14 +0000 (15:59 +0100)] 
stream: still inspect packets dropped by stream

The detect engine would bypass packets that are set as dropped. This
seems sane, as these packets are going to be dropped anyway.

However, it lead to the following corner case: stream events that
triggered the drop could not be matched on the rules. The packet
with the event wouldn't make it to the detect engine due to the bypass.

This patch changes the logic to not bypass DROP packets anymore.
Packets that are dropped by the stream engine will set the no payload
inspection flag, so avoid needless cost.

7 years agoenip: support gaps
Victor Julien [Tue, 21 Nov 2017 09:31:58 +0000 (10:31 +0100)] 
enip: support gaps

Due to a bug in the GAP handling the TCP layer the parser would already
get data after GAPs before.

7 years agostream/app-layer: fix GAP handling issue
Victor Julien [Fri, 10 Nov 2017 22:03:16 +0000 (23:03 +0100)] 
stream/app-layer: fix GAP handling issue

Fix case where data after GAP was processed as in order data by app-layer.
This happened even if protocol parser did not register to accept GAPs.

7 years agopcre: don't leak memory in data extraction
Victor Julien [Mon, 29 Jan 2018 10:26:01 +0000 (11:26 +0100)] 
pcre: don't leak memory in data extraction

7 years agorust/tftp: eve logging with rust
Pascal Delalande [Tue, 23 Jan 2018 20:18:41 +0000 (21:18 +0100)] 
rust/tftp: eve logging with rust

7 years agorust/tftp: add tftp parsing and logging
Clement Galland [Fri, 20 Oct 2017 07:42:37 +0000 (07:42 +0000)] 
rust/tftp: add tftp parsing and logging

TFTP parsing and logging written in Rust.
Log on eve.json the type of request (read or write), the name of the file and
the mode.

Example of output:
    "tftp":{"packet":"read","file":"rfc1350.txt","mode":"octet"}

7 years agodoc: update filestore for file hash extraction
Pascal Delalande [Fri, 26 Jan 2018 21:11:33 +0000 (22:11 +0100)] 
doc: update filestore for file hash extraction

Update for extraction based on md5, sha1 and sha256

7 years agorust/nfs: explicitly handle GAPs from C
Victor Julien [Thu, 25 Jan 2018 16:55:17 +0000 (17:55 +0100)] 
rust/nfs: explicitly handle GAPs from C

It seems that Rust optimizes this code in such a way that it
passes the null ptr along as real data.

    if buf.as_ptr().is_null() && input_len > 0 {

7 years agorust/filetracker: if file API return error, trunc file
Victor Julien [Thu, 25 Jan 2018 14:31:35 +0000 (15:31 +0100)] 
rust/filetracker: if file API return error, trunc file

7 years agorust/nfs: fix read reply handling
Victor Julien [Thu, 25 Jan 2018 13:56:05 +0000 (14:56 +0100)] 
rust/nfs: fix read reply handling

READ replies with large data chunks are processed partially to avoid
queuing too much data. When the final chunk was received however, the
start of the chunk would already tag the transaction as 'done'. The
more aggressive tx freeing that was recently merged would cause this
tx to be freed before the rest of the in-progress chunk was done.

This patch delays the tagging of the tx until the final data has been
received.

7 years agofile: minor cleanups
Victor Julien [Thu, 25 Jan 2018 10:02:33 +0000 (11:02 +0100)] 
file: minor cleanups

7 years agofile: use enum for state
Victor Julien [Thu, 25 Jan 2018 09:32:13 +0000 (10:32 +0100)] 
file: use enum for state

Makes debugging easier.

7 years agorust/file: handle file open errors
Victor Julien [Thu, 25 Jan 2018 09:05:55 +0000 (10:05 +0100)] 
rust/file: handle file open errors

7 years agorust/file: change return type for FileOpenFileWithId
Victor Julien [Thu, 25 Jan 2018 08:56:37 +0000 (09:56 +0100)] 
rust/file: change return type for FileOpenFileWithId

Make it int so we can easily check it in Rust. No consumer used the
File pointer that was returned before anyway.

7 years agorust/core: comment cleanup
Victor Julien [Thu, 25 Jan 2018 08:47:02 +0000 (09:47 +0100)] 
rust/core: comment cleanup

7 years ago.gitignore: only ignore *.yaml in root directory
Jason Ish [Thu, 25 Jan 2018 22:19:57 +0000 (16:19 -0600)] 
.gitignore: only ignore *.yaml in root directory

7 years agoaf_packet: bug #2422. 3184/head
Alexander Gozman [Thu, 18 Jan 2018 09:05:15 +0000 (09:05 +0000)] 
af_packet: bug #2422.

This commit fixes a leak of mmap'ed ring buffer that was not
unmaped when a socket was closed. In addition, the leak could
break an inline channel on certain configurations.

Also slightly changed AFPCreateSocket():
1. If an interface is not up, it does not try to apply any
   settings to a socket. This reduces a number of error messages
   while an interface is down.
2. Interface is considered active if both IFF_UP and IFF_RUNNING
   are present.

7 years agorunmode-unix-socket: interrupt as commanded (2413)
Danny Browning [Sat, 13 Jan 2018 15:51:20 +0000 (08:51 -0700)] 
runmode-unix-socket: interrupt as commanded (2413)

https://redmine.openinfosecfoundation.org/issues/2413

Once interrupt occurs, reset the interrupt flag so that future runs are
not immediately interrupted.

7 years agounix-socket: socket permission update
Pascal Delalande [Tue, 5 Dec 2017 21:42:57 +0000 (22:42 +0100)] 
unix-socket: socket permission update

So far, the suricata socket suricata-command.socket has the rights
 rw-r----- suricata:user.
When suricata is used with restricted access, an other application
(suricatasc like) that needs to access to the command socket also
with restricted access can not write to the socket since it is not
the owner (e.g suricata within container, with an hardened value
for umask and hardened rights for users).

The socket should be set as rw-rw----. Use chmod instead of fchmod
and set it after the socket creation.

7 years agosuricatasc: pcap-file-continuous (2412)
Danny Browning [Sat, 13 Jan 2018 15:08:11 +0000 (08:08 -0700)] 
suricatasc: pcap-file-continuous (2412)

https://redmine.openinfosecfoundation.org/issues/2412

Suricatasc is not supporting pcap-file processing in continuous mode.
Register a new command pcap-file-continuous in the unix manager to work
with suricatasc. Add defaulted arguments for pcap-file to support
backwards compatibility.

7 years agoapp-layer-htp, stream-tcp: prevent modulo bias in RandomGetWrap() 3183/head
Martin Natano [Mon, 30 Oct 2017 15:03:25 +0000 (16:03 +0100)] 
app-layer-htp, stream-tcp: prevent modulo bias in RandomGetWrap()

RAND_MAX is not guaranteed to be a divisor of ULONG_MAX, so take the
necessary precautions to get unbiased random numbers. Although the
bias might be negligible, it's not advisable to rely on it.

7 years agodetect: minor cleanup
Victor Julien [Tue, 23 Jan 2018 07:55:37 +0000 (08:55 +0100)] 
detect: minor cleanup

7 years agosignal: use centralized pthread_sigmask for signals
Maurizio Abba [Tue, 16 Jan 2018 18:12:28 +0000 (18:12 +0000)] 
signal: use centralized pthread_sigmask for signals

according to its man page, sigprocmask has undefined behavior in
multithreaded environments. Instead of explictly blocking the handling
of SIGUSR2 in every thread, direct block handling SIGUSR2 before
creating the threads and enable again the handling of this signal
afterwards. In this way, only the main thread will be able to manage
this signal properly.

7 years agothreshold: minor cleanups
Victor Julien [Tue, 23 Jan 2018 07:44:46 +0000 (08:44 +0100)] 
threshold: minor cleanups

7 years agorate_filter: by_rule fixed triggering algorithm
Ruslan Usmanov [Tue, 12 Dec 2017 18:10:07 +0000 (13:10 -0500)] 
rate_filter: by_rule fixed triggering algorithm

Fixes issue #2258

Program was triggering rate_filter by_rule earlier than needed
and generally behaved like a threshold.

7 years agodetect/content: implement endswith 3182/head
Victor Julien [Tue, 19 Dec 2017 15:14:33 +0000 (16:14 +0100)] 
detect/content: implement endswith

7 years agodetect/content: introduce startswith modifier
Victor Julien [Sat, 16 Dec 2017 10:44:18 +0000 (11:44 +0100)] 
detect/content: introduce startswith modifier

Add startswith modifier to simplify matching patterns at the start
of a buffer.

Instead of:
    content:"abc"; depth:3;
This enables:
    content:"abc"; startswith;

Especially with longer patterns this makes the intention of the rule
more clear and eases writing the rules.

Internally it's simply a shorthand for 'depth:<pattern len>;'.

Ticket https://redmine.openinfosecfoundation.org/issues/742

7 years agodetect: bypass merge sort call if possible
Victor Julien [Thu, 2 Nov 2017 11:44:29 +0000 (12:44 +0100)] 
detect: bypass merge sort call if possible

7 years agodetect: profiling update for new detect code
Victor Julien [Wed, 1 Nov 2017 16:38:22 +0000 (17:38 +0100)] 
detect: profiling update for new detect code

7 years agodetect/prefilter: redo profiling
Victor Julien [Tue, 31 Oct 2017 16:48:18 +0000 (17:48 +0100)] 
detect/prefilter: redo profiling

7 years agodetect/profiling: postpone setup
Victor Julien [Mon, 23 Oct 2017 08:48:56 +0000 (10:48 +0200)] 
detect/profiling: postpone setup

Do this to allow for including of runtime buffer registrations.

7 years agodetect/fast-pattern: use registered buffers for check
Victor Julien [Mon, 23 Oct 2017 10:29:55 +0000 (12:29 +0200)] 
detect/fast-pattern: use registered buffers for check

7 years agooutput/filedata: call loggers on both directions
Victor Julien [Fri, 12 Jan 2018 07:49:20 +0000 (08:49 +0100)] 
output/filedata: call loggers on both directions

7 years agooutput/file: run file loggers in both directions
Victor Julien [Thu, 11 Jan 2018 19:42:54 +0000 (20:42 +0100)] 
output/file: run file loggers in both directions

This avoids the wait for injected packets when file is already ready
to be logged.

7 years agodetect/state: clean up old code
Victor Julien [Thu, 11 Jan 2018 12:50:59 +0000 (13:50 +0100)] 
detect/state: clean up old code

7 years agodetect: fix multiple files per tx inspect
Victor Julien [Wed, 10 Jan 2018 18:17:33 +0000 (19:17 +0100)] 
detect: fix multiple files per tx inspect

Fix the inspection of multiple files in a single TX, where new files
may be added to the TX after inspection started.

Assign the hard coded id DE_STATE_FLAG_FILE_INSPECT to the file
inspect engine.

Make sure that sigs that do file inspection and don't match on the
current file always store a detailed state. This state will include
the DE_STATE_FLAG_FILE_INSPECT flag.

When the app-layer indicates a new file is available, for each sig
that has the DE_STATE_FLAG_FILE_INSPECT flag set, reset part of the
state so that the sig is evaluated again.

7 years agoapp-layer: improve async and out of order txs
Victor Julien [Wed, 11 Oct 2017 17:02:43 +0000 (19:02 +0200)] 
app-layer: improve async and out of order txs

Free txs that are done out of order if we can. Some protocol
implementations have transactions running in parallel, where it is
possible that a tx that started later finishes earlier than other
transactions. Support freeing those.

Also improve handling on asynchronious transactions. If transactions
are unreplied, e.g. in the dns flood case, the parser may at some
point free transactions on it's own. Handle this case in
the app-layer engine so that the various tracking id's (inspect, log,
and 'min') are updated accordingly.

Next, free txs much more aggressively. Instead of freeing old txs
at the app-layer parsing stage, free all complete txs at the end
of the flow-worker. This frees txs much sooner in many cases.

7 years agodetect/prefilter: show prefilter engine id space
Victor Julien [Tue, 10 Oct 2017 10:40:03 +0000 (12:40 +0200)] 
detect/prefilter: show prefilter engine id space

7 years agoapp-layer: warn that MpmIDs API is no longer used
Victor Julien [Tue, 10 Oct 2017 09:54:35 +0000 (11:54 +0200)] 
app-layer: warn that MpmIDs API is no longer used

Remove implementation.

7 years agodetect/flowbits: apply state knowledge
Victor Julien [Tue, 9 Jan 2018 16:52:19 +0000 (17:52 +0100)] 
detect/flowbits: apply state knowledge

When stateless rules are depending on a flowbit being set by a stateful
rule, the inspection order is almost certainly wrong.

Switch stateless rules depending on stateful rules to being stateful.
This is used to turn 'TCP stream' inspecting rules (which are stateless
unless mixed with stateful keywords) into stateful rules.

7 years agodetect: rewrite of the detect engine
Victor Julien [Sun, 8 Oct 2017 09:42:30 +0000 (11:42 +0200)] 
detect: rewrite of the detect engine

Use per tx detect_flags to track prefilter. Detect flags are used for 2
things:
1. marking tx as fully inspected
2. tracking already run prefilter (incl mpm) engines

This supercedes the MpmIDs API for directionless tracking
of the prefilter engines.

When we have no SGH we have to flag the txs that are 'complete'
as inspected as well.

Special handling for the stream engine:

If a rule mixes TX inspection and STREAM inspection, we can encounter
the case where the rule is evaluated against multiple transactions
during a single inspection run. As the stream data is exactly the same
for each of those runs, it's wasteful to rerun inspection of the stream
portion of the rule.

This patch enables caching of the stream 'inspect engine' result in
the local 'RuleMatchCandidateTx' array. This is valid only during the
live of a single inspection run.

Remove stateful inspection from 'mask' (SignatureMask). The mask wasn't
used in most cases for those rules anyway, as there we rely on the
prefilter. Add a alproto check to catch the remaining cases.

When building the active non-mpm/non-prefilter list check not just
the mask, but also the alproto. This especially helps stateful rules
with negated mpm.

Simplify AppLayerParserHasDecoderEvents usage in detection to only
return true if protocol detection events are set. Other detection is done
in inspect engines.

Move rule group lookup and handling into it's own function. Handle
'post lookup' tasks immediately, instead of after the first detect
run. The tasks were independent of the initial detection.

Many cleanups and much refactoring.

7 years agorust/nfs: add support for detect_flags API
Victor Julien [Mon, 16 Oct 2017 13:30:28 +0000 (15:30 +0200)] 
rust/nfs: add support for detect_flags API

7 years agodns: support detect flags
Victor Julien [Wed, 17 Jan 2018 14:13:55 +0000 (15:13 +0100)] 
dns: support detect flags

7 years agorust/dns: implement detect_flags API
Victor Julien [Fri, 13 Oct 2017 06:12:21 +0000 (08:12 +0200)] 
rust/dns: implement detect_flags API

7 years agohttp: move from MpmIDs to DetectFlags API
Victor Julien [Tue, 10 Oct 2017 09:54:02 +0000 (11:54 +0200)] 
http: move from MpmIDs to DetectFlags API

7 years agossl/tls: use DetectFlags API
Victor Julien [Tue, 17 Oct 2017 08:19:41 +0000 (10:19 +0200)] 
ssl/tls: use DetectFlags API

7 years agosmtp: implement DetectFlags API
Victor Julien [Mon, 16 Oct 2017 13:56:53 +0000 (15:56 +0200)] 
smtp: implement DetectFlags API

7 years agossh: implement DetectFlags API
Victor Julien [Mon, 16 Oct 2017 13:48:05 +0000 (15:48 +0200)] 
ssh: implement DetectFlags API

7 years agoapp-layer: detect flags API calls
Victor Julien [Tue, 10 Oct 2017 09:17:52 +0000 (11:17 +0200)] 
app-layer: detect flags API calls

Add API meant to replace the MpmIDs API. It uses a u64 for each direction
in a tx to keep track of 2 things:

1. is inspection done?
2. which prefilter engines (like mpm) are already completed

7 years agoflowbits: analyze and dump to json
Victor Julien [Fri, 13 Oct 2017 09:01:38 +0000 (11:01 +0200)] 
flowbits: analyze and dump to json

Analyze flowbits to find which bits are only checked.

Track whether they are set and checked on the same level of 'statefulness'
for later used.

Dump flowbits to json including the sids that set/check etc the bit.

7 years agofilestore: minor cleanups and warning fixes
Victor Julien [Thu, 18 Jan 2018 16:38:09 +0000 (17:38 +0100)] 
filestore: minor cleanups and warning fixes

7 years agosuricatasc: don't use find -delete 3175/head
Jason Ish [Thu, 18 Jan 2018 12:42:19 +0000 (06:42 -0600)] 
suricatasc: don't use find -delete

For when -delete isn't supported by find. Instead use
-print0 with xargs -0.

7 years agodoc: document file-store v2
Jason Ish [Wed, 17 Jan 2018 13:51:38 +0000 (07:51 -0600)] 
doc: document file-store v2

7 years agofilestore: only allow one filestore to be enabled
Jason Ish [Fri, 12 Jan 2018 20:46:31 +0000 (14:46 -0600)] 
filestore: only allow one filestore to be enabled

There is probably not too much bad about enabling both, but
open file counts can get messy with both enabled. And v1
should be schedule for deprecation soon enough.