Commit Graph

386 Commits (suricata-5.0.5)

Author SHA1 Message Date
Philippe Antoine b0a1bddb16 rust: fix warnings found by nightly compiler
warning: getting the inner pointer of a temporary `CString`
this `CString` is deallocated at the end of the statement,
bind it to a variable to extend its lifetime

(cherry picked from commit 8db78208f9)
5 years ago
Jason Ish a5e14258f9 rust: handle windows naming change from .lib to .a
Prior to Rust 1.44, Cargo would name static libs with the .lib
extension. 1.44 changes this extension to .a when running under
a GNU environment on Windows like msys to make it more similar
to other unix environments.

Now assume static library name to be the same on Windows and
unix, but rename the .lib if found to still support older
versions of Rust on Windows.

(cherry picked from commit f3c59ef8a6)
5 years ago
Victor Julien 83c9b305ac smb: check post-gap timeouts once a second at most
(cherry picked from commit 25f2efe977)
5 years ago
Victor Julien 264eecbdef smb: update ts only if it changed
(cherry picked from commit 8aa380600d)
5 years ago
Victor Julien c8be282533 smb: fix 'dangling' files in lossy sessions
In case of lossy connections the SMB state would properly clean up
transactions, including file transactions. However for files the
state was never set to 'truncated', leading to files to stay 'active'.

This would lead these files staying in the SMB's state. In long running
sessions with lots of files this would lead to performance and memory
use issues.

This patch cleans truncates the file that was being transmitted when
a file transaction is being closed.

(cherry picked from commit 65e9a7c31c)
5 years ago
Philippe Antoine 075fbc5c4e smb: resistance against padding evasions
Scenario is use of dummy padding in write AndX request
or other similar commands using a data offset.

Parsing skips now these dummy bytes, and generates one event
5 years ago
Philippe Antoine fbc856f14d smb: adds file overlap event against evasions
Evasion scenario is
- a first dummy write of one byte at offset 0 is done
- the second full write of EICAR at offset 0 is then done
and does not trigger detection

The last write had the final value, and as we cannot "cancel"
the previous write, we set an event which is then transformed into
an app-layer decoder alert
5 years ago
Jason Ish 19ed8dcc9b dhcp: set unidirection transaction flag
(cherry picked from commit 0529a00ffd)
5 years ago
Jason Ish 34a69d040e ikev2: set unidirection transaction flag
(cherry picked from commit 3036ec4db0)
5 years ago
Jason Ish c00c7ec070 sip: set unidirection transaction flag
(cherry picked from commit 54d5f336d4)
5 years ago
Jason Ish 41ce783896 rdp: set unidirection transaction flag
(cherry picked from commit 1d40d0c5f9)
5 years ago
Jason Ish 4a343c1585 krb5: set unidirection transaction flag
(cherry picked from commit f7dee602e9)
5 years ago
Jason Ish 2d1379d39c ntp: set unidirection transaction flag
(cherry picked from commit 984d3c7f20)
5 years ago
Jason Ish a39fa120ef snmp: set unidirectional transaction flag
(cherry picked from commit fc7d59d92f)
5 years ago
Jason Ish 428b06426c applayer: add flags to parser registration struct
This will allow Rust parsers to register for gap handing from
Rust (some Rust parsers do handle gaps, but they set the flag
from C).

(cherry picked from commit 53aa967e0b)
5 years ago
Jason Ish f22b1eb546 app-layer: backport unidirectional tx option
This is a partial backport of:
ac3cf6ff75

    detect/config: set config for special cases

    Allow app-layer to declare the txs are uni-directional and special
    care is needed for applying config.
5 years ago
Victor Julien 9c13d26ada nfs: fix 'dangling' files in lossy sessions
In case of lossy connections the NFS state would properly clean up
transactions, including file transactions. However for files the
state was never set to 'truncated', leading to files to stay 'active'.

This would lead these files staying in the NFS's state. In long running
sessions with lots of files this would lead to performance and memory
use issues.

This patch cleans truncates the file that was being transmitted when
a file transaction is being closed.

Based on 65e9a7c31c

(cherry picked from commit 44d7dd02b3)
5 years ago
Victor Julien 54d4a8ffb0 nfs: check post-gap timeouts once a second at most
Based on 25f2efe977

(cherry picked from commit 760d6c1877)
5 years ago
Victor Julien 77c79ebb86 nfs: update ts only if it changed
Based on 8aa380600d

(cherry picked from commit f8e9fe95cb)
5 years ago
Philippe Antoine 8026390672 kerberos: fix against packet split in record size
(cherry picked from commit 23f796a021)
5 years ago
Victor Julien a2ebab10e2 nfs: fix buffering code using wrong dir 5 years ago
Sascha Steinbiss 16fda46bf7 sip: address trailing space parsing
(cherry picked from commit 11912bd715)
5 years ago
Victor Julien 8af7637915 smb: fix rustc 1.42 warnings
(cherry picked from commit a729d266c3)
5 years ago
Victor Julien 908ba0f8b4 nfs: implement post-GAP transaction cleanup
Close all prior transactions in the direction of the GAP, except the
file xfers. Those use their own logic described below.

After a GAP all normal transactions are closed. File transactions
are left open as they can handle GAPs in principle. However, the
GAP might have contained the closing of a file and therefore it
may remain active until the end of the flow.

This patch introduces a time based heuristic for these transactions.
After the GAP all file transactions are stamped with the current
timestamp. If 60 seconds later a file has seen no update, its marked
as closed.

This is meant to fix resource starvation issues observed in long
running SMB sessions where packet loss was causing GAPs. Due to the
similarity of the NFS and SMB parsers, this issue is fixed for NFS
as well in this patch.

Bug #3424.
Bug #3425.

(cherry picked from commit f68c255f09)
6 years ago
Victor Julien 36902bab31 rust/rpc: add partial data test 6 years ago
Victor Julien 060781cef8 smb: handle file transactions post-GAP
After a GAP all normal transactions are closed. File transactions
are left open as they can handle GAPs in principle. However, the
GAP might have contained the closing of a file and therefore it
may remain active until the end of the flow.

This patch introduces a time based heuristic for these transactions.
After the GAP all file transactions are stamped with the current
timestamp. If 60 seconds later a file has seen no update, its marked
as closed.

This is meant to fix resource starvation issues observed in long
running SMB sessions where packet loss was causing GAPs.
6 years ago
Jason Ish 95a408f77d flow: expose last time as a function
This function returns the individual components
of the timeval in output pointers making it suitable
for use over Rust FFI.
6 years ago
Victor Julien ce0ae81d95 rust: fix vendor use on MinGW 6 years ago
Jason Ish 57b683233d rust: Don't use --frozen during build.
If sources are vendored, we get the same effect of using frozen
with a lock file, and the Cargo.lock is generated based
on the vendored sources.

This also removes the need to ship a Cargo.lock.

Fixed out of source builds with vendored sources.
6 years ago
Jason Ish c6f168eb98 rust/Makefile: Don't include Cargo.toml
There is no need to include Cargo.toml in the distribution,
it is always generated from Cargo.toml.in during
./configure.
6 years ago
Jason Ish 5ee8323028 rust: remove unnecessary parentheses (Rust 1.40 fixup)
Rust 1.40 in strict mode will now fail the build on the
presence of unnecessary parentheses.

warning: unnecessary parentheses around type
  --> src/smb/smb2_ioctl.rs:41:12
   |
41 |         -> (&mut SMBTransaction)
   |            ^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
   |
   = note: `#[warn(unused_parens)]` on by default
6 years ago
Victor Julien f5b33a070a smb1: allow empty trans records 6 years ago
Victor Julien 40fe29de96 smb1: fix 'event' txs not getting closed
If the only reason we created a request side TX was to set an event,
we would not close it.

This patch always looks up the TX from the response side.
6 years ago
Victor Julien 129cd28058 smb/dcerpc: close request tx sooner 6 years ago
Victor Julien 44ac3e30dd smb: post-GAP handling update
Close all prior transactions in the direction of the GAP, except the
file xfers. Those use their own logic.
6 years ago
Victor Julien a7ee2ffbde smb: winreg is a DCERPC facility 6 years ago
Ciprian c9cd7559fd configure: fixing rust/cargo cross compile command
adding --target argument to cargo command line when cross compiling
6 years ago
Jason Ish e2c846d01f snmp: add tx detect flags 6 years ago
Jason Ish fa4b9d37c2 krb5: register tx detect flags
Related ticker #3345:
https://redmine.openinfosecfoundation.org/issues/3345
6 years ago
Jason Ish 8a232be77e rust: define TxDetectFlag struct and binding macros
Define a TxDetectFlag type and macros to generating C
bindings for getting and settings the tx detect
flags.
6 years ago
Jason Ish cde49ec246 rust: add tx detect flags function to registration struct 6 years ago
Victor Julien f9155aa121 files: simplify pruning logic
Since ebcc4db84a the flow worker runs
file pruning after parsing, detection and loging. This means we can
simplify the pruning logic. If a file is in state >= CLOSED, we can
prune it. Detection and outputs will have had a final chance to
process it.

Remove the calls to the pruning code from Rust. They are no longer
needed.
6 years ago
Victor Julien b4318a11e3 rust: remove build system HAVE_RUST guards 6 years ago
Jason Ish a3cdef2b4d rust: run tests with same features as build
Cargo check wasn't being passed --features so could have a different
configuration than the build.
6 years ago
Jason Ish 389272f4c7 rustup: handle rustup for sudo and su
If rustup is in use, and a user uses sudo or su for the make
install, the install may fail with a "no default toolchain"
error.

To prevent this, detect at configure if rustup is being used,
then set RUSTUP_HOME for all calls to cargo.
6 years ago
Jason Ish 6e981fd15a rust: fix build when source directory has spaces in it
Redmine issue:
https://redmine.openinfosecfoundation.org/issues/2668
6 years ago
Jason Ish f9c9548b74 configure: detect lua integer size
Lua 5.1 and 5.3 use a different integer size. Run a test program
to set the integer size used in the Rust FFI layer to Rust.
6 years ago
Jeff Lucovsky bd691778eb rust/ftp: add parser for active mode port handling 6 years ago
Jason Ish 517ecd68a9 sip: rustfmt
As this is new Rust code, format with rustfmt using default
styling.
6 years ago
Jason Ish a45a2fa1fc sip: disable by default in 5.0 6 years ago