]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
5 years agoutil: check if parsed data is in range 5101/head
Shivani Bhardwaj [Wed, 17 Jun 2020 13:11:51 +0000 (18:41 +0530)] 
util: check if parsed data is in range

5 years agosrc: remove multiple uses of atoi
Shivani Bhardwaj [Sat, 21 Dec 2019 08:37:58 +0000 (14:07 +0530)] 
src: remove multiple uses of atoi

atoi() and related functions lack a mechanism for reporting errors for
invalid values. Replace them with calls to the appropriate
ByteExtractString* and StringParse* functions.

Partially closes redmine ticket #3053.

5 years agoaffinity: Convert nb_threads to uint32_t
Shivani Bhardwaj [Sat, 20 Jun 2020 14:39:17 +0000 (20:09 +0530)] 
affinity: Convert nb_threads to uint32_t

5 years agonapatech: make stream_id uint8_t
Shivani Bhardwaj [Fri, 26 Jun 2020 06:59:23 +0000 (12:29 +0530)] 
napatech: make stream_id uint8_t

5 years agoredis: Change port type to uint16_t
Shivani Bhardwaj [Tue, 12 May 2020 18:50:37 +0000 (00:20 +0530)] 
redis: Change port type to uint16_t

5 years agorust: lock to nom 5.1.1 5077/head
Jason Ish [Tue, 16 Jun 2020 14:04:49 +0000 (08:04 -0600)] 
rust: lock to nom 5.1.1

5.1.2 pulls in dependencies that don't build on Rust 1.34.

5 years agoapp-layer: remove old MPMId API calls 5059/head
Victor Julien [Tue, 26 May 2020 08:35:34 +0000 (10:35 +0200)] 
app-layer: remove old MPMId API calls

Had been deprecated and non-functional since 2017.

5 years agojson: macros for setting formatted true and string values
Jason Ish [Mon, 8 Jun 2020 18:28:02 +0000 (12:28 -0600)] 
json: macros for setting formatted true and string values

JB_SET_TRUE(jb, key), and JB_SET_STRING(string, key, val) are C macros
around jb_set_formatted to set static string and true values as a
(micro) optimization.

5 years agojsonbuilder: setter for formatted data
Jason Ish [Mon, 8 Jun 2020 18:27:05 +0000 (12:27 -0600)] 
jsonbuilder: setter for formatted data

Create a method to set preformatted data that contains the key
and the value already formatted.

This is an optimization for static data.

5 years agojsonbuilder: export {set,append}_string_from_bytes to C
Jason Ish [Mon, 8 Jun 2020 17:11:28 +0000 (11:11 -0600)] 
jsonbuilder: export {set,append}_string_from_bytes to C

5 years agojsonbuilder: use Box::from_raw instead of transmute to free
Jason Ish [Mon, 8 Jun 2020 16:57:00 +0000 (10:57 -0600)] 
jsonbuilder: use Box::from_raw instead of transmute to free

I think this is a bad use of transmute, while the end result
is the same, Box::from_raw is more correct as we created this
pointer with Box::into_raw.

5 years agosignature: adds file flag for file_data keyword
Philippe Antoine [Fri, 1 May 2020 08:54:51 +0000 (10:54 +0200)] 
signature: adds file flag for file_data keyword

So that SigValidate can check if a protocol not supporting
files was set after this keyword

5 years agossh/eve: convert to jsonbuilder
Philippe Antoine [Sat, 6 Jun 2020 20:02:26 +0000 (22:02 +0200)] 
ssh/eve: convert to jsonbuilder

5 years agodoc: Improve tos description 5047/head
Jeff Lucovsky [Sat, 2 May 2020 14:09:12 +0000 (10:09 -0400)] 
doc: Improve tos description

This commit improves the description of the `tos` keyword by emphasizing
that the value used should adhere to the guidelines in RFC2474. Instead
of specifying the DSCP value directly, right shift the DSCP value and
use that.

5 years agodoc: pcrexform documentation
Jeff Lucovsky [Mon, 24 Feb 2020 13:22:33 +0000 (08:22 -0500)] 
doc: pcrexform documentation

5 years agodetect: Register pcrexform
Jeff Lucovsky [Sat, 7 Mar 2020 14:03:44 +0000 (09:03 -0500)] 
detect: Register pcrexform

This commit registers the `pcrexform` transform.

5 years agotransform/pcrexform: Add pcrexform source files
Jeff Lucovsky [Mon, 24 Feb 2020 13:22:52 +0000 (08:22 -0500)] 
transform/pcrexform: Add pcrexform source files

5 years agodetect/pcrexform: New transform: applies RE
Jeff Lucovsky [Mon, 24 Feb 2020 13:19:05 +0000 (08:19 -0500)] 
detect/pcrexform: New transform: applies RE

This commit adds a new transform -- pcrexform -- that applies a regular
expression to the transformation buffer. If an expression was captured,
that is output to the transformation buffer. Otherwise, the
transformation buffer is unchanged.

5 years agodetect: Add constant for new transform
Jeff Lucovsky [Sat, 7 Mar 2020 14:03:01 +0000 (09:03 -0500)] 
detect: Add constant for new transform

This commit adds the definition of the new `pcrexform` transform.

5 years agodetect/transform: Support transform options
Jeff Lucovsky [Fri, 31 Jan 2020 15:21:57 +0000 (10:21 -0500)] 
detect/transform: Support transform options

This commit adds support for transform-specific options. During Setup,
transforms have the signature string available for options detection.
When a transform detects an option, it should convert the option into an
internal format and supply a pointer to this format as the last argument
to DetectSignatureAddTransform.

Transforms that support options must provide a function in their
Sigmatch table entry. When the transform is freed, a pointer to the
internal format of the option is passed to this function.

5 years agogeneral: Correct typos
Jeff Lucovsky [Fri, 31 Jan 2020 14:59:29 +0000 (09:59 -0500)] 
general: Correct typos

5 years agogeneral: Update copyright year
Jeff Lucovsky [Fri, 31 Jan 2020 14:57:23 +0000 (09:57 -0500)] 
general: Update copyright year

5 years agodetect/asn1: Fix relative_offset keyword option
Emmanuel Thompson [Tue, 28 Apr 2020 18:03:26 +0000 (14:03 -0400)] 
detect/asn1: Fix relative_offset keyword option

- Fix relative_offset keyword option to be relative in regards to the
last content match
- Change relative_offset to int32_t with bounds check to allow the full
range of the packet buffer size (uint16_t)
- Added checks for over/underflows
- Changed the offset type to uint16_t because the offset is applied to
the payload length, which is a uint16_t
- Adjusted test cases to work relative to the content match
- Added test case to verify bounds

5 years agoredis: ensure a dump per second
Eric Leblond [Thu, 23 Jan 2020 12:30:29 +0000 (13:30 +0100)] 
redis: ensure a dump per second

In sync mode, Suricata was waiting to have batch size alerts before
logging them. This was introducing delay in some configuration with
low traffic.

5 years agoredis: fix reconnect in batch mode
Eric Leblond [Thu, 23 Jan 2020 12:10:44 +0000 (13:10 +0100)] 
redis: fix reconnect in batch mode

In case of redis outage, the redis session was reset but the replies
were still fetch even if there is none replies in the new session.

5 years agoredis: add support for unix socket
Eric Leblond [Fri, 29 May 2020 10:08:31 +0000 (12:08 +0200)] 
redis: add support for unix socket

If there is a '/' in the redis server string then we consider that
the connection should be done other a unix socket.

5 years agocmdline: --list-app-layer-protos respects -c arg
Joshua Lumb [Wed, 3 Jun 2020 12:24:40 +0000 (08:24 -0400)] 
cmdline: --list-app-layer-protos respects -c arg

5 years agohtp: enforce body limits more exact
Victor Julien [Thu, 4 Jun 2020 20:50:38 +0000 (22:50 +0200)] 
htp: enforce body limits more exact

5 years agoeve/alert: convert decoder event logging to jsonbuilder 5023/head
Victor Julien [Fri, 5 Jun 2020 05:24:40 +0000 (07:24 +0200)] 
eve/alert: convert decoder event logging to jsonbuilder

5 years agoeve/anomaly: don't add timestamp twice
Victor Julien [Fri, 5 Jun 2020 05:14:20 +0000 (07:14 +0200)] 
eve/anomaly: don't add timestamp twice

Timestamp is added unconditionally by CreateEveHeader(), so no need
to have a local timestamp in case of non-IP packets.

5 years agoeve/alert: clean up decoder event logging
Victor Julien [Fri, 5 Jun 2020 04:58:55 +0000 (06:58 +0200)] 
eve/alert: clean up decoder event logging

5 years agoeve/nfs: switch output to jsonbuilder
Victor Julien [Thu, 4 Jun 2020 12:28:59 +0000 (14:28 +0200)] 
eve/nfs: switch output to jsonbuilder

5 years agojsonbuilder: fix build error 5021/head
Giuseppe Longo [Thu, 4 Jun 2020 19:20:23 +0000 (21:20 +0200)] 
jsonbuilder: fix build error

Clang's build in travis-ci is actually failing because of this error:

output-json-alert.c:476:40: error: missing field 'state_index' initializer

      [-Werror,-Wmissing-field-initializers]

            JsonBuilderMark mark = { 0 };

5 years agouserguide: remove old drop-log documentation 5012/head
Jason Ish [Tue, 2 Jun 2020 17:01:42 +0000 (11:01 -0600)] 
userguide: remove old drop-log documentation

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/2381

5 years agodrop-log: remove drop log (deprecated)
Jason Ish [Tue, 2 Jun 2020 16:58:09 +0000 (10:58 -0600)] 
drop-log: remove drop log (deprecated)

Remove the old style line based drop log.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/2381

5 years agouserguide: RDP now enabled by default
Jason Ish [Tue, 2 Jun 2020 16:19:37 +0000 (10:19 -0600)] 
userguide: RDP now enabled by default

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/3255

5 years agordp: enable by default
Jason Ish [Tue, 2 Jun 2020 16:16:17 +0000 (10:16 -0600)] 
rdp: enable by default

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/3255

5 years agouserguide: SIP now enabled by default
Jason Ish [Tue, 2 Jun 2020 16:08:23 +0000 (10:08 -0600)] 
userguide: SIP now enabled by default

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/3256

5 years agosip: enable by default
Jason Ish [Tue, 2 Jun 2020 16:08:32 +0000 (10:08 -0600)] 
sip: enable by default

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/3256

5 years agoNapatech: Fix network byte order when comparing addresses
Phil Young [Mon, 1 Jun 2020 15:02:49 +0000 (11:02 -0400)] 
Napatech: Fix network byte order when comparing addresses

This fixes an issue where the "endieness" was not properly accounted for
when comparing two IPv4 addresses to be sorted.

5 years agoNapatech: Change to use separate FlowStream handle for each thread
Phil Young [Mon, 1 Jun 2020 15:01:06 +0000 (11:01 -0400)] 
Napatech: Change to use separate FlowStream handle for each thread

Previously a single handle to the FlowStream (which is  used to program
flows to the card) was shared between the threads.  This resulted
in contention between the threads where sometimes programming the flow would
silently fail.

5 years agodoc/userguide: add IPS with BPF info, minor cleanups
Victor Julien [Tue, 12 May 2020 08:19:55 +0000 (10:19 +0200)] 
doc/userguide: add IPS with BPF info, minor cleanups

5 years agoeve: print interface info for vxlan and other tunnel pkts
Victor Julien [Sat, 23 May 2020 13:12:45 +0000 (15:12 +0200)] 
eve: print interface info for vxlan and other tunnel pkts

5 years agogithub-ci: allow pull-request to be referenced in pr body
Jason Ish [Tue, 2 Jun 2020 14:28:15 +0000 (08:28 -0600)] 
github-ci: allow pull-request to be referenced in pr body

For example, to use suricata-verify pr #239:

suricata-verify-pr: 239

Also update the pull request template to contain the available
parameters that can be set.

5 years agorfb/eve: convert to jsonbuilder
Jason Ish [Fri, 22 May 2020 17:26:53 +0000 (11:26 -0600)] 
rfb/eve: convert to jsonbuilder

5 years agosmtp/eve: convert to jsonbuilder
Jason Ish [Thu, 21 May 2020 19:11:17 +0000 (13:11 -0600)] 
smtp/eve: convert to jsonbuilder

5 years agojsonbuilder: add reset marks
Jason Ish [Thu, 21 May 2020 19:06:50 +0000 (13:06 -0600)] 
jsonbuilder: add reset marks

Add methods to get the state of a JsonBuilder (called a mark),
then allow restoring to the mark.

5 years agoanomaly/eve: convert to jsonbuilder
Jason Ish [Mon, 4 May 2020 20:20:33 +0000 (14:20 -0600)] 
anomaly/eve: convert to jsonbuilder

5 years agotls/eve: convert to jsonbuilder
Jason Ish [Mon, 4 May 2020 20:01:12 +0000 (14:01 -0600)] 
tls/eve: convert to jsonbuilder

5 years agohttp/eve: remove jansson version of metadata logger
Jason Ish [Mon, 4 May 2020 18:14:36 +0000 (12:14 -0600)] 
http/eve: remove jansson version of metadata logger

With fileinfo converted over to JsonBuilder, these
Jansson versions are no longer needed.

5 years agofileinfo-filestore/eve: convert to jsonbuilder
Jason Ish [Mon, 4 May 2020 18:07:18 +0000 (12:07 -0600)] 
fileinfo-filestore/eve: convert to jsonbuilder

5 years agofileinfo: use addr info cache for address logging (jsonbuilder prep)
Jason Ish [Mon, 4 May 2020 17:42:47 +0000 (11:42 -0600)] 
fileinfo: use addr info cache for address logging (jsonbuilder prep)

This is to prepare for JsonBuilder conversion where we can't
overwrite an already set value. Here we prepare the addresses
to be logged in a struct, overwite with XFF if needed, then
log.

5 years agohttp/eve: convert to jsonbuilder
Jason Ish [Mon, 4 May 2020 16:47:44 +0000 (10:47 -0600)] 
http/eve: convert to jsonbuilder

5 years agoflow/eve: convert to jsonbuilder
Jason Ish [Wed, 29 Apr 2020 17:45:22 +0000 (11:45 -0600)] 
flow/eve: convert to jsonbuilder

5 years agorust: allow some clippy lints without warning
Jason Ish [Wed, 11 Mar 2020 17:43:17 +0000 (11:43 -0600)] 
rust: allow some clippy lints without warning

Suppresses some clippy lints that have more to do with style
than anything else, to reduce the amount of noise in the
clippy output.

5 years agodns/eve: convert to jsonbuilder
Jason Ish [Tue, 5 May 2020 15:14:36 +0000 (09:14 -0600)] 
dns/eve: convert to jsonbuilder

5 years agosip/eve: convert to jsonbuilder
Jason Ish [Wed, 4 Mar 2020 22:56:07 +0000 (16:56 -0600)] 
sip/eve: convert to jsonbuilder

5 years agodhcp/eve: add common eve fields
Jason Ish [Wed, 4 Mar 2020 21:48:54 +0000 (15:48 -0600)] 
dhcp/eve: add common eve fields

Add the common eve fields like metadata and community id.

5 years agodhcp/eve: convert to jsonbuilder
Jason Ish [Mon, 13 Jan 2020 16:44:32 +0000 (10:44 -0600)] 
dhcp/eve: convert to jsonbuilder

5 years agoalert/eve: convert to jsonbuilder
Jason Ish [Sun, 15 Mar 2020 17:05:16 +0000 (11:05 -0600)] 
alert/eve: convert to jsonbuilder

Convert alert Eve logging JsonBuilder. Currently
makes heavy use of JsonBuilder being able to log Jansson's json_t
which is a temporary measure until all protocols loggers can be
converted to JsonBuilder.

New functions that replace Jansson versions with JsonBuilder
variations use "Eve" instead of "JSON".

5 years agojsonbuilder: new module for generating json
Jason Ish [Tue, 7 Jan 2020 19:08:29 +0000 (13:08 -0600)] 
jsonbuilder: new module for generating json

JsonBuilder is a Rust module for creating JSON output. Unlike
Jansson, the final JSON string is built up as items are added,
instead of building up an object tree and rendering it when
done.

The idea is to create a more efficient JSON serializer instead
of a flexible one.

5 years agorust: bring back libc as a dependency
Jason Ish [Thu, 12 Mar 2020 21:33:32 +0000 (15:33 -0600)] 
rust: bring back libc as a dependency

Its already pulled in by some of other dependencies so adds zero
extra weight, and provides handy definitions for basic functions
like free().

5 years agorust/json: expose libjansson json_dumps
Jason Ish [Fri, 6 Mar 2020 21:13:44 +0000 (15:13 -0600)] 
rust/json: expose libjansson json_dumps

This will be temporarily used by JsonBuilder to add the ability
to extend JsonBuilder with Jansson's json_t types.

5 years agoalert/eve: use addr info struct for source/target (jsonbuilder prep)
Jason Ish [Fri, 13 Mar 2020 19:38:02 +0000 (13:38 -0600)] 
alert/eve: use addr info struct for source/target (jsonbuilder prep)

Update the source/target logging to use the cached address info
instead of fetching it from the constructed json_t object.

This is required for migration to JsonBuilder which does not
have the ability to retrieve already set fields.

5 years agoflow/eve: separate flow and app_proto logging (jsonbuilder prep)
Jason Ish [Sun, 15 Mar 2020 15:50:45 +0000 (09:50 -0600)] 
flow/eve: separate flow and app_proto logging (jsonbuilder prep)

Currently the flow logger also logs app_proto information,
but not to the flow object, but instead to the root object
of the log record.

Refactor into 2 separate methods, one for the app_proto
and one for the flow, to make this more clear, as well
as make it easier to refactor for JsonBuilder as JsonBuilder
can only write to the currently open object.

5 years agoeve/fivetuple: use intermediate address struct (jsonbuilder prep)
Jason Ish [Fri, 13 Mar 2020 19:25:56 +0000 (13:25 -0600)] 
eve/fivetuple: use intermediate address struct (jsonbuilder prep)

Currently alert logging relies on the ability to change existing
values in the json_t structure to overwrite addresses with xff
data. This feature is also used for the "target" logging.

As we can't do this with JsonBuilder, create a new struct to
hold the 5 tuple, with the values swapped as needed, and
overwritten with XFF data if needed. This struct will now
be used to write out the 5 tuple, as well as cache the information
for log fields to be written out later on in the log path.

5 years agoalert/eve: remove jansson specific feature (jsonbuilder prep)
Jason Ish [Thu, 12 Mar 2020 23:06:58 +0000 (17:06 -0600)] 
alert/eve: remove jansson specific feature (jsonbuilder prep)

Remove the Jansson specific feature of being able to delete
an object from json_t, in prep for refactors to JsonBuilder.

Instead create a new header for each alert to be logged.

5 years agoalert/eve: move logging of rule text (jsonbuilder prep)
Jason Ish [Thu, 12 Mar 2020 22:12:50 +0000 (16:12 -0600)] 
alert/eve: move logging of rule text (jsonbuilder prep)

Move the logging of the rule text to where the alert object
is being logged to remove the usage of json_object_get...

Getting previously logged objects will not be possible with
JsonBuilder.

5 years agodetect/pcre: set app proto correctly when using modifiers 5000/head
Victor Julien [Mon, 1 Jun 2020 10:56:20 +0000 (12:56 +0200)] 
detect/pcre: set app proto correctly when using modifiers

5 years agodetect/pcre: minor code cleanups
Victor Julien [Mon, 1 Jun 2020 10:50:20 +0000 (12:50 +0200)] 
detect/pcre: minor code cleanups

5 years agodetect: clarify and slightly cleanup non-pf logic
Victor Julien [Mon, 1 Jun 2020 10:16:40 +0000 (12:16 +0200)] 
detect: clarify and slightly cleanup non-pf logic

5 years agoflow/manager: fix management tasks not running
Victor Julien [Thu, 28 May 2020 06:33:57 +0000 (08:33 +0200)] 
flow/manager: fix management tasks not running

Fix tasks not running on the first manager, even if there is just
a single manager.

5 years agossh: minor cleanups in incomplete handling
Victor Julien [Sat, 30 May 2020 18:35:21 +0000 (20:35 +0200)] 
ssh: minor cleanups in incomplete handling

5 years agoapp-layer: support Copy and Clone traits in AppLayerResult
Victor Julien [Sat, 30 May 2020 18:34:41 +0000 (20:34 +0200)] 
app-layer: support Copy and Clone traits in AppLayerResult

5 years agoapp-layer: add methods to get status from AppLayerResult
Victor Julien [Sat, 30 May 2020 18:20:54 +0000 (20:20 +0200)] 
app-layer: add methods to get status from AppLayerResult

5 years agossh: handles incomplete record after banner
Philippe Antoine [Tue, 26 May 2020 06:46:24 +0000 (08:46 +0200)] 
ssh: handles incomplete record after banner

To signal incomplete data, we must return the number of
consumed bytes. When we get a banner and some records, we have
to take into account the number of bytes already consumed by
the banner parsing before reaching an incomplete record.

5 years agomagic: get rid of global lock
Eric Leblond [Fri, 29 May 2020 09:24:31 +0000 (11:24 +0200)] 
magic: get rid of global lock

Global magic context was involving a lock that appear to be really
costly for some traffic.

5 years agoaf-packet: fix warnings by undefined sanitizer
Victor Julien [Fri, 29 May 2020 12:27:24 +0000 (14:27 +0200)] 
af-packet: fix warnings by undefined sanitizer

5 years agocapture: optimize checksum handling
Victor Julien [Fri, 29 May 2020 11:04:47 +0000 (13:04 +0200)] 
capture: optimize checksum handling

Don't use a flag in the livedev, but overwrite the config setting after
'auto' mode has determined checksums should be disabled.

5 years agobuild: allows use of env variable CARGO_BUILD_TARGET 4986/head
Philippe Antoine [Thu, 28 May 2020 11:59:38 +0000 (13:59 +0200)] 
build: allows use of env variable CARGO_BUILD_TARGET

needed by oss-fuzz

5 years agowindows: fix timestring timezone display 4976/head
Victor Julien [Sat, 23 May 2020 18:57:21 +0000 (20:57 +0200)] 
windows: fix timestring timezone display

Bug: #3690

5 years agodetect/pcre: Use the keyword context for JIT stack
Jeff Lucovsky [Wed, 6 May 2020 12:10:44 +0000 (08:10 -0400)] 
detect/pcre: Use the keyword context for JIT stack

When PCRE `jit` is available, store the JIT stack in the keyword context
instead of on a global id. This ensures proper cleanup and
re-initialization over a rule reload.

5 years agoprofiling: c11 atomics fixup
Victor Julien [Mon, 11 May 2020 09:26:19 +0000 (11:26 +0200)] 
profiling: c11 atomics fixup

5 years agogithub actions: extract repo/branch names from PR message
Jason Ish [Tue, 28 Apr 2020 16:29:17 +0000 (10:29 -0600)] 
github actions: extract repo/branch names from PR message

Create a "prep" build that parses libhtp, suricata-update and
suricata-verify repo and branch information from the pull
request message and turn these into artifacts that are
used by the builders

Examples:

libhtp-repo: https://github.com/OISF/libhtp
libhtp-branch: 0.5.x

suricata-verify-repo: http://github.com/OISF/suricata-verify
suricata-verify-branch: master

suricata-update-repo: http://github.com/OISF/suricata-update
suricata-update-branch: master

Other changes:
- checkout@v2 (faster)
- working directory cleanup

5 years agodoc: document file-store v1 to v2 configuration changes
Jason Ish [Fri, 15 May 2020 17:28:49 +0000 (11:28 -0600)] 
doc: document file-store v1 to v2 configuration changes

5 years agosuricata.yaml: remove filestore v1 configuration
Jason Ish [Fri, 15 May 2020 17:28:26 +0000 (11:28 -0600)] 
suricata.yaml: remove filestore v1 configuration

5 years agofilestore v1: remove
Jason Ish [Wed, 6 May 2020 16:49:01 +0000 (10:49 -0600)] 
filestore v1: remove

File store v1 has been deprecated and was scheduled for removal
by June 2020.

Log an error if a file-store configuration is loaded without
version set to 2.

5 years agorules: add SSH decoder events rules 4971/head
Philippe Antoine [Thu, 5 Mar 2020 14:10:46 +0000 (15:10 +0100)] 
rules: add SSH decoder events rules

5 years agoparse: move SSH parser from C to Rust
Philippe Antoine [Thu, 5 Mar 2020 14:11:00 +0000 (15:11 +0100)] 
parse: move SSH parser from C to Rust

5 years agostyle: compressed function headers for rustfmt
Philippe Antoine [Wed, 8 Apr 2020 09:43:33 +0000 (11:43 +0200)] 
style: compressed function headers for rustfmt

5 years agorust: export enums definition to C
Philippe Antoine [Thu, 5 Mar 2020 14:10:06 +0000 (15:10 +0100)] 
rust: export enums definition to C

5 years agosmb: Import constants from DCERPC 4958/head
Shivani Bhardwaj [Tue, 21 Apr 2020 08:20:10 +0000 (13:50 +0530)] 
smb: Import constants from DCERPC

Remove DCERPC constants to avoid duplicate name errors. Import the
required constants from DCERPC implementation.

5 years agodcerpc: Replace C function calls with Rust
Shivani Bhardwaj [Tue, 21 Apr 2020 09:06:06 +0000 (14:36 +0530)] 
dcerpc: Replace C function calls with Rust

All the dead code in C after the Rust implementation is hereby removed.
Invalid/migrated tests have also been deleted.
All the function calls in C have been replaced with appropriate calls to
Rust functions. Same has been done for smb/detect.rs as a part of this
migration.

5 years agorust: Add DCERPC parser
Shivani Bhardwaj [Tue, 21 Apr 2020 08:55:43 +0000 (14:25 +0530)] 
rust: Add DCERPC parser

This parser rewrites the DCE/RPC protocol implementation of Suricata
in Rust. More tests have been added to improve the coverage and some
fixes have been made to the tests already written in C. Most of the
valid tests from C have been imported to Rust.

File anatomy

src/dcerpc.rs
This file contains the implementation of single transactions in DCE/RPC
over TCP. It takes care of REQUEST, RESPONSE, BIND and BINDACK business
logic before and after the data parsing. DCERPCState holds the state
corresponding to a particular transaction and handles all important
aspects. It also defines any common structures and constants required
for DCE/RPC parsing irrespective of the carrier protocol.

src/dcerpc_udp.rs
This file contains the implementation of single transactions in DCE/RPC
over UDP. It takes care of REQUEST and RESPONSE parsing. It borrows the
Request and Response structs from src/dcerpc.rs.

src/detect.rs
This file contains the implementation of dce_iface and opnum detect
keywords. Both the parsing and the matching is taken care of by
functions in this file. Tests have been rewritten with the test data
from C.

src/parser.rs
This file contains all the nom parsers written for DCERPCRequest,
DCERPCResponse, DCERPCBind, DCERPCBindAck, DCERPCHeader, DCERPCHdrUdp.
It also implements functions to assemble and convert UUIDs. All the
fields have their endianness defined unless its an 8bit field or an
unusable one, then it's little endian but it won't make any difference.

src/mod.rs
This file contains all the modules of dcerpc folder which should be
taken into account during compilation.

Function calls

This is a State-wise implementation of the protocol for single
transaction only i.e. a valid state object is required to parse any
record. Function calls start with the app layer parser in C which
detects the application layer protocol to be DCE/RPC and calls the
appropriate functions in C which in turn make a call to these functions
in Rust using FFI. All the necessary information is passed from C to the
parsers and handlers in Rust.

Implementation

When a batch of input comes in, there is an analysis of whether the
input header and the direction is appropriate. Next check is about the
size of fragment. If it is as defined by the header, process goes
through else the data is buffered and more data is awaited. After this,
type of record as indicated by the header is checked. A call to the
appropriate handler is made. After the handling, State is updated with
the latest information about whatever record came in.
AppLayerResult::ok() is returned in case all went well else
AppLayerResult::err() is returned indicating something went wrong.

5 years agorust: Add debug_validate_bug_on macro
Shivani Bhardwaj [Wed, 6 May 2020 18:00:53 +0000 (23:30 +0530)] 
rust: Add debug_validate_bug_on macro

This macro allows to check if certain parts of the code are reachable
during fuzzing.

5 years agorust: Add new crate uuid
Shivani Bhardwaj [Tue, 21 Apr 2020 08:02:26 +0000 (13:32 +0530)] 
rust: Add new crate uuid

5 years agorust: Add Debug and PartialEq to AppLayerResult
Shivani Bhardwaj [Tue, 21 Apr 2020 07:54:25 +0000 (13:24 +0530)] 
rust: Add Debug and PartialEq to AppLayerResult

5 years agofuzz: do not reuse global variable named suricata 4945/head
Philippe Antoine [Sat, 16 May 2020 12:30:13 +0000 (14:30 +0200)] 
fuzz: do not reuse global variable named suricata

5 years agofuzz: improves sigpcap target 4939/head
Philippe Antoine [Mon, 11 May 2020 12:06:10 +0000 (14:06 +0200)] 
fuzz: improves sigpcap target

So that it can cover alert generation
ie in function DetectRun, get past scratch.sgh == NULL condition

5 years agodoc/devguide: create basic layout 4904/head
Victor Julien [Thu, 30 Apr 2020 12:23:24 +0000 (14:23 +0200)] 
doc/devguide: create basic layout

Issue: #3343