Commit Graph

165 Commits (789353bc1e1aa23d075f16af25df84df00c68682)

Author SHA1 Message Date
Jeff Lucovsky 0d2268ddfc decode/vlan: Decode upto 3 layers of VLAN
Issue: 2816

This commit increase the number of VLAN layers supported by Suricata
from 2 to 3. 3-layers are dubbed "Q-in-Q-in-Q".

Note that 3 layers are not compliant with any existing standard but are
often seen in larger deployments.
2 years ago
Jeff Lucovsky cb174e4fd9 log/thread: Consolidate threaded file tracking
Issue: 5836

This commit removes the duplicate threaded file tracking from the log
file mechanisms.

Tracking is now consolidated with the threaded hash table.
3 years ago
Jeff Lucovsky 31793aface time: Replace struct timeval with scalar value
Issue: 5718

This commit switches the majority of time handling to a new type --
SCTime_t -- which is a 64 bit container for time:
- 44 bits -- seconds
- 20 bits -- useconds
3 years ago
Victor Julien b31ffde6f4 output: remove error codes from output 3 years ago
Philippe Antoine 9af0dafbad src: fix some include orders
So as to be able to get include removal right
3 years ago
Victor Julien 55cf11fdc2 flow/storage: use const for getter 3 years ago
Victor Julien 99fd69ee8c eve: mac logging code cleanup 3 years ago
Victor Julien 90f3823cad eve: log mac addresses in packet direction 3 years ago
Eric Leblond e46a0bd46a eve: explicit default when setting port 3 years ago
Eric Leblond 00c419a6f8 eve: micro simplification 3 years ago
Victor Julien 79499e4769 app-layer: move files into transactions
Update APIs to store files in transactions instead of the per flow state.

Goal is to avoid the overhead of matching up files and transactions in
cases where there are many of both.

Update all protocol implementations to support this.

Update file logging logic to account for having files in transactions. Instead
of it acting separately on file containers, it is now tied into the
transaction logging.

Update the filestore keyword to consider a match if filestore output not
enabled.
3 years ago
Victor Julien e250ef6402 debug: remove empty header 3 years ago
Philippe Antoine da0be16d36 output: do not log empty arrays for sid
Ticket: #5167
3 years ago
Philippe Antoine 02f2602dde src: rework includes as per cppclean 3 years ago
Philippe Antoine c4d9cb02ec util: better hex print function
Without dangerous snprintf pattern identified by CodeQL
even if this pattern is not a problem in those precise cases,
it may easily get copy pasted in a dangerous place, so better
get rid of it and make CodeQL happy
3 years ago
Victor Julien 9336ab5dcd eve: add pkt_src
This will tell the user if a record was generated based on a real packet,
a flow timeout packet or others.
3 years ago
Jeff Lucovsky 22e89ec4a3 log: Coverity REVERSE_INULL warnings
This commit addresses Coverity reported "REVERSE_INULL" warnings.

Issue: 4699
4 years ago
Jason Ish 6392216f6b base64: use the Rust base64 encode implementation
Replace our internal base64 implementation with a ffi wrapper
around the Rust implementation provided by an external crate.
4 years ago
Jason Ish 6d3dcf27a6 eve: use JsonBuilder for encoding base64
Replaces all usages of Base64Encode just before writing to a
JsonBuilder with jb_set_base64 and jb_append_base64.
4 years ago
Jason Ish a8b603e509 plugins: remove internal fields
The internal flag is not really used. This also reverts the behaviour of
the plugin refactor of passing a ConfNode based on the plugin name
instead of the eve ConfNode.
4 years ago
Jason Ish 4cd99fc266 eve: register internal output file types
Register known eve output file types during eve registration. This
removes the function to load internal plugins as they are not really
plugins and moves the registration of them into their respective
subsystem.
4 years ago
Jason Ish 784a080201 plugins: rename SCPLuginFileType to SCEveFileType
With internal code using the plugin API to register an Eve
filetype, the name plugin no longer makes sense. This is
part of my idea that internal plugins aren't plugins at all,
and the plugin interface should be an abstraction over
internal APIs.

Along that idea, this is the start of a refactor of the plugin
file types to be internal, where the plugin API is just an external
interface to that internal API.
4 years ago
Jeff Lucovsky 98d4f9eaa4 output/syslog: Refactor syslog definitions 4 years ago
Jeff Lucovsky 0e3773ddef output/json: Refactor internal routines 4 years ago
Jeff Lucovsky 7fa98cde4d output/redis: Redis threaded output changes 4 years ago
Jeff Lucovsky 1defca3c34 output/plugin: Support threaded output plugins 4 years ago
Jeff Lucovsky 05836a4452 output/plugin: API changes for threaded support
This commit extends the interface to better support file output plugins.
4 years ago
Jason Ish 06f58650d6 eve: refactor OutputJsonBuilderBuffer to take context
All callers of OutputJsonBuilderBuffer are now calling it
using fields from an OutputJsonThreadCtx, so just pass
a pointer to the thread context now.
4 years ago
Jason Ish 013becf569 eve: reset buffer in OutputJsonBuilderBuffer
Reset the buffer here so each caller doesn't need to do it.
4 years ago
Jason Ish 2d78afe4b0 eve: refactor CreateEveHeaderWithTx to include common options 5 years ago
Jason Ish 06ba611667 eve cleanup: remove duplicate/redundant code
The first change was to have CreateEveHeader add the common options
as this was left out in a few loggers. While update all the loggers
that use CreateEveHeader, remove redundant code, in particular
from loggers that don't need to use their own context but
can use the generic one.
5 years ago
Victor Julien c25afbccc1 json: remove unused jansson wrappers 5 years ago
Jason Ish 0321f60ebf community-id: use Rust SHA1 to compute hash
Removes use of our internal ComputeSHA1 for calculating the
community ID.
5 years ago
Jason Ish e50ee7eb62 filestore: remove requirement of nss for filestore
Required including NSS header in places that depended on
util-file.h including it.

All filestore suricata-verify tests now pass without libnss.

Also enabled detect-file{md5,sha1,sha256} without NSS support.
5 years ago
Justin Ossevoort 320de5f43d eve: Log tenant_id for all eve-json messages 5 years ago
Shivani Bhardwaj ea0936199d output: use BASE64_BUFFER_SIZE macro
Base64Encode function requires the maximum length of the output string
as its last parameter. Use the macro BASE64_BUFFER_SIZE to calculate it
correctly.
5 years ago
Sascha Steinbiss ea2bc4c962 eve: do not access flow storage in packet context
We must make sure not to access the flow storage (e.g. keeping a
MacSet) before making sure we have a flow to begin with, We can,
for example, run into an alert without a flow with `ip` rules,
in which case the flow might be NULL. See Redmine issue #4109.
5 years ago
Jason Ish f2a1626b51 output-json: fix Coverity USE_AFTER_FREE
Return error if plugin open fails. Fixes Coverity CID 1465664
USE_AFTER_FREE error.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/3864
5 years ago
Jason Ish 8fb35236e6 plugins: initial support for a filetype plugin
A filetype plugin is a plugin that implements an eve filetype. Most
of the current filetypes could likely be implemented as such a plugin.
Such a plugin must implement Open, Close and Write, where Write
is provided the formatted JSON to be logged.

This commit also includes the plumbing for plugin loading. Example
plugin to come.

Plugins are loaded by the "plugin" section in the configuration
file:

  plugins:
    - /path/to/directory/plugins
    - /path/to/plugin_file.so

This can also be done on the command line with:

  --set plugins.0=/path/plugin_file.so
5 years ago
Sascha Steinbiss 4e1a41a17d output-json: add MAC address output
This commit adds MAC address output to the EVE-JSON format. We follow the
remarks made in Redmine ticket #962: for packets, log MAC src/dst as a
scalar field in EVE; for flows, log MAC src/dst as lists in EVE. Field names
are different between flow and packet context to avoid type confusion
(src_mac vs. src_macs). Configuration approach and JSON representation is
taken from previous GitHub PR #2700.
5 years ago
Jeff Lucovsky 30ae98f658 output/json: Multi-threaded EVE logging support
This commit modifies the JSON loggers with changes necessary to support
multi-threaded EVE output.

Each "thread-init" function sets up the per-thread log file context for
subsequent calls to the JSON output to buffer function.
5 years ago
Victor Julien b99ffd9ece eve: remove unused jansson code 5 years ago
Victor Julien 38fe11f3b2 eve: remove unused json_t common functions
These are no longer used as all callers have switched to
the JsonBuilder equivalents.
5 years ago
Shivani Bhardwaj 6f7d8e50c8 src: use FatalError whenever possible
Replaces all patterns of SCLogError() followed by exit() with
FatalError(). Cocci script to do this:

@@
constant C;
constant char[] msg;
@@

- SCLogError(C,
+ FatalError(SC_ERR_FATAL,
  msg);
- exit(EXIT_FAILURE);

Closes redmine ticket 3188.
5 years ago
Jeff Lucovsky 6bb89c37f1 output/json: Correct clang warning
This commit corrects the warning for mismatched type.
5 years ago
Jeff Lucovsky 1e8d4af29a output/json: Improve protocol output handling
Improve protocol label handling by eliminating an unneeded copy.

Additionally, unknown protocol values are no longer zero-padded.
5 years ago
Jeff Lucovsky 4127c5fcc8 output/fileinfo: Optimize filename output
This commit optimizes the JSON preparation of the file name by
eliminating the temporary copy before adding to the Json builder buffer.
5 years ago
Jeff Lucovsky 1f19ab1013 output/eve: Remove unused helper function
This commit removes an unused helper function no longer required/used
after conversion to JsonBuilder.
5 years ago
Jeff Lucovsky ff92745851 output/json: Include fileinfo in alerts
This commit adds fileinfo to alerts when `metadata` is configured.
5 years ago
Jeff Lucovsky ae50d1a225 output/json: Refactor file output helper
This commit creates a common file output helper function based on the
logic in output-file-info.c:BuildBuildFileInfoRecord

The refactored helper will be used to create "fileinfo" information
during the alert output path.
5 years ago