Commit Graph

8689 Commits (460a0a6977614a521ebb17cc8e531c6528ff8c69)
 

Author SHA1 Message Date
Victor Julien 1bed6e9cae ssh: implement DetectFlags API 7 years ago
Victor Julien daeb8fd343 app-layer: detect flags API calls
Add API meant to replace the MpmIDs API. It uses a u64 for each direction
in a tx to keep track of 2 things:

1. is inspection done?
2. which prefilter engines (like mpm) are already completed
7 years ago
Victor Julien 51d429b3b1 flowbits: analyze and dump to json
Analyze flowbits to find which bits are only checked.

Track whether they are set and checked on the same level of 'statefulness'
for later used.

Dump flowbits to json including the sids that set/check etc the bit.
7 years ago
Victor Julien d05355db3d filestore: minor cleanups and warning fixes 7 years ago
Jason Ish 46d754044e suricatasc: don't use find -delete
For when -delete isn't supported by find. Instead use
-print0 with xargs -0.
7 years ago
Jason Ish 5420c0ab06 doc: document file-store v2 7 years ago
Jason Ish aa0760a8d5 filestore: only allow one filestore to be enabled
There is probably not too much bad about enabling both, but
open file counts can get messy with both enabled. And v1
should be schedule for deprecation soon enough.
7 years ago
Jason Ish cc35a5b81f filestore (old): register global stat in init func
This doesn't need to be registered from suricata.c. And moving
it to the init function makes sure its only registered if
the logger is actually enabled.
7 years ago
Jason Ish 9b1d268071 filestore2: warn once for file errors
Track each type of error warning and only log it once. Also create
a new stat, file_store.fs_errors to count each file system type
error (open, rename, unlink).

Also remove exit stats, they are of limited value.
7 years ago
Jason Ish 9456a3164d util-error: define SC_ERR_MAX 7 years ago
Jason Ish 50b5a3a56d suricatactl: a new python script for misc. tasks
Use a new directory, Python to host the Suricata python modules.
One entry point is suricatactl, a control script for
miscalleneous tasks. Currently onl filestore pruning
is implemented.
7 years ago
Jason Ish f7c3f30186 filestore v2: use fileinfo records as metadata
As fileinfo records are logged to the main eve log, disable
metadata by default. But when enabled, just use the fileinfo
record.

Metadata is stored in a file named:
  <sha256>.<seconds>.<file_id>.json

where the sha256 is the same as the file logged, the seconds
is the unix timestamp in seconds for the fileinfo record,
and the file_id is an atomically incremented integer per
Suricata instance.

This should allow for each occurrence of the same file to have
its own metadata file. But a collision is expected when running
Suricata repeatedly over the same pcap, as that would be the
exact same occurrence of a file.
7 years ago
Jason Ish f631e8cd90 file extract: force sha256 even if truncated
Even if a file is truncated, force the SHA256 if force sha256
is set to yes.

The new file store requires the sha256 regardless of the file
state if it is to be logged, as the filename is based on the
sha256.
7 years ago
Jason Ish 4a97315057 filestore v2 - initial version
Filestore v2 is starts as a copy of log-filestore with the
following changes.

- NSS is required as file names as based on the SHA256.
- Work/tmp files are stored in a temp. directory, then
  moved into a directory tree where the directory names
  are the first 2 characters of the hex SHA256.
- Removes the need for a waldo file or pid in the filenames.
7 years ago
Jason Ish dbdac73784 configure: check for utime.h and utime() 7 years ago
Jason Ish ccbe7401b6 output-json-file: let caller decide if file is stored
Mainly for the filestore module, which may have its own
knowledge of the file being stored before others.
7 years ago
Jason Ish 59bb98afcc eve/fileinfo: split record creation from writing
Split the building of the fileinfo record from the writing
of the record so the building can be called from other code.
Specifically the new filestore output which uses fileinfo
records as the metadata.
7 years ago
Jason Ish c8b6212a97 util-error: new error: SC_ERR_CREATE_DIRECTORY
For logging directory create errors.
7 years ago
Jason Ish 38bbdb51d5 SCPathExists - function to see if a path exists
Returns true if path exists, otherwise false.
7 years ago
Jason Ish c0ffe4055a create directory: final arg to control full path or prefix
Give SCCreateDirectoryTree a new argument, final. If true the
full path will be created as a directory. If false, the last
component will not be created as a directory (current
behaviour).
7 years ago
Jason Ish 0d558ddc27 create directory: fix strlcpy usage
The final character was being cut off.
7 years ago
Jason Ish de2fffca5e util: move SCCreateDirectoryTree to util-path
Renames SCLogCreateDirectoryTree to SCCreateDirectoryTree
and move into a util module for re-use.

Also moves SCMkDir from suricata-common.h to the more
appropriately names util-path.h.

I would have prefered to use util-file for file related options
but that is already used by file store utilities. util-path
is close enough for file related operations.
7 years ago
Jason Ish 00e6cd4ced output: introduce init return type
The new OutputInitResult is a struct return type that allows
logger init functions to return a NULL context without
raising error.

Instead of returning NULL to signal error, the "ok" field will
be set to false. If ok, but the ctx is NULL, then silently
move on to the next logger.

Use case: multiple versions of a specific logger, and one
implementation decides the configuration is not for that
implemenation. It can return NULL, ok.
7 years ago
Victor Julien 50a762bfd1 thresholds: fix issues with host based thresholds
The flow manager thread (that also runs the host cleanup code) would
sometimes free a host before it's thresholds are timed out. This would
lead to misdetection or too many alerts.

This was mostly (only?) visible on slower systems. And was caused by a
mismatch between time concepts of the async flow manager thread and the
packet threads, resulting in the flow manager using a timestamp that
was before the threshold entry creation ts. This would lead to an
integer underflow in the timeout check, leading to a incorrect conclusion
that the threshold entry was timed out.

To address this,  check if the 'check' timestamp is not before the creation
timestamp.
7 years ago
Victor Julien 4b24d965b8 stream/midstream: be more liberal with window
Use the wscale setting when updating the window, even if it's very
high.
7 years ago
Victor Julien 38e6901c34 threads: don't crash in slow shutdown
If TmThreadDrainPacketThreads would take more than 60 seconds, the wait
loop that follows it would reach 'timeout' condition immediately. This
would lead to a null ptr deref of 'tv'.

Fix by not counting the TmThreadDrainPacketThreads and also not doing
the null ptr deref in any case.
7 years ago
Maurizio Abba 62ac13523a time: Force init cached_minute_start array
In offline mode, if the starting timestamp is 0 suricata will never
initialize cached_minute_start array. This cause the timestamp to be
ignored when needed (e.g., in fast.log).

This commit will force the initialization of this array.
7 years ago
Pierre Chifflier 4b6555588f NTP: ensure parser name is not freed after registration 7 years ago
Danny Browning aae50f8a7e util-time: Add function to convert timespec to epoch millis 7 years ago
Victor Julien e41acd3d05 destate: test cleanups 7 years ago
Victor Julien 56b1df1b4d http: clean up & improve unittests 7 years ago
Eric Leblond ba0899a77f conf: add function to get child with default 7 years ago
Eric Leblond 4bfa3aeaf9 af-packet: synchronize flags sizes
They are passed from config to threads so they need to be of the
same size.
7 years ago
Maurizio Abba 7266c12b4f print: Escape backslash in PrintRawUriFp
PrintRawUriFp does not properly escape backslash. This causes confusion
between a \ character and an hex-encoded character. PrintRawUriBuffer,
instead, correctly does backslash-encoding.
Adding proper escaping of backslash to PrintRawUriFp.
7 years ago
Pierre Chifflier ec62eedc87 Rust: remove deprecated functions LoggerFlags::get_logged/set_logged 7 years ago
Pierre Chifflier 5c6868b327 NTP: update logger to use new API 7 years ago
Victor Julien 044e7b8e20 output: add missing dnp3 profiling labels 7 years ago
Victor Julien d634140fa2 logging: unique id's per log direction
For loggers that register once per direction, use unique id's per
direction.

Reshuffle id's to keep tx log id's low so we can use u32 for tracking
logged loggers.
7 years ago
Victor Julien bca0cd71ae app-layer: use logger bits to avoid looping
Avoid looping in transaction output.

Update app-layer API to store the bits in one step
and retrieve the bits in a single step as well.

Update users of the API.
7 years ago
Victor Julien 01724f04fa app-layer: register per proto logger bits
Create a bitmap of the loggers per protocol. This is done at runtime
based on the loggers that are enabled. Take the logger_id for each
logger and store it as a bitmap in the app-layer protcol storage.

Goal is to be able to use it as an expectation later.
7 years ago
Victor Julien 40986b1f61 detect: put inspect code for MATCH-list into func
Introduce DetectRunInspectRulePacketMatches to inspect the signatures
match list.
7 years ago
Victor Julien 70597066e0 detect: move detect cleanup into util func 7 years ago
Victor Julien 01f9d0076c detect: move packet hdr inspect into util func 7 years ago
Eric Leblond 9ecd60c7a2 detect-ftpdata: register keyword
Keyword registration was missing so the keyword was not existing.
7 years ago
Maurizio Abba 204474de39 runmodes: fix single runmode bug with pcap
Fix crash for suricata running with pcap option and single runmode.

Ticket: https://redmine.openinfosecfoundation.org/issues/2403
7 years ago
Victor Julien e1e9ada9df rust/nfs: improve file close handling 7 years ago
Nick Price 350b5d99ce rust/nfs: don't panic on malformed NFS traffic
Instead set events.
7 years ago
Eric Leblond ce59ec5d13 af-packet: free ring buffer at exit 7 years ago
Victor Julien 485663583a rust/mingw: fix linker issues on mingw 7 years ago
Victor Julien 746638b220 cuda: remove
Remove CUDA support as it has been broken for a long time.

Ticket #2382.
7 years ago