]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
11 years agodns: if no (valid) config is found, use defaults 841/head
Victor Julien [Thu, 13 Feb 2014 14:53:08 +0000 (15:53 +0100)] 
dns: if no (valid) config is found, use defaults

This patch will set up probing parsers if no (valid) config is
found.

Add a warning in those cases.

11 years agoapp-layer: tell pp registrar if config was found
Victor Julien [Thu, 13 Feb 2014 14:48:35 +0000 (15:48 +0100)] 
app-layer: tell pp registrar if config was found

The probing parser registration function
AppLayerProtoDetectPPParseConfPorts was a void, meaning it would
give no feedback to the registering protocol implementation. If a
config was missing, it would just give up.

This patch changes it to return a bool. 0 if no config was found,
1 if a config was found.

This allows the caller to setup a default case.

11 years agodns yaml: fix detect ports of tcp relying on udp
Victor Julien [Thu, 13 Feb 2014 14:15:53 +0000 (15:15 +0100)] 
dns yaml: fix detect ports of tcp relying on udp

The probing parser detection ports yaml settings of the TCP part
of the DNS parser accidentally used udp as protocol string, causing
the wrong part of the YAML to be evaluated.

11 years agoapp-layer-event: make error reporting more clear
Victor Julien [Thu, 13 Feb 2014 14:02:57 +0000 (15:02 +0100)] 
app-layer-event: make error reporting more clear

If the protocol is disabled, app-layer-event would print a cryptic
error message. This patch makes sure we inform the user the protocol
is in fact disabled.

11 years agodns: fix message of decoder rule 2240008
Victor Julien [Thu, 13 Feb 2014 13:41:54 +0000 (14:41 +0100)] 
dns: fix message of decoder rule 2240008

The message now reflects that the rule matches on:
    app-layer-event:dns.state_memcap_reached;

11 years agoyaml: add and comment missing dns settings
Victor Julien [Thu, 13 Feb 2014 13:36:45 +0000 (14:36 +0100)] 
yaml: add and comment missing dns settings

DNS memcap settings "global-memcap" and "state-memcap" were missing.

Additionally, add request-flood setting.

11 years agoUpdate Changelog for 2.0rc1 release suricata-2.0rc1
Victor Julien [Thu, 13 Feb 2014 10:14:40 +0000 (11:14 +0100)] 
Update Changelog for 2.0rc1 release

11 years agovlan/QinQ: add vlan_qinq counter 840/head
Victor Julien [Tue, 11 Feb 2014 08:44:26 +0000 (09:44 +0100)] 
vlan/QinQ: add vlan_qinq counter

This patch introduces a new counter "decoder.vlan_qinq". It counts
packets that have more than two stacked vlan layers.

Packets with 2 vlan layers will both increment "decoder.vlan" and
"decoder.vlan_qinq".

11 years agoeve-log: add warning if enabled but not supported
Victor Julien [Tue, 11 Feb 2014 06:44:42 +0000 (07:44 +0100)] 
eve-log: add warning if enabled but not supported

If we're not compiled against libjansson, the eve-log output is not
available. This patch adds a warning.

11 years agoPromote nodes set with --set to sequence nodes as needed. 839/head
Jason Ish [Mon, 10 Feb 2014 20:47:43 +0000 (14:47 -0600)] 
Promote nodes set with --set to sequence nodes as needed.

A node isn't known to be a sequence node until the YAML is parsed.
If a node sequence node was set on the command line, promote
it to a sequence node when it is discovered by YAML to be
a sequence node.

Fixes comment #18 in issue 921.

11 years agovlan: support QinQ ethernet types 838/head
Victor Julien [Mon, 10 Feb 2014 10:13:11 +0000 (11:13 +0100)] 
vlan: support QinQ ethernet types

Add support for 802.1AD and 802.1QinQ in ethernet and vlan parsing.

Tickets: #814, #1103, #1104

11 years agodefrag: fix reassembly with vlan
Victor Julien [Mon, 10 Feb 2014 09:57:46 +0000 (10:57 +0100)] 
defrag: fix reassembly with vlan

When creating a pseudo packet with the reassembled IP packet, the
parent's vlan id or id's are also needed. The defrag packet is run
through decode and the flow engine, where the vlan id is necessary
for connecting the packet to the correct flow.

11 years agoaf-packet: declare TP_STATUS_VLAN_VALID if needed
Eric Leblond [Sat, 8 Feb 2014 21:01:13 +0000 (22:01 +0100)] 
af-packet: declare TP_STATUS_VLAN_VALID if needed

Some old distribution don't ship recent enough linux header. This
result in TP_STATUS_VLAN_VALID being undefined. This patch defines
the constant and use it as it is used in backward compatible method
in the code: the flag is not set by kernel and a test on vci value
will be made.

This should fix https://redmine.openinfosecfoundation.org/issues/1106

11 years agoBug 1107: decoders: bail out on pseudo packets
Victor Julien [Sat, 8 Feb 2014 16:39:16 +0000 (17:39 +0100)] 
Bug 1107: decoders: bail out on pseudo packets

Flow-timeout code injects pseudo packets into the decoders, leading
to various issues. For a full explanation, see:
  https://redmine.openinfosecfoundation.org/issues/1107

This patch works around the issues with a hack. It adds a check to
each of the decoder entry points to bail out as soon as a pseudo
packet from the flow timeout is encountered.

Ticket #1107.

11 years agoFlow: fix flow reference cnt issues
Victor Julien [Sat, 8 Feb 2014 16:09:10 +0000 (17:09 +0100)] 
Flow: fix flow reference cnt issues

FlowReference stores the flow in the destination pointer and increases
the flow reference counter (use_cnt). This should only be called once
per destination pointer. The reference counter is decremented when
FlowDereference is called. Multiple FlowReference calls would lead to
multiple use_cnt bumps, while there would be only one FlowRereference.
This lead to a use_cnt that would never become 0, meaning the flow
would stay in the hash for the entire lifetime of the process.

The fix here is to check if the destination pointer is already set to
the flow. If so, we don't increase the reference counter.

As this is really a bug, this condition will lead to a BUG_ON if the
DEBUG_VALIDATION checking is enabled.

11 years agoipv4 decoder: set 'invalid' event on icmpv6
Victor Julien [Sat, 8 Feb 2014 10:25:13 +0000 (11:25 +0100)] 
ipv4 decoder: set 'invalid' event on icmpv6

ICMPv6 on IPv4 is invalid, so if we encounter this we set an event
and flag the packet as invalid.

Ticket #1105.

11 years agodebug-validation: fix packet check
Victor Julien [Sat, 8 Feb 2014 09:35:47 +0000 (10:35 +0100)] 
debug-validation: fix packet check

On fragments and invalid packets we can have p->proto set, while the
matching protocol header pointer is null.

11 years agodetect ip-only: update radix usage 835/head
Victor Julien [Fri, 20 Dec 2013 13:38:22 +0000 (14:38 +0100)] 
detect ip-only: update radix usage

Update IP-only lookups to the changed radix API.

The return of user_data is treated as a succesful lookup, instead of
the node.

11 years agohost-os-info: update radix lookups
Victor Julien [Fri, 20 Dec 2013 13:37:10 +0000 (14:37 +0100)] 
host-os-info: update radix lookups

Update host OS lookups to use the new API.

The return of user_data is treated as a succesful lookup, instead of
the node.

11 years agounused reputation: radix update
Victor Julien [Fri, 20 Dec 2013 13:36:14 +0000 (14:36 +0100)] 
unused reputation: radix update

Update the unused reputation code to compile after radix update.

11 years agodefrag: update radix usage
Victor Julien [Fri, 20 Dec 2013 13:34:48 +0000 (14:34 +0100)] 
defrag: update radix usage

Update defrag timeout lookup to use the updated radix API.

The return of user_data is treated as a succesful lookup, instead of
the node.

11 years agoradix: update HTP config lookup logic
Victor Julien [Fri, 20 Dec 2013 13:32:33 +0000 (14:32 +0100)] 
radix: update HTP config lookup logic

The HTP config tree is a radix. The lookups are updated to the new API.
The return of user_data is treated as a succesful lookup, instead of
the node itself.

11 years agoradix: update tests after API change
Victor Julien [Fri, 20 Dec 2013 13:29:13 +0000 (14:29 +0100)] 
radix: update tests after API change

This patch updates all the radix tests to the new API. In most cases
it just passes a NULL user data return pointer.

It also removes the tests related to SC_RADIX_NODE_USERDATA, as this
macro is removed.

Bug #1073

11 years agoradix: don't modify node prefix on lookup
Victor Julien [Fri, 20 Dec 2013 13:19:23 +0000 (14:19 +0100)] 
radix: don't modify node prefix on lookup

The radix tree stores user data. However, it had no function to return
this data to the consumers of the API. Instead, on lookup, it would
set a field "user_data_result" in the nodes prefix structure which
could then be read by the caller.

Apart for this not being a very nice design as it exposes API internals
to the caller, it is not thread safe. By updating the global data
structure without any form (or suggestion) of locking, threads could
overwrite the same field unexpectedly.

This patch modifies the lookup logic to get rid of this stored
user_data_result. Instead, all the lookup functions how take an
addition argument: void **user_data_result.

Through this pointer the user data is returned. It's allowed to be
NULL, in this case the user data is ignored.

This is a significant API change, that affects a lot of tests and
callers. These will be updated in follow up patches.

Bug #1073.

11 years agoDon't alert on valid ICMP6 solicit/advert messages.
Jason Ish [Wed, 5 Feb 2014 23:27:42 +0000 (17:27 -0600)] 
Don't alert on valid ICMP6 solicit/advert messages.

Handles ND_ROUTER_SOLICIT, ND_ROUTER_ADVERT, ND_NEIGHBOUR_ADMIN,
ND_NEIGHBOUR_SOLICIT and ND_REDIRECT.  Don't set ICMPV6_UNKONWN_CODE
if code is the expected value of 0.

11 years agoRemove extra ] configure.ac for HAVE_DETECT_DISABLED
Ken Steele [Thu, 6 Feb 2014 18:23:43 +0000 (13:23 -0500)] 
Remove extra ] configure.ac for HAVE_DETECT_DISABLED

Saw a warning about unknow command ']' running distcheck and tracked it back
to this error.

11 years agoFix CUDA test warning.
Victor Julien [Fri, 7 Feb 2014 14:06:43 +0000 (15:06 +0100)] 
Fix CUDA test warning.

11 years agoCUDA: Fix header file resolution issues.
Anoop Saldanha [Wed, 5 Feb 2014 03:17:45 +0000 (08:47 +0530)] 
CUDA: Fix header file resolution issues.

11 years agoaf-packet: no VLAN id from msg header for old kernel 833/head
Eric Leblond [Fri, 7 Feb 2014 10:13:38 +0000 (11:13 +0100)] 
af-packet: no VLAN id from msg header for old kernel

This patch uses the new function SCKernelVersionIsAtLeast to know
that we've got a old kernel that do not strip the VLAN header from
the message before sending it to userspace.

11 years agoAdd new function to work on kernel version.
Eric Leblond [Fri, 7 Feb 2014 10:11:14 +0000 (11:11 +0100)] 
Add new function to work on kernel version.

This patch adds a new file containing a function that can be used
to compare the version number of the running kernel with a specific
version.

11 years agoaf-packet: improve VLAN detection
Eric Leblond [Thu, 6 Feb 2014 12:54:10 +0000 (13:54 +0100)] 
af-packet: improve VLAN detection

Since commit in kernel
  commit a3bcc23e890a6d49d6763d9eb073d711de2e0469
  Author: Ben Greear <greearb@candelatech.com>
  Date:   Wed Jun 1 06:49:10 2011 +0000

      af-packet: Add flag to distinguish VID 0 from no-vlan.
a flag is set to indicate VLAN has been set in packet header.

As suggested in commit message, using a test of the flag followed
by a check on vci value ensure backward compatibility of the test.

11 years agoaf-packet: handle vlan counter
Eric Leblond [Tue, 4 Feb 2014 10:49:42 +0000 (11:49 +0100)] 
af-packet: handle vlan counter

This patch adds a vlan counter increment in decodeAFP. This
is needed to take into account vlan_id set by the packet
reading function.

11 years agoaf-packet: get vlan id from header
Eric Leblond [Thu, 30 Jan 2014 17:11:10 +0000 (18:11 +0100)] 
af-packet: get vlan id from header

Since kernel 3.8, the VLAN header are stripped from packet. So the
first VLAN id can only be fetched from the tpacket header at capture
time.

11 years agoapp-layer: fix AppLayerParserProtocolIsTxEventAware 831/head
Victor Julien [Fri, 7 Feb 2014 10:04:32 +0000 (11:04 +0100)] 
app-layer: fix AppLayerParserProtocolIsTxEventAware

AppLayerParserProtocolIsTxEventAware would check if a proto is tx
event aware by checking if it had registered a StateHasEvents function.
However, this is an optimization function. This patch changes it to
use the StateGetEvents function instead, which is a better indicator.

11 years agohttp: per tx decoder events
Victor Julien [Fri, 7 Feb 2014 10:02:41 +0000 (11:02 +0100)] 
http: per tx decoder events

Store HTTP decoder events per TX, so they can be inspected per TX.

Ticket: #839.

11 years agodns: fix protocol yaml setting
Victor Julien [Thu, 6 Feb 2014 17:30:33 +0000 (18:30 +0100)] 
dns: fix protocol yaml setting

UDP code would accidentally depend on 'tcp' setting.

11 years agoAdd option on Tile-Gx for logging for fast.log alerts over PCIe 822/head 824/head
Ken Steele [Tue, 7 Jan 2014 17:56:07 +0000 (12:56 -0500)] 
Add option on Tile-Gx for logging for fast.log alerts over PCIe

When running on a TILEncore-Gx PCIe card, setting the filetype of fast.log
to pcie, will open a connection over PCIe to a host application caleld
tile-pcie-logd, that receives the alert strings and writes them to a file
on the host. The file name to open is also passed over the PCIe link.

This allows running Suricata on the TILEncore-Gx PCIe card, but have the
alerts logged to the host system's file system efficiently. The PCIe API that
is used is the Tilera Packet Queue (PQ) API which can access PCIe from User
Space, thus avoiding system calls.

Created util-logopenfile-tile.c and util-logopen-tile.h for the TILE
specific PCIe logging functionality.

Using Write() and Close() function pointers in LogFileCtx, which
default to standard write and close for files and sockets, but are
changed to PCIe write and close functions when a PCIe channel is
openned for logging.

Moved Logging contex out of tm-modules.h into util-logopenfile.h,
where it makes more sense. This required including util-logopenfile.h
into a couple of alert-*.c files, which previously were getting the
definitions from tm-modules.h.

The source and Makefile for tile-pcie-logd are added in contrib/tile-pcie-logd.

By default, the file name for fast.log specified in suricata.yaml is used as
the filename on the host. An optional argument to tile-pcie-logd, --prefix=,
can be added to prepend the supplied file path. For example, is the file
in suricata.yaml is specified as "/var/log/fast.log" and --prefix="/tmp",
then the file will be written to "/tmp/var/log/fast.log".

Check for TILERA_ROOT environment variable before building tile_pcie_logd

Building tile_pcie_logd on x86 requires the Tilera MDE for its PCIe libraries
and API header files. Configure now checs for TILERA_ROOT before enabling
builing tile_pcie_logd in contrib/tile_pcie_logd

11 years agoReduce time the file lock is held to write an alert to Fast.log
Ken Steele [Tue, 7 Jan 2014 15:31:40 +0000 (10:31 -0500)] 
Reduce time the file lock is held to write an alert to Fast.log

Generate the alert string into a temporary buffer before aquiring the
file lock. Only hold the file lock while writing the alert string to the
file.

In the case of multiple alerts, it would be better to generate all the
alerts, then aquire the lock once and write them all and then flush.

Changed PrintRawLineHexFp, which printed to a file, to PrintBufferRawLineHex,
that puts the same output into a string buffer. It was only used by fast.log.

11 years agoAlert file formatting clean up.
Ken Steele [Mon, 6 Jan 2014 17:00:57 +0000 (12:00 -0500)] 
Alert file formatting clean up.

Put { on new line for function declarations. Remove space after function
name.

Add static to unit tests delcaration.

11 years agoFix address parsing issues 823/head
Victor Julien [Thu, 6 Feb 2014 08:38:58 +0000 (09:38 +0100)] 
Fix address parsing issues

Fix issue where negating a range containing a negation would fail.

E.g. HOME_NET: [192.168.0.0/16,!192.168.10.0], can be used in a rule
     as !$HOME_NET.

Also, fix another parsing issue:

If the negation range would be bigger than the 'positive' range, parsing
wouldn't be correct. Now this case is rejected.

E.g. [192.168.1.3,!192.168.0.0/16] is now explicitly rejected

Ticket 1079.

11 years agoprofiling: end profiling tunnel packets inside lock 820/head
Victor Julien [Tue, 4 Feb 2014 17:18:46 +0000 (18:18 +0100)] 
profiling: end profiling tunnel packets inside lock

End profiling inside the lock for a tunnel packet as otherwise another
thread may already free the packet while the profiling code runs.

SEGV's observed and now gone.

11 years agofileext: make case insensitive
Victor Julien [Tue, 4 Feb 2014 16:26:39 +0000 (17:26 +0100)] 
fileext: make case insensitive

Change keyword to be case insensitive when matching.

Ticket #597.

11 years agoWhen setting a sequence value, check for an existing node. 818/head
Jason Ish [Tue, 10 Dec 2013 18:09:40 +0000 (12:09 -0600)] 
When setting a sequence value, check for an existing node.

This makes --set af-packet.0.threads=X do what you expect by
looking for the sequence node before setting.

11 years agoAdd a --set command line option to set/override a configuration value.
Jason Ish [Wed, 4 Dec 2013 06:00:07 +0000 (00:00 -0600)] 
Add a --set command line option to set/override a configuration value.

11 years agojson dns: fix tx logic
Victor Julien [Tue, 4 Feb 2014 13:07:10 +0000 (14:07 +0100)] 
json dns: fix tx logic

The JSON DNS logger would still have some conditions in the main
Logger function. This led to some transactions not beeing logged.

11 years agoprofiling: output log api modules separately
Victor Julien [Tue, 4 Feb 2014 11:53:00 +0000 (12:53 +0100)] 
profiling: output log api modules separately

Skip log api thread modules in the regular 'thread modules' list,
instead print them in a separate list.

11 years agoprofiling: fix percentage of detect phases
Victor Julien [Tue, 4 Feb 2014 11:52:07 +0000 (12:52 +0100)] 
profiling: fix percentage of detect phases

Use proper 'total' to calculate weigth of each detection phase.

11 years agothreading: add missing json types to TmModuleTmmIdToString
Victor Julien [Tue, 4 Feb 2014 11:15:04 +0000 (12:15 +0100)] 
threading: add missing json types to TmModuleTmmIdToString

Also, remove 'default' case from switch statement, so missing entries
will lead to a compiler warning.

11 years agooutput: add TM_FLAG_LOGAPI_TM thread module flag
Victor Julien [Tue, 4 Feb 2014 10:49:20 +0000 (11:49 +0100)] 
output: add TM_FLAG_LOGAPI_TM thread module flag

The TM_FLAG_LOGAPI_TM flag indicates that a module is run by the log
api, not by the 'regular' thread module call functions.

Set flag in all all Log API users' registration code.

Purpose of this flag is in profiling. In profiling output it will be
used to list log api thread modules separately.

11 years agoprofiling: support log api
Victor Julien [Tue, 4 Feb 2014 10:34:21 +0000 (11:34 +0100)] 
profiling: support log api

The log API calls thread modules directly, so the TMM profiling logic
can be applied to it. This patch does so.

The "Thread Module" out now again lists the individual loggers. As the
module are normally called much less frequently the numbers are hard to
compare to pre-log-api numbers.

11 years agothreading: add utility to get module id from name
Victor Julien [Tue, 4 Feb 2014 10:31:02 +0000 (11:31 +0100)] 
threading: add utility to get module id from name

Add TmModuleGetIdByName to go from module name to id directly.

11 years agoprofiling: add sample-rate yaml option
Victor Julien [Mon, 3 Feb 2014 16:40:45 +0000 (17:40 +0100)] 
profiling: add sample-rate yaml option

Add option "profiling.sample-rate":

  # Run profiling for every xth packet. The default is 1, which means we
  # profile every packet. If set to 1000, one packet is profiled for every
  # 1000 received.
  #sample-rate: 1000

This allows for configuration of the sample rate.

11 years agoprofiling: conditional rule profiling
Victor Julien [Sat, 1 Feb 2014 14:58:58 +0000 (15:58 +0100)] 
profiling: conditional rule profiling

Add support for conditional rule profiling. Currently only simple
rate limiting is supported, but hardcoded to inspecting rules for
each packet.

11 years agoprofiling: lower overhead when disabled
Victor Julien [Sat, 1 Feb 2014 11:57:01 +0000 (12:57 +0100)] 
profiling: lower overhead when disabled

Instead of a large (6k+) structure in the Packet, make the profiling
storage dynamic. To do this the Packet->profile is now a pointer.

Initial support for selective sampling, e.g. only profile every
1000th packet.

11 years agotls: fix negated match
Eric Leblond [Tue, 28 Jan 2014 15:54:51 +0000 (16:54 +0100)] 
tls: fix negated match

A negated match is matching if the tested field is NULL. But as it
is not set, nor negated nor normal test must match.

Without this patch, a rule like:
 alert tls any any -> any any (msg:"negated match"; tls.subject:!"CN=home.regit.org"; sid:1; rev:1;)
is alerting for all connections. Event if they are done on a certificate
with matching subject. This was due to the fact that tls protocol
is discovered before the handshake is complete. Thus the condition
on tls is true with a NULL tls.subject. And code was returning a
positive match in the case of a NULL subject and a signature with
a negated match.

11 years agoUpdated banned function cocci check
Victor Julien [Fri, 31 Jan 2014 11:53:26 +0000 (12:53 +0100)] 
Updated banned function cocci check

Added: strndup and strchrnul

Both are not supported on OS X 10.6. It's rather old, but it's the
only Mac QA box I have, so for now it'll have to do.

11 years agoReplace strchrnul with strchr
Victor Julien [Fri, 31 Jan 2014 11:52:36 +0000 (12:52 +0100)] 
Replace strchrnul with strchr

And add a null check then of course. strchrnul isn't supported on
all platforms.

11 years agoRemove SCStrndup
Victor Julien [Fri, 31 Jan 2014 11:25:16 +0000 (12:25 +0100)] 
Remove SCStrndup

Removed strndup wrapper as it's not available in all plaforms.

11 years agoReplace remaining SCStrndup calls
Victor Julien [Fri, 31 Jan 2014 11:23:53 +0000 (12:23 +0100)] 
Replace remaining SCStrndup calls

Replace them with BytesToString().

11 years agoIntroduce BytesToString utility
Victor Julien [Fri, 31 Jan 2014 11:21:47 +0000 (12:21 +0100)] 
Introduce BytesToString utility

Introduce a utility function to convert an array of bytes into a
null-terminated string:

 char *BytesToString(const uint8_t *bytes, size_t nbytes);

All non-printables are copied over, except for '\0', which is
turned into literal '\' '0' in the string. So the resulting string
may be bigger than the input.

11 years agojson loggers: dup bstr with bstr_util_strdup_to_c
Victor Julien [Fri, 31 Jan 2014 09:49:57 +0000 (10:49 +0100)] 
json loggers: dup bstr with bstr_util_strdup_to_c

In various places SCStrndup was used to 'dup' a bstr string, however
libhtp provides bstr_util_strdup_to_c for this. As this is a cleaner
interface, it's preferred.

11 years agostream: yaml addition for recent config options
Victor Julien [Fri, 31 Jan 2014 08:33:29 +0000 (09:33 +0100)] 
stream: yaml addition for recent config options

11 years agoutil-host-os-info: scan-build fix
Victor Julien [Thu, 30 Jan 2014 15:23:44 +0000 (16:23 +0100)] 
util-host-os-info: scan-build fix

util-host-os-info.c:202:13: warning: Potential leak of memory pointed to by 'user_data'
            SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:278:35: note: expanded from macro 'SCLogError'
 #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:214:82: note: expanded from macro 'SCLogErr'
                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                                                                 ^~
1 warning generated.

11 years agoutil-host-os-info: scan build fixes
Victor Julien [Thu, 30 Jan 2014 15:08:20 +0000 (16:08 +0100)] 
util-host-os-info: scan build fixes

util-host-os-info.c:200:13: warning: Potential leak of memory pointed to by 'ip_str'
            SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:278:35: note: expanded from macro 'SCLogError'
 #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:214:82: note: expanded from macro 'SCLogErr'
                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                                                                 ^~
util-host-os-info.c:200:13: warning: Potential leak of memory pointed to by 'user_data'
            SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:278:35: note: expanded from macro 'SCLogError'
 #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-debug.h:214:82: note: expanded from macro 'SCLogErr'
                                  char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \
                                                                                 ^~
2 warnings generated.

11 years agoFix util-debug scan-build warnings
Victor Julien [Thu, 30 Jan 2014 15:02:17 +0000 (16:02 +0100)] 
Fix util-debug scan-build warnings

util-debug.c:461:12: warning: Potential leak of memory pointed to by 'substr'
    return SC_ERR_SPRINTF;
           ^~~~~~~~~~~~~~
util-debug.c:856:31: warning: Potential leak of memory pointed to by 's'
                op_ifaces_ctx = SCLogInitFileOPIface(s, NULL, SC_LOG_LEVEL_MAX);
                ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util-debug.c:1349:9: warning: Potential leak of memory pointed to by 's'
    if (log_level >= 0 && log_level < SC_LOG_LEVEL_MAX)
        ^~~~~~~~~
3 warnings generated.

11 years agojson file: separate http params 810/head
Eric Leblond [Fri, 31 Jan 2014 11:05:48 +0000 (12:05 +0100)] 
json file: separate http params

This patch separates http keys from file to have a different value
list:

{
 "time":"01\/31\/2014-12:04:52.837245","event_type":"file","src_ip":"5.3.1.1","src_port":80,"dest_ip":"1.8.1.9","dest_port":9539,"proto":"TCP",
 "http":{"url":"/foo/","hostname":"bar.com","http_refer":"http:\/\/bar.org","http_user_agent":"Mozilla\/5.0"},
 "file":{"filename":"bar","magic":"unknown","state":"CLOSED","stored":false,"size":21}
}

One interest of this modification is that it is possible to use the
same key as the one used in http events. Thus correlating both type
of events is trivial. On code side, this will permit to factorize
the code by simply asking the underlying protocol to output its
info in a json object.

Second interest is that adding file extraction for a new protocol
will result in only changing the protocol specific json list.

11 years agojson: add event_type key
Eric Leblond [Fri, 31 Jan 2014 10:54:19 +0000 (11:54 +0100)] 
json: add event_type key

This patch adds an event_type key to the generated events. Current
value is one of "dns", "alert, "file", "tls", "http", "drop". It is
then easy to differentiate in log analysis tools the events based on
source inside Suricata.

11 years agojson dns: do not use array to output answer
Eric Leblond [Fri, 31 Jan 2014 09:58:35 +0000 (10:58 +0100)] 
json dns: do not use array to output answer

Without this patch DNS answers for a single query are stored in a
single json event. The result is an array in the object like this one:
 {"type":"answer","id":45084,"rrname":"s-static.ak.facebook.com","rrtype":"CNAME","ttl":734},
 {"type":"answer","id":45084,"rrname":"s-static.ak.facebook.com.edgekey.net","rrtype":"CNAME","ttl":1710},
This type of output is not well supported in logstash. It is
displayed as it is written above and it is not possible to
query the fields.

I think the reason is that this is not logical if we consider search
query. For example if we search for "rrname" equal "s-static.ak.facebook.com"
we got one entry with two values in it. That's against the logic
of event. Furthermore, if we want to get a complete query, we can
used the id.

This patch splits the answer part in mulitple message. The result
is then accepted by logstash and fields can be queried easily.

11 years agojson-dns: sync field names with draft rfc2629
Eric Leblond [Fri, 31 Jan 2014 08:43:31 +0000 (09:43 +0100)] 
json-dns: sync field names with draft rfc2629

This patch updates DNS field name to be in sync with RFC 2629:
 https://github.com/adulau/pdns-qof
This will allow to easily use Suricata with other passive DNS tools.

11 years agojson: sync key name with CIM
Eric Leblond [Thu, 30 Jan 2014 22:33:45 +0000 (23:33 +0100)] 
json: sync key name with CIM

This patch is synchronizing key name with Common Information Model.
It updates key name following what is proposed in:
 http://docs.splunk.com/Documentation/PCI/2.0/DataSource/CommonInformationModelFieldReference
The interest of these modifications is that using the same key name
as other software will provide an easy to correlate and improve
data. For example, geoip setting in logstash can be applied on
all src_ip fields allowing geoip tagging of data.

11 years agoVarious fixes for scan-build warnings 807/head
Victor Julien [Thu, 30 Jan 2014 14:22:55 +0000 (15:22 +0100)] 
Various fixes for scan-build warnings

11 years agooutput: cleanups 806/head
Victor Julien [Thu, 30 Jan 2014 13:38:03 +0000 (14:38 +0100)] 
output: cleanups

Preparation of making output type for json logs configurable.

11 years agojson tls log: rename to output-json-tls
Victor Julien [Thu, 30 Jan 2014 12:58:28 +0000 (13:58 +0100)] 
json tls log: rename to output-json-tls

11 years agooutput: check for multiple instances of drop and tls
Victor Julien [Thu, 30 Jan 2014 12:49:42 +0000 (13:49 +0100)] 
output: check for multiple instances of drop and tls

Both the drop and tls logs are currently not designed to have multiple
instances running. So until that is changed, error out if more than one
instance is started.

11 years agojson drop log: rename to output-json-drop
Victor Julien [Thu, 30 Jan 2014 12:34:45 +0000 (13:34 +0100)] 
json drop log: rename to output-json-drop

11 years agojson dns: rename output-dnslog -> output-json-dns
Victor Julien [Thu, 30 Jan 2014 12:29:36 +0000 (13:29 +0100)] 
json dns: rename output-dnslog -> output-json-dns

11 years agojson: rename output-httplog -> output-json-http
Victor Julien [Thu, 30 Jan 2014 12:26:59 +0000 (13:26 +0100)] 
json: rename output-httplog -> output-json-http

11 years agojson outputs: cleanups 805/head
Victor Julien [Thu, 30 Jan 2014 12:20:47 +0000 (13:20 +0100)] 
json outputs: cleanups

Clean up header files and improve memory handling.

11 years agojansson file log: make file log module
Victor Julien [Thu, 30 Jan 2014 11:26:01 +0000 (12:26 +0100)] 
jansson file log: make file log module

Turn the libjansson based file logger into a file module, as a child
of eve-log.

11 years agotls json: turn into packet logger
Victor Julien [Thu, 30 Jan 2014 10:45:30 +0000 (11:45 +0100)] 
tls json: turn into packet logger

Like log-tls, turn the json tls logger into a packet logger as the
protocol parser is not tx aware.

Make it a child of eve-log as well.

11 years agooutput: simple name space support for sub modules
Victor Julien [Thu, 30 Jan 2014 09:59:51 +0000 (10:59 +0100)] 
output: simple name space support for sub modules

To avoid module name clashes, a submode abc of parent xyz, will now
register itself as xyz.abc.

11 years agodrop-json: make child of eve-log
Victor Julien [Thu, 30 Jan 2014 09:50:38 +0000 (10:50 +0100)] 
drop-json: make child of eve-log

Make drop json child of eve-log.

11 years agojson drop log: move into packet module
Victor Julien [Thu, 30 Jan 2014 09:15:59 +0000 (10:15 +0100)] 
json drop log: move into packet module

Move JSON drop log into a full packet module.

11 years agolog api: use AppProto instead of uint16_t
Victor Julien [Thu, 30 Jan 2014 08:18:12 +0000 (09:18 +0100)] 
log api: use AppProto instead of uint16_t

11 years agolog api: convert all names to const
Victor Julien [Thu, 30 Jan 2014 08:14:59 +0000 (09:14 +0100)] 
log api: convert all names to const

Instead of strdupping all names w/o a need, use const ptrs.

11 years agoalert json: make child of eve-log
Victor Julien [Wed, 29 Jan 2014 18:42:46 +0000 (19:42 +0100)] 
alert json: make child of eve-log

Enable alert json for eve-log by registering the module as a sub-
module of eve-log.

11 years agoalert-json: make full module out of json alert
Victor Julien [Wed, 29 Jan 2014 17:50:32 +0000 (18:50 +0100)] 
alert-json: make full module out of json alert

Make a full module out of the json alert code in output-json-alert.[ch].

11 years agooutput: sub-module support for other log api's
Victor Julien [Wed, 29 Jan 2014 17:19:27 +0000 (18:19 +0100)] 
output: sub-module support for other log api's

Packets:
void OutputRegisterPacketSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *),
    PacketLogger LogFunc, PacketLogCondition ConditionFunc);

Files:
void OutputRegisterFileSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FileLogger FileLogFunc);

Filedata:
void OutputRegisterFiledataSubModule(const char *parent_name, char *name, char *conf_name,
    OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), FiledataLogger FiledataLogFunc);

11 years agooutput: introduce concept of sub-modules
Victor Julien [Wed, 29 Jan 2014 16:38:04 +0000 (17:38 +0100)] 
output: introduce concept of sub-modules

To support the 'eve-log' idea, we need to be able to force all log
modules to be enabled by the master eve-log module, and need to be
able to make all logs go into a single file. This didn't fit the
API so far, so added the sub-module concept.

A sub-module is a regular module, that registers itself as a sub-
module of another module:

    OutputRegisterTxSubModule("eve-log", "JsonHttpLog", "http",
            OutputHttpLogInitSub, ALPROTO_HTTP, JsonHttpLogger);

The first argument is the name of the parent. The 4th argument is
the OutputCtx init function. It differs slightly from the non-sub
one. The different is that in addition to it's ConfNode, it gets
the OutputCtx from the parent. This way it can set the parents
LogFileCtx in it's own OutputCtx.

The runmode setup code will take care of all the extra setup. It's
possible to register a module both as a normal module and as a sub-
module, which can operate at the same time.

Only the TxLogger API is handled in this patch, the rest will be
updated later.

11 years agodns-json: turn logger to tx api
Victor Julien [Wed, 29 Jan 2014 14:29:15 +0000 (15:29 +0100)] 
dns-json: turn logger to tx api

Convert Json DNS logger into a Tx Logger API logger.

11 years agohttp-json: separate module using tx api
Victor Julien [Wed, 29 Jan 2014 13:36:22 +0000 (14:36 +0100)] 
http-json: separate module using tx api

Turn HTTP json logger into a Tx Logger API logger.

11 years agoVarious compile fixes after rebase with master
Victor Julien [Wed, 29 Jan 2014 10:32:10 +0000 (11:32 +0100)] 
Various compile fixes after rebase with master

11 years agojson: rebase fixes
Tom DeCanio [Fri, 17 Jan 2014 00:18:54 +0000 (16:18 -0800)] 
json: rebase fixes

- restore json output-file.[ch] as output-json-file.[ch] after rebase conflict
- fix Makefile.am after merge conflict
- some dev-log-api-v4.0 rebase json fallout cleanup

11 years agoRemaining JSON output pull request comment edits
Tom DeCanio [Tue, 19 Nov 2013 20:58:47 +0000 (12:58 -0800)] 
Remaining JSON output pull request comment edits

11 years agoaddress most initial JSON pull request comments
Tom DeCanio [Mon, 18 Nov 2013 22:36:52 +0000 (14:36 -0800)] 
address most initial JSON pull request comments

11 years agoadd "united" drop JSON log
Tom DeCanio [Thu, 14 Nov 2013 03:33:00 +0000 (19:33 -0800)] 
add "united" drop JSON log

11 years agoAdd "united" JSON files output
Tom DeCanio [Wed, 13 Nov 2013 19:17:03 +0000 (11:17 -0800)] 
Add "united" JSON files output

11 years agoFirst cut at "united" file log output in JSON
Tom DeCanio [Wed, 13 Nov 2013 06:43:19 +0000 (22:43 -0800)] 
First cut at "united" file log output in JSON

11 years agoJSON output cleanup
Tom DeCanio [Wed, 13 Nov 2013 02:48:37 +0000 (18:48 -0800)] 
JSON output cleanup

11 years agoremove unused http JSON code
Tom DeCanio [Wed, 13 Nov 2013 02:13:43 +0000 (18:13 -0800)] 
remove unused http JSON code