]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
10 years agopcap: implement LINKTYPE_NULL 1454/head
Victor Julien [Mon, 13 Apr 2015 10:12:46 +0000 (12:12 +0200)] 
pcap: implement LINKTYPE_NULL

Implement LINKTYPE_NULL for pcap live and pcap file.

From: http://www.tcpdump.org/linktypes.html

"BSD loopback encapsulation; the link layer header is a 4-byte field,
 in host byte order, containing a PF_ value from socket.h for the
 network-layer protocol of the packet.

 Note that ``host byte order'' is the byte order of the machine on
 which the packets are captured, and the PF_ values are for the OS
 of the machine on which the packets are captured; if a live capture
 is being done, ``host byte order'' is the byte order of the machine
 capturing the packets, and the PF_ values are those of the OS of
 the machine capturing the packets, but if a ``savefile'' is being
 read, the byte order and PF_ values are not necessarily those of
 the machine reading the capture file."

Feature ticket #1445

10 years agofix reputation parser so that it accepts ipv6 addresses in configuration file.
Tom DeCanio [Fri, 17 Apr 2015 04:28:03 +0000 (21:28 -0700)] 
fix reputation parser so that it accepts ipv6 addresses in configuration file.

10 years agoafl - SCHINfoLoadFromConfig - check for NULL before parsing.
Jason Ish [Mon, 20 Apr 2015 18:12:55 +0000 (12:12 -0600)] 
afl - SCHINfoLoadFromConfig - check for NULL before parsing.

Found by AFL on suricata.yaml.

10 years agoafl - Don't fail if app-layer proto enabled value is NULL.
Jason Ish [Mon, 20 Apr 2015 17:47:18 +0000 (11:47 -0600)] 
afl - Don't fail if app-layer proto enabled value is NULL.

Found by using AFL on suricata.yaml.

10 years agoemail-json: free temporary 'cc' string
Eric Leblond [Wed, 29 Apr 2015 12:57:53 +0000 (14:57 +0200)] 
email-json: free temporary 'cc' string

10 years agoemail-json: free temporary 'to' string
Eric Leblond [Wed, 29 Apr 2015 12:57:07 +0000 (14:57 +0200)] 
email-json: free temporary 'to' string

10 years agoapp-layer-smtp: fix SMTPTransactionFree function
Eric Leblond [Wed, 29 Apr 2015 13:43:47 +0000 (15:43 +0200)] 
app-layer-smtp: fix SMTPTransactionFree function

A typo was causing some freeing tasks not to be executed.

10 years agoprofiling: fix sorting on very long runs
Victor Julien [Wed, 29 Apr 2015 21:34:44 +0000 (23:34 +0200)] 
profiling: fix sorting on very long runs

Fix poor int handling breaking sorts of profiling on long runs
where the numbers could get really big.

10 years agoxbits: fix coverity warnings
Victor Julien [Wed, 29 Apr 2015 13:51:19 +0000 (15:51 +0200)] 
xbits: fix coverity warnings

Switch statement would contain NOALERT even though this was
unreachable.

10 years agocoverity fix: don't do pointer check on static array
Victor Julien [Wed, 29 Apr 2015 13:38:39 +0000 (15:38 +0200)] 
coverity fix: don't do pointer check on static array

10 years agoFix potential deadlock in output
Victor Julien [Wed, 29 Apr 2015 13:03:23 +0000 (15:03 +0200)] 
Fix potential deadlock in output

Coverity:
** CID 1296115:  Program hangs  (ORDER_REVERSAL)
/src/tm-threads.c: 1670 in TmThreadClearThreadsFamily()

The problem is with the by default unused '%m' output parameter.
To get the thread vars it takes the tv_root_lock. This may already
be locked by the calling thread. Also, it could lead to a case of
wrong lock order between the tv_root_lock and the thread_store_lock.

Very unlikely to happen though.

As the %m param isn't really used (by default) this patch just
disables it.

10 years agopacket pool: fix memleaks
Victor Julien [Tue, 21 Apr 2015 15:29:24 +0000 (17:29 +0200)] 
packet pool: fix memleaks

Don't kill flow manager and recyclers before the rest of the threads. The
packet threads may still have packets from their pools. As the flow threads
would destroy their pools the packets would be lost.

This patch doesn't kill the threads, it just pulls them out of their run
loop and into a wait loop. The packet pools won't be cleared until all
threads are killed.

Wait for flow management threads to close before moving on to the
next steps in the shutdown process.

Don't destroy flow force reassembly packet pool too early. Worker
threads may still want to return packets to it.

10 years agothreshold: cleanups
Victor Julien [Wed, 8 Apr 2015 14:22:07 +0000 (16:22 +0200)] 
threshold: cleanups

Use pcre_copy_substring in the most common part of threshold rule
parsing. Minor other cleanups.

10 years agoreference: use pcre_copy_substring
Victor Julien [Wed, 8 Apr 2015 13:34:58 +0000 (15:34 +0200)] 
reference: use pcre_copy_substring

10 years agoclassification: cleanups
Victor Julien [Wed, 8 Apr 2015 13:15:29 +0000 (15:15 +0200)] 
classification: cleanups

Reduce hash table size as regular classification files are usually
below 100 in size. It's not performance critical anyway.

Convert pcre_get_substring calls to pcre_copy_substring.

10 years agosuricatasc: allow for longer response times after connect
Victor Julien [Thu, 16 Apr 2015 13:47:19 +0000 (15:47 +0200)] 
suricatasc: allow for longer response times after connect

10 years agopacket pool: init pool for autofp workers as well
Victor Julien [Wed, 22 Apr 2015 10:38:52 +0000 (12:38 +0200)] 
packet pool: init pool for autofp workers as well

Introduce a new 'PacketPoolInitEmpty' as these pools will not often
need packets.

Also, don't double 'destroy' in the main thread.

10 years agoautofp: reduce flow storage space requirement
Victor Julien [Fri, 17 Apr 2015 09:21:54 +0000 (11:21 +0200)] 
autofp: reduce flow storage space requirement

Use int16_t instead of a regular int to safe 2 bytes per flow.

10 years agothreading: add missing locks to threading storage
Victor Julien [Thu, 23 Apr 2015 07:32:01 +0000 (09:32 +0200)] 
threading: add missing locks to threading storage

Lock threading root lock when walking or updating the threading
storage for 'ThreadVars' objects.

10 years agoAdded new WebDAV http methods. 1445/head
maxtors [Fri, 17 Apr 2015 08:37:21 +0000 (10:37 +0200)] 
Added new WebDAV http methods.

Added more WebDAV functions. A complete list of what http
methods libhtp can handle can be found at:
https://github.com/OISF/libhtp/blob/0.5.x/htp/htp_core.h#L260.
So now the methods array reflects these available functions.

The comments have also been changed to reflect the desired style.

10 years agoReworked pattern registration structure and feedback issues.
maxtors [Fri, 17 Apr 2015 08:03:24 +0000 (10:03 +0200)] 
Reworked pattern registration structure and feedback issues.

1) Reworked pattern registration for http methods and versions.

Instead of being a manual and verbose action of adding one
and one http method with N-amount if prefix spacings and
the same for HTTP versions (eg. HTTP/1.1) i moved it all
to be loop based actions reading values from char arrays.

In the future all that is needed is to add new methods
to the arrays and they will be added as a pattern.

2) Modified pattern registration after feedback.

Changed variable used in snprintf for http method registration
Should have been size of dest buffer at not another var (catsize)
that i had created. Also removed this variable.

Fixed a typo in the comment for registering http versions.
TO_CIENT -> TO_CLIENT.

10 years agoAdded http methods for webdav (rfc4918).
maxtors [Thu, 16 Apr 2015 20:44:36 +0000 (22:44 +0200)] 
Added http methods for webdav (rfc4918).

Included the following methods to app-layer-htp.c:
- PROPFIND
- PROPPATCH
- MKCOL
- COPY
- MOVE
- LOCK
- UNLOCK

10 years agoAdded DELETE and PATCH http methods to app-layer-htp.c
maxtors [Thu, 16 Apr 2015 14:15:10 +0000 (16:15 +0200)] 
Added DELETE and PATCH http methods to app-layer-htp.c

Added two new http methods to the http decoding done in
app-layer-htp.c so that these messages will be decoded as well.

10 years agoapp-layer: update protocol detection tests 1444/head
Victor Julien [Thu, 23 Apr 2015 07:53:20 +0000 (09:53 +0200)] 
app-layer: update protocol detection tests

AppLayerTest09, AppLayerTest10 and AppLayerTest11 depended on a max
protocol detection pattern size of < 17. Update the tests to pass one
extra byte to the app layer. This makes the protocol detection code
flag the session as 'proto detection completed' again.

10 years agoFix Unit ID check 1435/head
David Maciejak [Sun, 8 Feb 2015 02:27:03 +0000 (10:27 +0800)] 
Fix Unit ID check

10 years agoutil-running-mode: setup config file
Eric Leblond [Tue, 27 Jan 2015 20:22:29 +0000 (21:22 +0100)] 
util-running-mode: setup config file

Without that we get warning message.

10 years agolist keywords: fix regression on app layer name
Eric Leblond [Fri, 16 Jan 2015 13:37:41 +0000 (14:37 +0100)] 
list keywords: fix regression on app layer name

It was not anymore displayed.

10 years agolist keywords: restore 2.0 similar output
Eric Leblond [Fri, 16 Jan 2015 09:12:55 +0000 (10:12 +0100)] 
list keywords: restore 2.0 similar output

Unset was previously displayed if the application layer was not
set. Code before this patch was displaying '(null)' which is not
user friendly.

10 years agoReject ICMP traffic, not only TCP/UDP
Alexander Gozman [Tue, 7 Apr 2015 14:04:52 +0000 (17:04 +0300)] 
Reject ICMP traffic, not only TCP/UDP

10 years agospelling - dubbed -> duped (for duplicate) 1429/head
Jason Ish [Thu, 16 Apr 2015 21:56:51 +0000 (15:56 -0600)] 
spelling - dubbed -> duped (for duplicate)

10 years agoDetectGidSet - safer stripping of quotes.
Jason Ish [Thu, 16 Apr 2015 21:33:32 +0000 (15:33 -0600)] 
DetectGidSet - safer stripping of quotes.

Discovered by AFL when using a rule like:
    alert tcp any any -> any any (content:"ABC"; gid:";)
resulting a negative array index.

10 years agoDetectSidSetup - safer stripping of quotes.
Jason Ish [Thu, 16 Apr 2015 20:46:24 +0000 (14:46 -0600)] 
DetectSidSetup - safer stripping of quotes.

Discovered by AFL when using a rule like:
    alert tcp any any -> any any (content:"ABC"; sid:";)
would result in a negative array index.

10 years agoParseSizeString - don't abort on unknown unit type. 1428/head
Jason Ish [Thu, 16 Apr 2015 17:44:55 +0000 (11:44 -0600)] 
ParseSizeString - don't abort on unknown unit type.

10 years agohost: handle timeout 1422/head
Victor Julien [Sat, 20 Dec 2014 21:43:21 +0000 (22:43 +0100)] 
host: handle timeout

Set expiration for regular hostbits keyword.

10 years agoippair: handle timeouts in the flow manager
Victor Julien [Sat, 20 Dec 2014 21:19:11 +0000 (22:19 +0100)] 
ippair: handle timeouts in the flow manager

Like host and defrag, handle timeouts of ippair in the first flow
manager thread.

10 years agoippair: implement basic timeout check
Victor Julien [Sat, 20 Dec 2014 20:30:12 +0000 (21:30 +0100)] 
ippair: implement basic timeout check

The only user is the xbits subsys, so it's timeout controls all.

10 years agohosts: consider hostbits/xbits status in timeout
Victor Julien [Sat, 20 Dec 2014 20:12:15 +0000 (21:12 +0100)] 
hosts: consider hostbits/xbits status in timeout

Consider the host's xbits expiry status when checking the host for
timeout. If a single active non-expired bit is found, the host won't
be timeout just yet.

10 years agohost: implement hostbits/xbits expire
Victor Julien [Sat, 20 Dec 2014 19:02:19 +0000 (20:02 +0100)] 
host: implement hostbits/xbits expire

10 years agoippair: implement xbits expiration
Victor Julien [Sat, 20 Dec 2014 18:07:48 +0000 (19:07 +0100)] 
ippair: implement xbits expiration

10 years agoxbits: expire (first steps)
Victor Julien [Sat, 20 Dec 2014 16:14:53 +0000 (17:14 +0100)] 
xbits: expire (first steps)

10 years agoxbits: implement ip_src/ip_dst support
Victor Julien [Sat, 20 Dec 2014 12:39:23 +0000 (13:39 +0100)] 
xbits: implement ip_src/ip_dst support

Just a wrapper for regular 'hostbits'.

10 years agohostbits: prepare for xbits integration
Victor Julien [Sat, 20 Dec 2014 11:28:01 +0000 (12:28 +0100)] 
hostbits: prepare for xbits integration

10 years agoxbits: prepare for non-ippair support
Victor Julien [Sat, 20 Dec 2014 11:24:03 +0000 (12:24 +0100)] 
xbits: prepare for non-ippair support

10 years agovars: redo var name <-> idx handling
Victor Julien [Sat, 20 Dec 2014 11:02:59 +0000 (12:02 +0100)] 
vars: redo var name <-> idx handling

Can't use sm type anymore as multiple var carriers (host/flow/etc) will
all have xbits.

10 years agoxbits: hostbits use xbits type
Victor Julien [Sat, 20 Dec 2014 09:06:30 +0000 (10:06 +0100)] 
xbits: hostbits use xbits type

Make hostbits use xbits type.

10 years agoxbit: move to util-var
Victor Julien [Sat, 20 Dec 2014 09:00:24 +0000 (10:00 +0100)] 
xbit: move to util-var

We can reuse the type for hostbits and flowbits as well.

10 years agoippair: xbit implementation
Victor Julien [Fri, 19 Dec 2014 16:40:36 +0000 (17:40 +0100)] 
ippair: xbit implementation

detect xbits for ippair: initial implementation

10 years agohostbits: unittest cleanups
Victor Julien [Tue, 16 Dec 2014 10:22:24 +0000 (11:22 +0100)] 
hostbits: unittest cleanups

10 years agohostbits: allow for src/dst parameter
Victor Julien [Tue, 16 Dec 2014 07:41:23 +0000 (08:41 +0100)] 
hostbits: allow for src/dst parameter

By default, the hostbit checks the 'src' host. By adding the dst option
the dst host is used instead.

10 years agohostbits: add more tests, include sigorder
Victor Julien [Sat, 13 Dec 2014 23:04:47 +0000 (00:04 +0100)] 
hostbits: add more tests, include sigorder

10 years agohostbits: implement sigorder
Victor Julien [Sat, 13 Dec 2014 23:04:14 +0000 (00:04 +0100)] 
hostbits: implement sigorder

Like with flowbits, make sure that 'set's are evaluated before
'isset's, etc.

10 years agodetect: hostbits keyword
Victor Julien [Fri, 12 Dec 2014 22:40:30 +0000 (23:40 +0100)] 
detect: hostbits keyword

Per host bit similar to 'flowbits'.

Initial code that uses just the 'src' ip for the operations.

10 years agoippair: track ippairs, enable tests
Victor Julien [Thu, 18 Dec 2014 22:33:03 +0000 (23:33 +0100)] 
ippair: track ippairs, enable tests

10 years agoprscript: rework option logic 1405/head
Eric Leblond [Fri, 13 Mar 2015 08:55:27 +0000 (09:55 +0100)] 
prscript: rework option logic

Handle cleanly the case where user start docker handling command
without having the dependency installed. The help message does
now say:

```
  -d, --docker          use docker based testing
  -C, --create          create docker container (disabled)
  -s, --start           start docker container (disabled)
  -S, --stop            stop docker container (disabled)

You need to install Python docker module to enable docker container handling
options.
```

And running a disabled options says:

```
$ qa/prscript.py -s
You need to install python docker to use docker handling features.
```

10 years agoprscript: fix error message in non local test
Eric Leblond [Thu, 12 Mar 2015 17:01:03 +0000 (18:01 +0100)] 
prscript: fix error message in non local test

Indicate to user that non local test needs a github user.

10 years agoprscript: improve command line
Eric Leblond [Thu, 12 Mar 2015 14:39:32 +0000 (15:39 +0100)] 
prscript: improve command line

You can now directly access to docker related command:

 qa/prscript.py -C # create container
 qa/prscript.py -s # start container
 qa/prscript.py -S # stop container

The build option does not change:

 qa/prscript.pu -l -d MY_BRANCH # build test of branch MY_BRANCH

10 years agoprscript: add notification system
Eric Leblond [Wed, 11 Mar 2015 18:56:12 +0000 (19:56 +0100)] 
prscript: add notification system

If Python pynotify is installed, prscript can now send notification
via the -n flag.

10 years agoprscript: improve wordings
Eric Leblond [Wed, 11 Mar 2015 18:15:14 +0000 (19:15 +0100)] 
prscript: improve wordings

10 years agoprscript: suppress useless message
Eric Leblond [Wed, 11 Mar 2015 18:08:37 +0000 (19:08 +0100)] 
prscript: suppress useless message

No build run faster than 2 seconds.

10 years agoprscript: iterate on builds when checking status
Eric Leblond [Wed, 11 Mar 2015 17:07:15 +0000 (18:07 +0100)] 
prscript: iterate on builds when checking status

This patch is changing the logic when using docker mode. We are
iterating over each builds so we know when one build is over in
the 5 seconds following the event instead of getting the result
when the builds that are checked before are others.

On OISF's build system, the two builds comes out in order so there
is no problem.

10 years agoprscript: read buildbot config from source
Eric Leblond [Wed, 11 Mar 2015 14:01:58 +0000 (15:01 +0100)] 
prscript: read buildbot config from source

This patch change the logic of the Docker buildbot system. The
buildbot configuration is now the one available in qa/docker
directory.

This way, developers can test features in docker buildbot that
could require some specific flags to be set. They just need to
edit the buildbot.cfg for instance to enable a new feature.

In the same way, the tested pcap files are the one which are in
the qa/docker/pcaps/ directory. So to test some private ones it is
enough to put them in that directory.

To take into consideration a buildbot.cfg modification or a new
pcap, it is enough to stop and restart the container:

 sudo qa/prscript.py -l -d -S master
 sudo qa/prscript.py -l -d -s master

This patch also fixes the container update issue. A local modification
to the buildbot will be kept. It is also fixing the issue when working
on old code that could possibly not support the same build flag as
the one of buildbot. Here the configuration will remains in sync.

10 years agoprscript: add a comment on the SELinux issue
Eric Leblond [Tue, 10 Mar 2015 18:55:23 +0000 (19:55 +0100)] 
prscript: add a comment on the SELinux issue

10 years agoprscript: add docker handling support
Eric Leblond [Tue, 10 Mar 2015 15:12:45 +0000 (16:12 +0100)] 
prscript: add docker handling support

You can now create the docker image necessary to run a
suricata builbot in docker. To do that you need to have
docker and python-docker installed on the system.

Then you can go to the qa directory.

You need to run once the creattion procedure:
 sudo ./prscript.py  -C -d master  -l
This will create a container named 'suri-buildbot'.

You can start it with:
 sudo ./prscript.py  -s -d master  -l

And stop it with:
 sudo ./prscript.py  -S -d master  -l

To start a test, you can do:
 ./prscript.py -d my_branch -l

10 years agoprscript: refactor for docker
Eric Leblond [Tue, 10 Mar 2015 12:15:15 +0000 (13:15 +0100)] 
prscript: refactor for docker

With the current work in progress on docker we need to update the
script to handle this case.

This patch adds two options:
 - -d to run in docker mode. In that case the build is started in
 the local dockerized buildbot instance
 - -l to not test the tested branch synchronization with github.

The -l option allows user to run a complete test without publishing
the code on github and without Internet access.

10 years agoDuplicate rule ID.
Jason Ish [Mon, 6 Apr 2015 23:05:16 +0000 (17:05 -0600)] 
Duplicate rule ID.

10 years agoDetectAddressParseString(): fix IPv6 address handling
Alexander Gozman [Mon, 23 Mar 2015 17:06:47 +0000 (20:06 +0300)] 
DetectAddressParseString(): fix IPv6 address handling

10 years agoprscript - fallback to json is simplejson not available.
Jason Ish [Tue, 17 Mar 2015 04:33:51 +0000 (22:33 -0600)] 
prscript - fallback to json is simplejson not available.

10 years agorules: add app layer events rules 1402/head
Eric Leblond [Thu, 2 Apr 2015 16:21:40 +0000 (18:21 +0200)] 
rules: add app layer events rules

Some application layer events are defined but the corresponding
rules were not available in the rules directory.

10 years agorunmodes: improve listing output 1401/head
Eric Leblond [Wed, 1 Apr 2015 15:59:54 +0000 (17:59 +0200)] 
runmodes: improve listing output

This patch removes some multiple line displayed before the
information about unix socket mode.

10 years agosuricata.yaml: add missing mpm-algo
Eric Leblond [Thu, 5 Mar 2015 10:09:03 +0000 (11:09 +0100)] 
suricata.yaml: add missing mpm-algo

10 years agorunmodes: fix typo in output
Eric Leblond [Wed, 1 Apr 2015 11:58:25 +0000 (13:58 +0200)] 
runmodes: fix typo in output

10 years agoflow-manager: don't set cpu affinity twice
Eric Leblond [Fri, 20 Mar 2015 09:24:39 +0000 (10:24 +0100)] 
flow-manager: don't set cpu affinity twice

It is already set in the thread creation function.

10 years agostream: fix bad last_ack update leading to gaps 1397/head
Victor Julien [Wed, 25 Mar 2015 21:29:10 +0000 (22:29 +0100)] 
stream: fix bad last_ack update leading to gaps

A bad last_ack update where it would be set beyond next_seq could
lead to rejection of valid segments and thus stream gaps.

Update tests to reflect new last_ack/next_seq behaviour.

10 years agodetect-state: cleanups and comments 1391/head
Victor Julien [Fri, 20 Mar 2015 20:58:50 +0000 (21:58 +0100)] 
detect-state: cleanups and comments

10 years agodetect-state: use f->protomap instead of FlowGetProtoMapping(f->proto)
Victor Julien [Fri, 20 Mar 2015 18:23:09 +0000 (19:23 +0100)] 
detect-state: use f->protomap instead of FlowGetProtoMapping(f->proto)

10 years agodetect-flowbits: locking update
Victor Julien [Fri, 20 Mar 2015 15:09:10 +0000 (16:09 +0100)] 
detect-flowbits: locking update

Make matches that can be in the POSTMATCH list aware of the lock hint.

10 years agodetect-flowint: conditional locking
Victor Julien [Fri, 20 Mar 2015 15:22:19 +0000 (16:22 +0100)] 
detect-flowint: conditional locking

10 years agodetect-state: handle 'post match' locking
Victor Julien [Fri, 20 Mar 2015 14:47:39 +0000 (15:47 +0100)] 
detect-state: handle 'post match' locking

The post match list was called with an unlocked flow until now.
However, recent de_state handling updates changed this. The stateful
detection code can now call the post match functions while keeping
the flow locked. The normal detection code still calls it with an
unlocked flow.

This patch adds a hint to the DetectEngineThreadCtx called
'flow_locked' that is set to true if the caller has already locked
the flow.

10 years agodetect-flowint: fix unlocked flow access
Victor Julien [Fri, 20 Mar 2015 14:23:18 +0000 (15:23 +0100)] 
detect-flowint: fix unlocked flow access

Some of the access to the flow and to structures retrieved from the
flow was unlocked.

This patch changes the logic to be wrapped in lock calls.

10 years agodetect-state: fix profiling
Victor Julien [Fri, 20 Mar 2015 13:30:00 +0000 (14:30 +0100)] 
detect-state: fix profiling

10 years agodns: optimize tx list walks
Victor Julien [Tue, 17 Mar 2015 22:05:07 +0000 (23:05 +0100)] 
dns: optimize tx list walks

The detection engine and log engines can walk the tx list indirectly,
by looping AppLayerParserGetTx. This would lead to new list walks in
the DNS tx list though. Leading to bad performance.

This patch stores the last returned tx and uses that to determine if
the next tx is what we need next. If so, we can return that w/o list
walk.

10 years agodetect-reload: enable unconditionally 1389/head
Victor Julien [Thu, 19 Mar 2015 16:20:27 +0000 (17:20 +0100)] 
detect-reload: enable unconditionally

Reloading is available unconditionally now.

10 years agodetect-reload: 0 detect threads is no error
Victor Julien [Mon, 16 Mar 2015 09:53:56 +0000 (10:53 +0100)] 
detect-reload: 0 detect threads is no error

The reload code would consider 0 detect threads to be an error,
but it's not in case of unix socket mode.

10 years agounix-socket: implement reload-rules
Victor Julien [Thu, 5 Mar 2015 15:25:09 +0000 (16:25 +0100)] 
unix-socket: implement reload-rules

Implement the reload-rules unix socket command. The unix command
thread signals the main thread to do the reload and it waits for
it to complete.

10 years agodetect reload: load config
Victor Julien [Thu, 5 Mar 2015 12:04:33 +0000 (13:04 +0100)] 
detect reload: load config

Load the YAML into a prefix "detect-engine-reloads.N" where N is the
reload counter. This way we can load the updated config w/o overwriting
the current one.

10 years agodetect: remove config at prefix
Victor Julien [Thu, 5 Mar 2015 12:00:33 +0000 (13:00 +0100)] 
detect: remove config at prefix

Remove config at prefix when freeing a detect engine.

10 years agorule vars: support prefix
Victor Julien [Mon, 2 Mar 2015 07:59:44 +0000 (08:59 +0100)] 
rule vars: support prefix

Support the detection engine's prefix when retrieving rule vars.

10 years agorule-vars: take detect engine as arg
Victor Julien [Sun, 1 Mar 2015 19:30:01 +0000 (20:30 +0100)] 
rule-vars: take detect engine as arg

10 years agodetect:pass DetectEngineCtx to port parsing
Victor Julien [Sun, 1 Mar 2015 11:34:11 +0000 (12:34 +0100)] 
detect:pass DetectEngineCtx to port parsing

Preparation for prefix handling in port parsing.

10 years agodetect: pass DetectEngineCtx to address parsing
Victor Julien [Sun, 1 Mar 2015 10:02:33 +0000 (11:02 +0100)] 
detect: pass DetectEngineCtx to address parsing

Preparation for prefix handling in address parsing.

10 years agodetect: initialize detection engine by prefix
Victor Julien [Fri, 16 Jan 2015 16:46:16 +0000 (17:46 +0100)] 
detect: initialize detection engine by prefix

Initalize detection engine by configuration prefix.

    DetectEngineCtxInitWithPrefix(const char *prefix)

Takes the detection engine configuration from:
<prefix>.<config>

If prefix is NULL the regular config will be used.

Update sure that DetectLoadCompleteSigPath considers the prefix when
retrieving the configuration.

10 years agoconf: add ConfYamlLoadFileWithPrefix
Victor Julien [Tue, 13 Jan 2015 10:59:21 +0000 (11:59 +0100)] 
conf: add ConfYamlLoadFileWithPrefix

Add function to load a yaml file and insert it into the conf tree at
a specific prefix.

Example YAML:
somefile: myfile.txt

If loaded using ConfYamlLoadFileWithPrefix with prefix "myprefix", it
can be retrieved by the name of "myprefix.somefile".

10 years agodetect: allow det_ctx->de_ctx to be NULL
Victor Julien [Thu, 29 Jan 2015 10:16:49 +0000 (11:16 +0100)] 
detect: allow det_ctx->de_ctx to be NULL

When freeing det_ctx, allow de_ctx to be NULL.

10 years agodetect: reload thread init cleanup
Victor Julien [Tue, 27 Jan 2015 11:33:21 +0000 (12:33 +0100)] 
detect: reload thread init cleanup

Rename the thread init function DetectEngineThreadCtxInitForLiveRuleSwap
to DetectEngineThreadCtxInitForReload and change it's logic to take the
new detection engine as argument and let it return the
DetectEngineThreadCtx or NULL on error.

The old approach used the thread init API format, but it wasn't used in
that way.

10 years agodetect reload: allow master update during reload
Victor Julien [Tue, 27 Jan 2015 10:30:08 +0000 (11:30 +0100)] 
detect reload: allow master update during reload

Add DetectEngineReference, which takes a reference to a detect engine,
and make DetectEngineThreadCtxInitForLiveRuleSwap use it. This way
reload will not depend on master staying the same. This allows master
to be updated in between w/o affecting the reload that is in progress.

10 years agodetect: remove old live reload implementation
Victor Julien [Sat, 17 Jan 2015 09:53:54 +0000 (10:53 +0100)] 
detect: remove old live reload implementation

Remove code that ran the reload in it's own thread. Simplify the
signal handling.

10 years agodetect: move reload into main loop
Victor Julien [Mon, 19 Jan 2015 21:09:59 +0000 (22:09 +0100)] 
detect: move reload into main loop

Use new DetectEngineReload() function. It's called from the main loop
instead of it being spawned into it's own temporary thread. This greatly
simplifies the signal handling.

An added advantage is that this seems to improve the memory usage.

Related to bug #1358

10 years agodetect: introduce 'minimal' detect engine
Victor Julien [Mon, 19 Jan 2015 13:54:11 +0000 (14:54 +0100)] 
detect: introduce 'minimal' detect engine

The minimal detect engine has only the minimal memory use and setup
time. It's to be used for 'delayed' detect where the first detection
engine is essentially empty.

The threads setup are also minimal.

10 years agothreading: remove 'dummy' slot logic
Victor Julien [Mon, 19 Jan 2015 11:11:22 +0000 (12:11 +0100)] 
threading: remove 'dummy' slot logic

Now that delayed detect is not using it anymore, the dummy logic
can be removed.

10 years agodetect: unify delayed detect and reload
Victor Julien [Mon, 19 Jan 2015 11:08:55 +0000 (12:08 +0100)] 
detect: unify delayed detect and reload

Instead of threading logic with dummy slots and all, use the regular
reload logic for delayed detect.

This means we pass a empty detect engine to the threads and then
reload (live swap) it as soon as the engine is running.