Commit Graph

70 Commits (5ca4a2e6fe5df41673009d89f2f1e0173b55097c)

Author SHA1 Message Date
Victor Julien 1a2ad059a1 eve: log pktvars/flowvars/bits/ints
Optionally logs 'vars' into alerts
9 years ago
Jason Ish 1b4ba4496c logging: rename registration functions to not have tmm
As the logging modules are no longer threading modules, rename
them so they don't look like they are being registered as
threading modules.

Also, move the registration to the output.c which will handle
registration of the loggers.
9 years ago
Jason Ish 9489d5b9e3 logging: remove dead code from output-json
The "parent" json logger was setup like a real logger, but
some of that code was never being called.
9 years ago
Victor Julien b81ea0d7db eve: reduce flow_id to 51 bits
Evebox & ELK couldn't handle the large integers. It looks like (partly)
a javascript limitation that doesn't treat 64bit ints as real ints.
9 years ago
Victor Julien 9ca34fa5c9 eve: output more unique flow_id 9 years ago
maxtors 9d3fd82849 Removed duplicate include statements. 9 years ago
maxtors 69863f7b1c Corrected and unified debugmessages for init data errors in *ThreadInit. 9 years ago
Jason Ish 8edbc20a07 flow: record the flow hash for use as the output flow id
Provides a consistent hash for a flow, as well as a better
distribution than using a memory address.
9 years ago
Victor Julien 53704ea468 output-json: constify API 10 years ago
Victor Julien fb90358e17 conf: explicitly ignore retval (CID 1353490) 10 years ago
Victor Julien 3f3ed71fe7 jansson: cleanup JSON_ESCAPE_SLASH use 10 years ago
Victor Julien 40cf1f8ef7 json: make membuffer helper public
Make json_t to MemBuffer helper public so it can reused.
10 years ago
Victor Julien c446abeb47 jansson: include in suricata-common.h 10 years ago
Jason Ish 3d2834a232 json: use top-level sensor-name if provided.
Currently the default configuration file contains a "sensor-name"
at the root of the configuration file, however, eve-log will only
use it if its specified under eve-log.

Now we will look for it at the eve-log, if present we'll use it
but log a deprecation warning, if its not present we'll look
for sensor-name at the root of the configuration.
10 years ago
Victor Julien 8bb1cf08ef eve: fix mishandling of big messages
When the string representation of a JSON message grew bigger than
64k, the JSON record would just be truncated. This lead to errors
in the parser(s) of the JSON stream.

This patch changes the buffer logic to grow the buffer on demand.
10 years ago
Victor Julien ac476de5ed json: small improvement to log message wording 10 years ago
Eric Leblond 9930f447d2 output-json: fix regression on log prefix handling
The log prefix option was not anymore honored due to a regression
caused by some recent code.
10 years ago
Victor Julien bec913b40c json: fix malformed output
Even though the json output callback is called with a null terminated
string, it's not useable directly. The size parameter to the callback
might be a lot smaller than the string size. Libjansson gives the size
up to the first point that needs escaping.
10 years ago
Victor Julien c80990fe10 output: cleanup JSON logging 10 years ago
Victor Julien ad5a753dde output-json: don't alloc for JSON to string 10 years ago
Eric Leblond 2ea4bbc492 util-logopenfile: move sensor_name to filectx
We will now output the sensor name independantly of the output
method if it is set in the YAML file. In the case of redis we are
using the hostname value if unset.
10 years ago
Eric Leblond f11b269ef1 redis-output: fix sensor-name code
The sensor-name was not freed at exist and the result of SCStrdup
was not checked.
10 years ago
Eric Leblond f953fdfbac util-logopenfile: introduce SCConfLogOpenRedis
Introduce a function to realize the parsing and config file and
opening of connection to the database. Only used by output-json
for now it will be usable by other logging modules.
10 years ago
Eric Leblond a13be67b5e util-logopenfile: add write function
Introduce a function LogFileWrite that will handle the writing with
respect of the type defined in the configuration. This is used in
this patch to remove the write complexity from output-json.
10 years ago
Eric Leblond 60ea49c777 output-json: add sensor-name config variable
When using redis output, we are loosing the host key (added by
logstash or logstash-forwarder) and we can't find anymore what
Suricata did cause the alert.

This patch is adding this key during message generation using the
'sensor-name' variable or the hostname is 'sensor-name' is not
defined.
10 years ago
Eric Leblond 31c91d53bb output-json: improve hiredis define
Use #ifdef instead of #if and don't include the header which is
not needed anymore.
10 years ago
Eric Leblond eef5678e5e output-json: add redis support
This patch adds redis support to JSON output.
10 years ago
Eric Leblond 113d6a3950 output-json: add create header with tx function
To be able to correlate between events, it is better to have the
tx_id information in the root object. This function adds a new
function to automate the addition of the field.
10 years ago
Jason Ish b512580bbe logging: integrate rotation into SCConfLogOpenGeneric.
Addresses issue 1492, and will make it harder to omit
rotation on new outputs.
10 years ago
Zachary Rasmor 0edf28a4f8 Add Feature #1454. Generic eve-log prefix support. 10 years ago
Victor Julien 1e8142c699 logfile: rename ALERT_ types to LOGFILE_TYPE_ 10 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.
10 years ago
Zachary Rasmor f0c659f82f Fix Bug #1204
Fix typo that causes eve syslog settings code to be unreachable.
10 years ago
Victor Julien a3de4ecd97 Suppress debug statements 11 years ago
Christophe M 6c2ae469be Fix to output a JSON buffer to an Unix domain socket.
Create the JSON buffer and write to it like regular file.

Upper function SCConfLogOpenGeneric already handle it properly.

Closes issue #1246.
11 years ago
Ken Steele 8f1d75039a Enforce function coding standard
Functions should be defined as:

int foo(void)
{
}

Rather than:
int food(void) {
}

All functions where changed by a script to match this standard.
11 years ago
Alexander Gozman a6dbf627b2 Add input interface's name to JSON log 11 years ago
Victor Julien f1185d051c flow id: quick and dirty first stab at a flow id
Add a 'flow_id' that is the same for all records produced for packets
belonging to the same flow.

This patch simply takes the flow's memory address.
11 years ago
Victor Julien eaf01449e3 json: add tcp flags to json utility function
Turns a flags bitfield into a set of json bools.
11 years ago
Victor Julien fdd407751e Fix eve 'filetype' parsing
Now that we use 'filetype' instead of 'type', we should also
use 'regular' instead of 'file'.

Added fallback to make sure we stay compatible to old configs.
11 years ago
Alexander Gozman 8048eebd39 Fix handling filetype for eve log 11 years ago
Jason Ish fc2014ab40 Unregister for file rotation notification when a context is
de-initialized.  Required for unix-socket mode where
contexts come and go.
11 years ago
Jason Ish e1b97fed70 Add signal based file rotation for:
- alert debug log
- fast log
- stats log
- dns log
- drop log
- file log
- http log
- tls log
- eve/json log
11 years ago
Victor Julien 96adcf6829 refactor IDS/IPS engine mode logic
Instead of error phrone externs with macro's, use functions with a local
static enum var instead.

- EngineModeIsIPS(): in IPS mode
- EngineModeIsIDS(): in IDS mode

To set the modes:

- EngineModeSetIDS(): IDS mode (default)
- EngineModeSetIPS(): IPS mode

Bug #1177.
11 years ago
Victor Julien bc1c06b9e4 eve-log: fix mem leak at shutdown
Make sure we free all memory in the shutdown function.
11 years ago
Tom DeCanio 4085f08602 json: somewhere along the way IP/port pairs had gotten swapped in
http and ssh eve logs
11 years ago
Eric Leblond 6c3c234ca5 output-json: update timestamp format
This patch updates the timestamp format used in eve loggin.
It uses a ISO 8601 comptatible string. This allow tools parsing
the output to easily detect adn/or use the timestamp.

In the EVE JSON output, the value of the timestamp key has been
changed to 'timestamp' (instead of 'time'). This allows tools
like Splunk to detect the timestamp and use it without configuration.

Logstash configuration is simple:

input {
   file {
      path => [ "/usr/local/var/log/suricata/eve.json" ]
      codec =>   json
      type => "suricata-log"
   }
}

filter {
   if [type] == "suricata-log" {
      date {
        match => [ "timestamp", "ISO8601" ]
      }
   }
}

In splunk, auto detection of the fle format is failling and it seems
you need to define a type to parse JSON in
$SPLUNK_DIR/etc/system/local/props.conf:

[suricata]
KV_MODE = json
NO_BINARY_CHECK = 1
TRUNCATE = 0

Then you can simply declare the log file in
$SPLUNK_DIR/etc/system/local/inputs.conf:

[monitor:///usr/local/var/log/suricata/eve.json]
sourcetype = suricata

In both cases the timestamp are correctly imported by
the tools.
12 years ago
Victor Julien 88e9c85e36 json output: fix vlan byte order in output
VLAN functions/macros return vlan id in host byte order, so no need
to convert them in output functions.
12 years ago
Victor Julien 872bb5664e Fix null dereference in eve-log
Eve-log would call GET_VLAN_ID on the packets vlan header if p->vlan_idx
was bigger than 0. GET_VLAN_ID would then unconditionally dereference
p->vlanh[0] or [1]. However, there are a number of cases in which these
pointers are not set. Defrag pseudo packets, AF_PACKET and in the future
PF_RING, do set the id's, but not the header pointers.

This patch adds 2 new macro's which are wrappers around a function:

VLAN_GET_ID1 and VLAN_GET_ID2 get the id's by calling DecodeVLANGetId.

This function will return the correct id.

Bug #1120.
12 years ago
Victor Julien d8c486231c output-json: fix minor memory leak on error
If the json file couldn't be opened, a minor memory leak would occur.

Coverity 1166039
12 years ago