Commit Graph

5447 Commits (21db5ee691b349d3da1925b703ea5200d736e40a)

Author SHA1 Message Date
Victor Julien 50bb995458 counters: rename threadvars public counters 11 years ago
Victor Julien 6ffbc3a362 counters: s/SCPerfContext/SCPerfPublicContext/g 11 years ago
Victor Julien 0a5ae1b403 counters: s/SCPerfCounterArray/SCPerfPrivateContext/g
Goal is to make it's purpose clear.
11 years ago
Victor Julien 9f584483be counters: minor cleanups 11 years ago
Victor Julien 1e8142c699 logfile: rename ALERT_ types to LOGFILE_TYPE_ 12 years ago
Eric Leblond 4c6a7bea30 output-json: suppress global variable
It uses the new type field in the LogFileCtx instead.

This fixes the problem of not being able to use two eve-json
instance with different logging methods.
12 years ago
Eric Leblond 636e3d93c0 log file: add type flag
It will be used to store if the file is syslog or a real file.
12 years ago
Eric Leblond 39d667ff56 output-json: fix type of data parameter
The cast of data to AlertJsonThread was not correct as the real
type of the void pointer is a OutputJsonCtx. This was working by
luck because they both have a file_ctx as first element.
12 years ago
Alexander Gozman f11e237d77 Feature #1440: support wildcards in rule filenames 12 years ago
David Cannings 4f8f53d080 Fix rcode parsing, as noticed by Coverity.
Without support for OPT RR from RFC6891 (Extension mechanisms for DNS)
values of RCODE above 15 are not possible.  Remove dead code which will
never match.
12 years ago
Jason Ish 9fdae82815 conf - process includes even if not at root node. 12 years ago
Jason Ish 56f6e37304 radix-tree - prevent out of bounds array access
An IPv6 entry specified before an IPv4 entry on the host-os-policy
table can cause the stream byte array to be access one byte after
the end of the allocated memory at util-radix-tree.c:578.
12 years ago
Jason Ish 3e5b8f48b1 Bug 1281 - Add tests for rule content of lengths > 255. 12 years ago
Jason Ish e2b04635a7 Bug 1281 - Accept rule content with lengths greater than 255. 12 years ago
Victor Julien 0e22e95e47 alert-json: fix stream logging for IPS mode
Switch direction in IPS mode.
12 years ago
Victor Julien 5037ea93f3 threads: add untimed control cond call
The control conditions so far could only do timed waits, not normal
waits.
12 years ago
Victor Julien c7bc9ae6a8 detect: minor cleanups 12 years ago
Victor Julien bc2b53f10b parsing: s/strtok/strtok_r/g
Remove all strtok uses and replace them by strtok_r.

Do the same for Windows builds. Cygwin builds fine with strtok_r.

Add strtok to banned function list.
12 years ago
Victor Julien fb479902e4 threading: explain purpose of threadvars mucond 12 years ago
Victor Julien 478719ee9d flow: don't hold tv_root_lock longer than needed
Don't hold it longer than needed in shutting down.
12 years ago
Victor Julien c96805e839 threading: remove unused cmd thread create func 12 years ago
Victor Julien df5e9d44ca unix-manager: convert to thread module
Sync command thread for unix manager with other managers and make
it a full thread module.
12 years ago
Victor Julien cc01b5f6b6 reference/classification: call global init for unittests 12 years ago
Victor Julien 34f2ff067b reference: update pcre globals use
Don't update globals each time we parse, but instead do it once at
startup.
12 years ago
Victor Julien 46d401e3bb classification: update pcre globals use
Don't update globals each time we parse, but instead do it once at
startup.
12 years ago
Victor Julien b2da57c827 reference: remove global 12 years ago
Victor Julien 393689ce44 classification: remove global from parsing
Parsing code used a 'fd' global. Remove this.
12 years ago
Victor Julien 9764a35604 stream: fix --disable-detection reassembly issue
Due to an error at initialization, the stream engine would not disable
'raw' reassembly automatically when --disable-detection was used.

This lead to segments not getting cleared from the segment lists.
12 years ago
Victor Julien c1558f5ac4 stream: remove FLOW_NO_APPLAYER_INSPECTION flag
Instead, intruduce StreamTcpDisableAppLayer to disable app layer
tracking and reassembly. StreamTcpAppLayerIsDisabled can be used
to check it.

Replace all uses of FlowSetSessionNoApplayerInspectionFlag and
the FLOW_NO_APPLAYER_INSPECTION.
12 years ago
Victor Julien b6798495c5 stream: remove FLOW_NO_APPLAYER_INSPECTION use from tests 12 years ago
Victor Julien b2e1854e2a stream: improve 'no app layer' handling
When the session/flow was flagged as 'no applayer inspect', which
could happen as a result various reasons, packets would still be
considered by the app layer reassembly.

When ACK'd, they would be removed again. Depending also on the raw
reassembly.

In very long sessions however, this meganism could fail leading to
virtually endlessly growing segment lists.

This patch makes sure that segments that come in on a 'no app layer'
session are tagged properly or even not added at all.

Use a new ssn flag instead of flow flag for no app tracking.
12 years ago
Victor Julien 22a810813c app-layer: add DisableAppLayer
Move various app layer related flag setting calls into a utility
function "DisableAppLayer"
12 years ago
Victor Julien f536099a67 app-layer: de_state optimization
Add API to bypass expensive TX list walks. This API call is optional.

Implement it for HTTP and DNS.
12 years ago
Victor Julien 5f0678120d detect-state: update test to check state storing 12 years ago
Victor Julien 37f0bd57b6 detect-state: handle duplicate inspect/match
If for a packet we have a TX N that has detect state and a TX N+1 that
has no detect state, but does have 'progress', we have a corner case
in stateful detection.

ContinueDetection inspects TX N, but cannot flag the rule in the
de_state_sig_array as the next (TX N+1) has already started and needs
to be inspected. 'StartDetection' however, is then unaware of the fact
that ContinueDetection already inspected the rule. It uses the per
session 'inspect_id' that is only moved forward at the end of the
detection run.

This patch adds a workaround. It uses the DetectEngineThreadCtx::
de_state_sig_array to store an offset between the 'base' inspect_id
and the inspect_id that StartDetection should use. The data type is
limited, so if the offset would be too big, a search based fall back
is implemented as well.
12 years ago
Victor Julien bc6e4140be detect: add de_state duplication check
Add test to check if no duplicate destate is created.

Only enabled with DEBUG_VALIDATION.
12 years ago
Victor Julien 9d198e6662 detect-state: fix state storing
Fix storing state and bypassing detection. Previously we'd store
on a match only, meaning that StartDetection would rerun often.

Make sure StartDetection only stores if there is something to store.
12 years ago
Victor Julien 359e2d68f5 detect-http-header: improve buffer handling
Previously we could never be calling DetectEngineHHDGetBufferForTX
for TX N and then afterwards for TX N - 1. Due to changes in the
stateful detection code this is now possible.

This patch changes the buffer logic to take the 'inspect_id' as it's
base, instead of the first transaction that we are called with.
12 years ago
Victor Julien 62e937672d detect-events: set SIG_MASK_REQUIRE_*_STATE for events
Set SIG_MASK_REQUIRE_*_STATE for event rules to earlier discard
them.
12 years ago
Victor Julien 8d0b090150 engine-analysis: print fast_pattern summary
When using engine analysis for print fast_pattern stats, print a
short summary at the end containing per buffer:
- smallest fp
- biggest fp
- number of patterns
- avg fp len
12 years ago
Victor Julien 21f9328989 lua: fix error handling 12 years ago
Victor Julien 52195a4192 http: add event for leading spaces on request line
Libhtp will issue a warning in this case, so we can match on this.
This patch adds event, rule and unittest.
12 years ago
Victor Julien 2f85308afe threads: fix missing unlock in error handling
If TmThreadsUnregisterThread was called with out of range 'id', a lock
would not be cleared after returning from the function.

** CID 1264421:  Missing unlock  (LOCK)
/src/tm-threads.c: 2186 in TmThreadsUnregisterThread()
12 years ago
Eric Leblond 0303245761 af-packet: use max packet size as snaplen
If default_packet_size is set to 0, then we use the maximum packet
size as snaplen.
12 years ago
Eric Leblond 43f691fef8 util-device: fix LiveBuildDeviceListCustom
The code was assuming that the dictionnary containing the parameter
of a interface was ordered. But for YAML, the order is not assumed
so in case the configuration is generated we may not be able to
parse correctly the configuration file.

By iterating on child on main node and then iterating on subchild
and doing a match on the name, we are able to find the interface
list. In term of code, this algorithm was obtained by simply
removing the test on the name of the first child.
12 years ago
Eric Leblond 268285c49f output-json-http: output status as an integer
HTTP status is an integer and it should be written as such in the
JSON events. This will allow to have improved matching in log
analysis tools.
12 years ago
Eric Leblond 58582df1c6 decode-der: decode DC keyword
'DC' is used by some certificates and it was not currently translated
to a string.
12 years ago
Giuseppe Longo 26ba647d58 filedata: read inspected tracker settings from suricata.yaml 12 years ago
Giuseppe Longo 4b5848616f filedata: implement inspected tracker 12 years ago
Giuseppe Longo 1f52410d0f UT: implement tests for inspection code 12 years ago
Giuseppe Longo d2657becc9 app-layer-smtp: make functions as public 12 years ago
Giuseppe Longo 84dc73d9de mpm: implement prefiltering for smtp 12 years ago
Giuseppe Longo f0c54d4764 Detect engine for smtp file_data file_data: inspecting smtp attachments
Create a buffer to store reassembled file chunks,
and inspect the content.
12 years ago
Giuseppe Longo b9468aba7c FileData: add stream_offset field
This is required to store the offset for reassembling chunks.
12 years ago
Giuseppe Longo 68cf3dd621 file_data: register keyword for smtp and tcp protocol
Permits to use file_data keyword with smtp or tcp proto.
Also adds some unit tests
12 years ago
Giuseppe Longo 04561f13d3 signature: set flags and test the protocol
This checks if the signature's protocol is http
when setup the content keyword.

Also sets the proper flags based by protocol
since the flag SIG_FLAG_TOSERVER has to be set
if the proto is smtp, otherwise SIG_FLAG_TOCLIENT
is it's http.
12 years ago
Giuseppe Longo 41a1a9f4af find and replace HSBDMATCH by FILEDATA
This commit do a find and replace of the following:

- DETECT_SM_LIST_HSBDMATCH by DETECT_SM_LIST_FILEDATA
  sed -i 's/DETECT_SM_LIST_HSBDMATCH/DETECT_SM_LIST_FILEDATA/g' src/*

- HSBD by FILEDATA:
  sed -i 's/HSBDMATCH/FILEDATA/g' src/*
12 years ago
Ken Steele eac83be121 Formatting cleanup in detect-replace.c
Wrap lines longer than 80 characters
Add "static" for unit tests.
Use (void) for () for function arguments.
Add space after "while(" -> "while ("
Remove space after function names.
Put open bracket of function on a new line.
12 years ago
Ken Steele ddec92676d Add a comment for DetectReplaceList
Reworded a quote in PR 742 by Regit from Inliniac to explain why adding
the head of the list (really a FIFO) is the correct behavior.
12 years ago
Ken Steele cf9da2be15 Fix DetectReplaceAddToList
I see two problems:
1) If allocating a newlist fails, the function returns NULL, which then
   leaks any existing list elements.
2) The code to add the new value to the list works for the first two, but
   for not the third. For example, replist=A, A->next=B, B->next=NULL, then
   adding C results in replist=A, A->next=C, C->next=NULL, B is lost.

The fix pushes new values onto the head of the list, which might not be
what is needed, but there are no comments on what the function does, so I
made an assumption.
12 years ago
Alexander Gozman d44eab82c1 Fix bug #1435 (data loss when dumping payloads to JSON) 12 years ago
Zachary Rasmor f0c659f82f Fix Bug #1204
Fix typo that causes eve syslog settings code to be unreachable.
12 years ago
Victor Julien 208d27abc7 stream: next_seq handling improvements
Allow next_seq updating to recover from cases where last_ack has been
moved beyond it. This can happen if ACK's have been accepted for missing
data that is later retransmitted.

This undoes some of the previous last_ack update changes
12 years ago
Alexander Gozman b12c53cd51 Add timezone to timestamp in JSON logs 12 years ago
David Cannings 2918a75da1 Added support for full parsing of the rcode header in DNS answer
packets. Where rcode isn't "no error" this is displayed in both DNS and
JSON logs.

Note that this changes the current "No such domain" to "NXDOMAIN" in DNS
logs. This could be fixed if desired to maintain compatibility with
anybody crazy enough to parse the DNS log.

When the rcode is not "no error" (for example NXDOMAIN or SERVFAIL) it
is unlikely that there will be answer RRs. Therefore the rname from the
query is used.

Because the rcode applies to a whole answer packet (not individual
queries) it is impossible to determine which query RR caused the error.
Because of this most DNS servers currently reject multiple queries per
packet. Therefore each query RR is output instead with the relevant
error code, likely to be FORMERR if queries > 1.
12 years ago
Victor Julien cf839c931f tls: force 'raw' reassembly after each record
Trigger raw reassembly after each record and after the handshake.
12 years ago
DIALLO David 04f3f5066d app-layer-modbus: fix deadlock in parsers 12 years ago
Victor Julien 6d170cadd7 smtp: fix mime boundary parsing issue
If a boundary was longer than 254 bytes a stack overflow would result
in mime decoding.

Ticket #1449

Reported-by: Kostya Kortchinsky of the Google Security Team
12 years ago
Victor Julien a4a1c396e1 pcap-file: fix malformed timestamp crash
A bad timestamp would lead to SCLocalTime returning NULL. This case
wasn't checked, leading to a NULL deref.

Reported-by: Kostya Kortchinsky of the Google Security Team
12 years ago
Pierre Chifflier fa73a0bb8f Fix possible wrap in uint32_t addition in DER parser
Signed-off-by: Pierre Chifflier <pierre.chifflier@ssi.gouv.fr>
12 years ago
Victor Julien a2d0441380 Bug 1340: fix missing flow cleanup
Fix missing flow output cleanup function leading to a crash in the
unix socket mode.
12 years ago
Victor Julien 04ccfda639 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
12 years ago
Tom DeCanio 97a2d1ac26 fix reputation parser so that it accepts ipv6 addresses in configuration file. 12 years ago
Jason Ish 11d6770ae4 afl - SCHINfoLoadFromConfig - check for NULL before parsing.
Found by AFL on suricata.yaml.
12 years ago
Jason Ish 75d21851cf afl - Don't fail if app-layer proto enabled value is NULL.
Found by using AFL on suricata.yaml.
12 years ago
Eric Leblond 0376b60da9 email-json: free temporary 'cc' string 12 years ago
Eric Leblond bd67000b69 email-json: free temporary 'to' string 12 years ago
Eric Leblond 7b8184947a app-layer-smtp: fix SMTPTransactionFree function
A typo was causing some freeing tasks not to be executed.
12 years ago
Victor Julien 91ddf85323 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.
12 years ago
Victor Julien 1a83fee5f5 xbits: fix coverity warnings
Switch statement would contain NOALERT even though this was
unreachable.
12 years ago
Victor Julien 54d5e2eed5 coverity fix: don't do pointer check on static array 12 years ago
Victor Julien b9aaf5a9ab 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.
12 years ago
Victor Julien 94321b8a2f 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.
12 years ago
Victor Julien 22142d9b8b threshold: cleanups
Use pcre_copy_substring in the most common part of threshold rule
parsing. Minor other cleanups.
12 years ago
Victor Julien e86e1e0282 reference: use pcre_copy_substring 12 years ago
Victor Julien cc38df8074 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.
12 years ago
Victor Julien deb98fab0c 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.
12 years ago
Victor Julien 1884227019 autofp: reduce flow storage space requirement
Use int16_t instead of a regular int to safe 2 bytes per flow.
12 years ago
Victor Julien 643c30f67f threading: add missing locks to threading storage
Lock threading root lock when walking or updating the threading
storage for 'ThreadVars' objects.
12 years ago
maxtors e7658fd4f4 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.
12 years ago
maxtors 3b26b07963 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.
12 years ago
maxtors 7a9e963619 Added http methods for webdav (rfc4918).
Included the following methods to app-layer-htp.c:
- PROPFIND
- PROPPATCH
- MKCOL
- COPY
- MOVE
- LOCK
- UNLOCK
12 years ago
maxtors a7abaf538c 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.
12 years ago
Victor Julien 915eb992ca 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.
12 years ago
David Maciejak 48971afdfb Fix Unit ID check 12 years ago
Eric Leblond f35001a614 util-running-mode: setup config file
Without that we get warning message.
12 years ago
Eric Leblond 6f5c4c12e1 list keywords: fix regression on app layer name
It was not anymore displayed.
12 years ago
Eric Leblond d98060410c 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.
12 years ago
Alexander Gozman 568635c2e1 Reject ICMP traffic, not only TCP/UDP 12 years ago
Jason Ish 1f9d9256e7 spelling - dubbed -> duped (for duplicate) 12 years ago
Jason Ish 8911b04077 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.
12 years ago
Jason Ish da88b3b787 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.
12 years ago
Jason Ish ca60d8c370 ParseSizeString - don't abort on unknown unit type. 12 years ago
Victor Julien 00d6298666 host: handle timeout
Set expiration for regular hostbits keyword.
12 years ago
Victor Julien ab7882fbf3 ippair: handle timeouts in the flow manager
Like host and defrag, handle timeouts of ippair in the first flow
manager thread.
12 years ago
Victor Julien e8a5925012 ippair: implement basic timeout check
The only user is the xbits subsys, so it's timeout controls all.
12 years ago
Victor Julien f2349e10ad 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.
12 years ago
Victor Julien 67dd5c0430 host: implement hostbits/xbits expire 12 years ago
Victor Julien ca1f3e68d4 ippair: implement xbits expiration 12 years ago
Victor Julien fbdcffabc2 xbits: expire (first steps) 12 years ago
Victor Julien 7b79b9458d xbits: implement ip_src/ip_dst support
Just a wrapper for regular 'hostbits'.
12 years ago
Victor Julien 57d93cbcfe hostbits: prepare for xbits integration 12 years ago
Victor Julien 8e6453faac xbits: prepare for non-ippair support 12 years ago
Victor Julien dea8dda3c1 vars: redo var name <-> idx handling
Can't use sm type anymore as multiple var carriers (host/flow/etc) will
all have xbits.
12 years ago
Victor Julien f77c3d9a2c xbits: hostbits use xbits type
Make hostbits use xbits type.
12 years ago
Victor Julien a716dded04 xbit: move to util-var
We can reuse the type for hostbits and flowbits as well.
12 years ago
Victor Julien 61cb2abc8d ippair: xbit implementation
detect xbits for ippair: initial implementation
12 years ago
Victor Julien 4c6d564211 hostbits: unittest cleanups 12 years ago
Victor Julien 2cb0df7cf9 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.
12 years ago
Victor Julien be725a5ba2 hostbits: add more tests, include sigorder 12 years ago
Victor Julien d67fd306f8 hostbits: implement sigorder
Like with flowbits, make sure that 'set's are evaluated before
'isset's, etc.
12 years ago
Victor Julien 5c880377ae detect: hostbits keyword
Per host bit similar to 'flowbits'.

Initial code that uses just the 'src' ip for the operations.
12 years ago
Victor Julien 99ae643e4e ippair: track ippairs, enable tests 12 years ago
Alexander Gozman 45ba20bcb0 DetectAddressParseString(): fix IPv6 address handling 12 years ago
Eric Leblond 605ef33972 runmodes: improve listing output
This patch removes some multiple line displayed before the
information about unix socket mode.
12 years ago
Eric Leblond e5ae808b0f runmodes: fix typo in output 12 years ago
Eric Leblond ef3290bb2e flow-manager: don't set cpu affinity twice
It is already set in the thread creation function.
12 years ago
Victor Julien 8e83d0073e 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.
12 years ago
Victor Julien 4e177bc9d6 detect-state: cleanups and comments 12 years ago
Victor Julien 304c711a27 detect-state: use f->protomap instead of FlowGetProtoMapping(f->proto) 12 years ago
Victor Julien e1efa7a0b5 detect-flowbits: locking update
Make matches that can be in the POSTMATCH list aware of the lock hint.
12 years ago
Victor Julien 4609495c60 detect-flowint: conditional locking 12 years ago
Victor Julien 5111aa2ec0 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.
12 years ago
Victor Julien 9bcb02119f 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.
12 years ago
Victor Julien 18f0351d9b detect-state: fix profiling 12 years ago
Victor Julien 0b262cbfda 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.
12 years ago
Victor Julien 0704ece4d7 detect-reload: enable unconditionally
Reloading is available unconditionally now.
12 years ago
Victor Julien 724c7044e1 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.
12 years ago
Victor Julien 7c9e015748 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.
12 years ago
Victor Julien 71d01f06b9 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.
12 years ago
Victor Julien b51075e804 detect: remove config at prefix
Remove config at prefix when freeing a detect engine.
12 years ago
Victor Julien 85e12f2bc6 rule vars: support prefix
Support the detection engine's prefix when retrieving rule vars.
12 years ago
Victor Julien 0bc27c7dc7 rule-vars: take detect engine as arg 12 years ago
Victor Julien 3083f51cc6 detect:pass DetectEngineCtx to port parsing
Preparation for prefix handling in port parsing.
12 years ago
Victor Julien 2be9ccfe9c detect: pass DetectEngineCtx to address parsing
Preparation for prefix handling in address parsing.
12 years ago
Victor Julien 7108085d33 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.
12 years ago
Victor Julien 97d77e3540 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".
12 years ago
Victor Julien a80cc696d7 detect: allow det_ctx->de_ctx to be NULL
When freeing det_ctx, allow de_ctx to be NULL.
12 years ago
Victor Julien c9a8262ccf 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.
12 years ago
Victor Julien 55e7370fc5 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.
12 years ago