Commit Graph

15673 Commits (72146b969c06fb95399673bf61b0f97ac4d2bae0)
 

Author SHA1 Message Date
Jason Ish c476fcc85b suricata: expose FinalizeRunMode and ParseCommandLine
Expose the functions FinalizeRunMode and ParseCommandLine to library
users, renaming with the `SC` prefix in the process.

This involves moving "application" level details from SuricataInit
into SuricataMain, as parsing command line options should be opt-in
for a library user.
11 months ago
Jason Ish e18779c1b4 windows: remove argc, argv from SCServiceRemove
Not used.
11 months ago
Jason Ish 8dc5478d0a suricata: remove argv from FinalizeRunMode
FinalizeRunMode can get the program name from suri->progname.
11 months ago
Jason Ish 04bd026c5b suricata: remove instance from ParseCommandLine
We want to be able to call ParseCommandLine from library users, but
currently library users don't have access to the `suricata` instance
type. Since this var is used other places as a global, use the global
one in ParseCommandLine as well.

Not ideal, but isolating SCInstance to a non-global will be another
challenge on its own.
11 months ago
Jason Ish db44740fd8 suricata: move WindowsInitService to SuricataMain
Move WindowsInitService from SuricataInit() to SuricataMain(), as
initializing Suricata as a service is very specific to the application
and not something you'd want to happen in a library, and SuricataInit
is more common initialization for application and library usage.
11 months ago
Jason Ish 2dc39d31c6 examples/lib: replicate Suricata using the library
With more functions exposed via the library, a library user can now
replicate the Suricata "main" function.
11 months ago
Jason Ish cfd98e92a0 suricata: expose SuricataMainLoop and GlobalsDestroy
Expose SuricataMainLoop and GlobalsDestroy so that SuricataMain can be
replicated by a library user of Suricata.

These removes the `suricata` instance as a function argument to some
of these functions, as the way we use it now, it serves no
purpose. However, it is a reminder that it should probably be
refactored to not be a global, as at some point it might be desirable
for to have multiple instances active without data sharing.
11 months ago
Angelo Mirabella 67d23c7b61 libsuricata: reorganize SuricataMain code
Split SuricataMain code in smaller functions. This is a first step
towards running as a library.
11 months ago
Shivani Bhardwaj 7d937db5cb detect/port: fix grouping of ports w gaps
If a single port happens before a range port, the port groups created
were incorrect. Fix it to use smarter range check.

For example, given,
80:80 - SGH1
100:120 - SGH2

Range created should be
80:80 - SGH1
100:120 - SGH2

Bug 6881
11 months ago
Victor Julien 0be3ba802e eve/alert: fix validation check
Bug: #6875.
11 months ago
Philippe Antoine f7cde8f00e rust/smb: fix clippy nightly warning
error: unnecessary use of `to_vec`
    --> src/smb/smb.rs:1048:62
     |
1048 |         let (name, is_dcerpc) = match self.guid2name_map.get(&guid.to_vec()) {
     |                                                              ^^^^^^^^^^^^^^ help: replace it with: `guid`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned
     = note: `#[deny(clippy::unnecessary_to_owned)]` implied by `#[deny(warnings)]`

And also other uses of to_vec() on already Vec
12 months ago
Philippe Antoine 02f2fb8833 rust: fix clippy 1.77 warning
Ticket: 6883

error: field `0` is never read
  --> src/asn1/mod.rs:36:14
   |
36 |     BerError(Err<der_parser::error::BerError>),
   |     -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     field in this variant
   |
12 months ago
Victor Julien a2c817243f rust: add MSRV as rust-version
Update github-actions to use it for the MSRV check.
12 months ago
Jeff Lucovsky bf5cfd6ab7 profiling/rules: Improve dynamic rule handling
Issue: 6861

Without this commit, disabling rule profiling via suricatasc's command
'ruleset-profile-stop' may crash because profiling_rules_entered becomes
negative.

This can happen because
- There can be multiple rules evaluated for a single packet
- Each rule is profiled individually.
- Starting profiling is gated by a configuration setting and rule
  profiling being active
- Ending profiling is gated by the same configuration setting and
  whether the packet was marked as profiling.

The crash can occur when a rule is being profiled and rule profiling
is then disabled after one at least one rule was profiled for the packet
(which marks the packet as being profiled).

In this scenario, the value of profiling_rules_entered was
not incremented so the BUG_ON in the end profiling macro trips
because it is 0.

The changes to fix the problem are:
- In the profiling end macro, gate the actions taken there by the same
  configuration setting and use the profiling_rues_entered (instead of
  the per-packet profiling flag). Since the start and end macros are
  tightly coupled, this will permit profiling to "finish" if started.
- Modify SCProfileRuleStart to only check the sampling values if the
  packet hasn't been marked for profiling already. This change makes all
  rules for a packet (once selected) to be profiled (without this change
  sampling is applied to each *rule* that applies to the packet.
12 months ago
Philippe Antoine c4b8fb7aca ssh: limit length for banner logs
Ticket: 6770
12 months ago
Philippe Antoine 271ed2008b ssh: avoid quadratic complexity from long banner
Ticket: 6799

When we find an overlong banner, we get into the state just
waiting for end of line, and we just want to skip the bytes
until then.
Returning AppLayerResult::incomplete made TCP engine retain
the bytes and grow the buffer that we parsed again and again...
12 months ago
Philippe Antoine cc3b4b01ec detect: flush when setting no_inspection
Ticket: 6578

When a protocol such as SSH sets no_inspection, we still have to
flush the current streams and packets that contain clear-text
for detection.
12 months ago
Philippe Antoine 4c4f7ff1a2 detect: update packet action on protocol change
Ticket: #6305

When running FlowWorkerStreamTCPUpdate, one of the dequeued packet
may set the flow action to drop, without updating the not-pseudo
packet action, as is done usually with a previous call to
FlowHandlePacketUpdate
12 months ago
Victor Julien ff8597d50b membuffer: annotate printf style function 12 months ago
Victor Julien 926c6e3add eve/alert: break out of payload logging callback if buffer is full 12 months ago
Victor Julien 1dea4fea0b eve/frame: break out of logging callback if buffer is full 12 months ago
Victor Julien 7d5b537f5c membuffer: return bytes written 12 months ago
Victor Julien 9c3669b03f membuffer: use buffer pointer as flexible array member 12 months ago
Victor Julien 3ef98f2b87 membuffer: turn complex macros into functions
For better readability and type checking.
12 months ago
Victor Julien ea98df8da2 unix-manager: add \n string to buffer using correct API call 12 months ago
Victor Julien 6e10c66078 eve/frame: improve frame payload logging
Log using stream callback API, meaning that data will also
be logged if there are GAPs.

Also implement GAP indicators: '[123 bytes missing]'.
12 months ago
Victor Julien a205583269 eve/frames: pass membuffer to API
In preparation of stream logging changes.
12 months ago
Victor Julien 462a6d7913 eve/alert: init membuffer size on missing config
Don't init buffer to 0 size but use the desired default of 4k.
12 months ago
Victor Julien 43858f70ad eve/alert: log payload directly from stream buffer
This avoids looping over partly duplicate segments that cause
output data corruption by logging parts of the stream data multiple
times.

For data with GAPs now add a indicator '[4 bytes missing]' similar
to how Wireshark does it.

Bug: #6553.
12 months ago
Victor Julien 829bab295b eve/frame: implement payload-buffer-size option
Modeled after the same option in eve/alert. Defaults to 4k.
12 months ago
Victor Julien a5a6527d26 stream: const args for StreamReassembleLog
Needed a workaround cast for RBTREE use.
12 months ago
Victor Julien f53c4ab149 yaml: remove newline from error message 12 months ago
Jeff Lucovsky e41c2f15c2 gen/typo: Correct comment typo 12 months ago
Jeff Lucovsky 3c5745978f flow: Swap thread_ids
Issue: 6835

When swapping the flow's direction, also swap the thread_ids.

This should help with the issues identified in
https://redmine.openinfosecfoundation.org/issues/2725
12 months ago
Jeff Lucovsky 9ad73faa0a flow/inject: Ensure initialized thread value used
Issue: 6835

When injecting a flow, ensure that the selected thread_id has been
initialized. When a flow is picked up midstream, the initialized thread
can be the second thread element.
12 months ago
Philippe Antoine 632e52ca2b ci: update ubuntu22.04 builds with clang14+asan
using a workround about ASLR
12 months ago
Lukas Sismis 16c88f2db7 dpdk: fix typo in the struct member name 12 months ago
Lukas Sismis 5592ec079d dpdk: refactor the main packet loop into smaller functions 12 months ago
Lukas Sismis 0b5966c347 dpdk: only close the port when workers are synchronized
When Suricata was running in IPS mode and received a signal to stop,
the first worker of every interface/port stopped the port and
proactively stopped the peered interface as well.
This was done to be as accurate with port stats as possible.
However, in a highly active scenarios (lots of packets moving around)
the peered workers might still be in the process of a packet
release operation. These workers would then attempt to transmit
on a stopped interface - resulting in an errorneous operation.

Instead, this patch proposes a worker synchronization of the given
port. After these workers are synchronized, it is known that no packets
will be sent of the peered interface, therefore the first worker can
stop it. This however cannot be assumed about "its own" port as the
peered workers can still try to send the packets. Therefore, ports
are only stopped by the peered workers.

Ticket: #6790
12 months ago
Philippe Antoine 45bb936187 http: event on request line missing protocol
Ticket: 6856
12 months ago
Jason Ish 8284df3ed4 devguide: add an upgrade section
Add an upgrade section to the devguide. This should cover any changes
to APIs that users might be using from plugins or as a library user.
12 months ago
Jason Ish b7b16fb481 eve/filetype: reorder fields to match lifecycle
Enhances readability.
12 months ago
Jason Ish a3354e55e6 eve/filetypes: use more const 12 months ago
Jason Ish eee9757dba eve/filetype: ThreadDeinit can return void
Change ThreadDeinit to return void instead of an int, there is nothing
to be done on success or failure.
12 months ago
Jason Ish cd85d89f14 output-eve: doxygen docs for SCEveFileType
Add documentation for the SCEveFileType in Doxygen format.
12 months ago
Jason Ish 500d29f356 doxygen: document the examples directory 12 months ago
Jason Ish bd55cd4c55 eve/filetypes: common init for threaded and non-threaded
In 7.0 if EVE was non-threaded, the ThreadInit for the filetype was
not called meaning that the filetype author had to handle the threaded
and non-threaded cases.

To simplify this, if non-threaded, still call ThreadInit (and
ThreadDeinit) once with a thread_id of 0. This should simplify
authoring EVE filetype plugins.
12 months ago
Jason Ish 3ff72d3efa eve: rename plugin to filetypes
EVE filetypes are not always plugins, for example, null and syslog
that are built-in filetypes.
12 months ago
Jason Ish 7c8c9fff32 plugins: remove conf.h from suricata-plugin.h
Remove "conf.h" from suricata-plugin.h as its not needed by that
header. However, some other files became transitively dependent on
through other includes, so fix those up.
12 months ago
Jason Ish ead09c2497 eve/filetypes: remove from plugin context
Remove EVE filetypes from plugin context as they are not only used
from plugins. Plugins allow user code to register filetypes, but we
also have internal file types that use this api including the null
output and syslog.  Additionally library users can use this API to
register filetypes, and they are not plugins.

Ideally this code would go in "output-json.[ch]" as the "primary" eve
API, however there are currently some include circular include issues
there, so start new cleaned up EVE API in "output-eve.[ch]" which is
"clean" with respect to includes, and as we cleanup existing EVE API for
"public" use, it can be moved here.

Ticket: #6838
12 months ago