Commit Graph

16826 Commits (master)
 

Author SHA1 Message Date
Jason Ish 4cca135793 pgsql: cleanup visibility and naming
Remove pub and no_mangle from non-exported functions and rename to
Rust style as needed.

Ticket: 7498
1 month ago
Jason Ish a7f7dc5296 rust/dhcp: rustfmt 1 month ago
Jason Ish c5089ac5f4 dhcp: cleanup visibility and naming
- remove "rs_" prefix from functions that are not exported
- prefix exported functions with "SC"
- don't export functions that are only used by pointer

Ticket: 7498
1 month ago
Jason Ish c86b2608aa rust/applayer: clean visibility of export macros
Both the macros export_tx_data_get and export_state_data_get can
generate non-pub functions as the function they generate is only used
as a pointer during registration.

Remove "pub" and "no_mangle" from the generated functions and update
the names of the generated functions to follow Rust rules as they are
no longer exported into the global C namespace.

Ticket: 7498
1 month ago
Jason Ish c93bba8e2c rust/transforms: remove no_mangle from non-pub functions
Ticket: 7498
1 month ago
Jason Ish f370afb5bd rust/ldap: cleanup no_mangle and extern C pub functions
If a function is extern "C" and not pub, remove no_mangle so its not
exposed as-is into the global name space.

Ticket: 7498
1 month ago
Eric Leblond 8ae7054f1f decode/tcp: fix some macros
Ticket: #7509
1 month ago
Philippe Antoine 78715a5f3f smtp: recognize if client initiated TLS
Ticket: 7469
1 month ago
Philippe Antoine b5094b00b6 protodetect: finish probing parser sooner
Ticket: 7495

We want to finish also if we tested all the expected protocols
in mask, or if we tested even more.

There can be one more protocol coming from pe0, which can be
the protocol already found in the other direction.
1 month ago
Jeff Lucovsky 95e8427bae gen: Remove _AL_ usage in detect keywords
This commit removes the `_AL_` usage in detect keywords for improved
readability.

Some of the HTTP rule keywords already had counterparts without using
"_AL_". These rule keywords are the legacy content modifier keywords
that now have sticky buffer equivalents.

For these, "_AL_" was removed and a suffix was added to the #define:
src/detect-engine-register.h:151:    DETECT_HTTP_COOKIE_CM
src/detect-engine-register.h:153:    DETECT_HTTP_METHOD_CM
src/detect-engine-register.h:161:    DETECT_HTTP_HEADER_CM
src/detect-engine-register.h:173:    DETECT_HTTP_RAW_HEADER_CM
src/detect-engine-register.h:175:    DETECT_HTTP_URI_CM
src/detect-engine-register.h:179:    DETECT_HTTP_STAT_MSG_CM
src/detect-engine-register.h:181:    DETECT_HTTP_STAT_CODE_CM
src/detect-engine-register.h:185:    DETECT_HTTP_HOST_CM
1 month ago
Jason Ish c207cfc67e rust/detect: remove nested unsafe around keyword registration
Just a cleanup, I'm not sure why Rust wasn't warning on these
nested/unneeded unsafe's.
1 month ago
Jason Ish 2bcc66da58 rust/log: move rust log and debug utils to debug module
Move Rust logging, and debug_validation to a debug module to mirrow
the C side.
1 month ago
Jason Ish f62be374ea rust/direction: move direction to own file (cleanup)
Move the implementation of Direction to its own file, direction.rs.
1 month ago
Jason Ish 7ef4caf90e rust/flow: move flow support to its own file (cleanup)
Move the Rust Flow support from core.rs to flow.rs.
1 month ago
Philippe Antoine 23050d70ed http: aliases for htp opaque htp_tx_t
In preparation of libhtp rust
1 month ago
Philippe Antoine 8f6795d049 rust: remove unneeded mut for tx in detect
Detection does not change transactions, it reads only.
1 month ago
Philippe Antoine af4e1e8888 rust: remove unneeded mut for tx in loggers
Loggers do not change transactions, they read only.
1 month ago
Philippe Antoine 5ee6e7cef0 http: aliases for htp progresses
In preparation of libhtp rust
1 month ago
Philippe Antoine 8c612246c1 http: aliases for htp protocol versions
In preparation of libhtp rust
1 month ago
Philippe Antoine ef133942e8 http: aliases for htp stream states
In preparation of libhtp rust
1 month ago
Philippe Antoine a4479c03f6 http: aliases for htp methods
In preparation of libhtp rust
1 month ago
Philippe Antoine 604b625616 http: aliases for htp auths
In preparation of libhtp rust
1 month ago
Philippe Antoine fcfc10c95f http: aliases for htp flags
In preparation of libhtp rust
1 month ago
Philippe Antoine b482ae3f04 http: aliases for htp server personalities
In preparation of libhtp rust
1 month ago
Philippe Antoine 99ab3f7dc7 http: aliases for htp statuses
In preparation of libhtp rust
1 month ago
Philippe Antoine edfe0ccbe1 ldap: implement abandon request
Ticket: #7477
1 month ago
Philippe Antoine 770a75911f ldap: update ldap-parser crate
so that we can implement abandon request support

Ticket: #7477
2 months ago
Alice Akaki 078c6469a0 detect: add vlan.layers keyword
vlan.layers matches on the number of VLAN layers per packet
It is an unsigned 8-bit integer
Valid range = [0-3]
Supports prefiltering

Ticket: #1065
2 months ago
Alice Akaki b1c2643c87 detect: add vlan.id keyword
vlan.id matches on Virtual Local Area Network IDs
It is an unsigned 16-bit integer
Valid range = [0-4095]
Supports prefiltering

Ticket: #1065
2 months ago
Philippe Antoine 637708acb4 fuzz: remove unused macro 2 months ago
Philippe Antoine a92212d6e5 fuzz: better init for signature parsing harness
It needs app-layer registration for the names
2 months ago
Philippe Antoine eab212b0be plugins: app-layer plugins
Ticket: 5053
2 months ago
Philippe Antoine ae1a4ef757 app-layer: make number of alprotos dynamic
Ticket: 5053

The names are now dynamically registered at runtime.
The AppProto alproto enum identifiers are still static for now.

This is the final step before app-layer plugins.
2 months ago
Philippe Antoine e6be049c5d app-layer: move ALPROTO_FAILED definition
Because some alprotos will remain static and defined as a constant,
such as ALPROTO_UNKNOWN=0, or ALPROTO_FAILED.

The regular already used protocols keep for now their static
identifier such as ALPROTO_SNMP, but this could be made more
dynamic in a later commit.

ALPROTO_FAILED was used in comparison and these needed to change to use
either ALPROTO_MAX or use standard function AppProtoIsValid
2 months ago
Jason Ish 05853fb8d5 lua/datasets: factor out into its own file
This is mainly for header sanitization to avoid pulling in detect
modules into the Lua sandbox definition.

Plus if we namespace modules with names like "suricata.dataset", it
probably makes sense to keep those modules in their own files.
2 months ago
Jason Ish e397f21019 lua/datasets: rework to be a "required" module
Re-work the Lua dataset lib to be required into a user script like:

    local dataset = require("suricata.data")

The main difference from loading it into global space is providing a
custom require function (as we removed it in the sandbox) and load it on
demand, returning a table to the module.
2 months ago
Victor Julien ccebae6ec0 detect/lua: add support for datasets
dataset.new
  create a dataset object in lua

<dataset>:get
  gets a reference to an existing dataset

<dataset>:add
  returns 1 if a new entry was added
  returns 0 if entry was already in the set

Example:
```
function init (args)
    local needs = {}
    needs["packet"] = tostring(true)
    return needs
end

function thread_init (args)
    conn_new, dataset.new()
    ret, err conn_new:get("conn-seen")
    if err ~= nil then
        SCLogWarning("dataset warning: " .. err)
        return 0
    end
end

function match (args)
    ipver, srcip, dstip, proto, sp, dp = SCFlowTuple()
    str = ipver .. ":<" .. srcip .. ">:<" .. dstip .. ">:" .. dp

    ret, err = conn_new:add(str, #str);
    if ret == 1 then
        SCLogInfo(str .. " => " .. ret)
    end
    return ret
end
```

Ticket: #7243.
2 months ago
Victor Julien e89ab4f88a detect/lua: add thread_init
Add optional `thread_init` function support. This function is called per
script, per thread to allow a user to initialize the lua state.
2 months ago
Victor Julien c3e61e07f0 detect/lua: improve stack dumping
Only useful when debugging. Add a prefix and a stack size indication.
2 months ago
Jeff Lucovsky 1d996c5aed log/file: Ensure file ctx pointer is returned .
The fix for issue 7447 introduced an error with threaded eve output.

The changes that were committed for that issue mishandled the return
value when a file is being opened for the 2nd or higher time.

Instead of returning the existing file context, null was returned.
2 months ago
Shivani Bhardwaj ad7ff1c91b flow/pkts: allow matching on either direction
For flow.bytes and flow.pkts keywords, allow matching in either
direction.

Feature 5646
2 months ago
Shivani Bhardwaj 52fd695e5a doc: update syntax for flow.pkts & flow.bytes 2 months ago
Shivani Bhardwaj aad313438c flow/pkts: make syntax cleaner and compact
Currently, the syntax includes direction as a part of the keyword which
is against how usually keywords are done. By making direction as a
mandatory argument, it is possible to make the syntax cleaner and the
implementation more compact and easily extendable.
Pros:
- Registration table sees lesser entries if newer options are added
- If the options have to be extended, it can be done trivially
- In accordance w existing keyword implementations

Note that this commit also retains the existing direction specific
keywords.
2 months ago
Victor Julien bd1b9f6229 stream: RST no longer acks all data
Since forever (1578ef1e3e) a valid RST
would update the internal `last_ack` representation to include all
unack'd data. This was originally done to make sure the unACK'd data was
inspected/processed at flow timeout.

It was observed however, that if GAPs existed in this unACK'd data, a
GAP could be reported in the stats and a GAP event would be raised. This
doesn't make sense, as missing segments in the unACK'd part of the
stream are completely normal. Segments simply do not all arrive in
order.

It turns out that the original behavior of updating `last_ack` to
include all unACK'd data is no longer needed.

For raw stream inspection, the detection engine will already include the
unACK'd data on flow end.

For app-layer updates the unACK'd data is often harmful, as the data
often has GAPs. Parser like the http parser would report these GAPs and
could also get confused about the post-GAP data being a new transaction
including a file. This lead to many reported errors and fantom txs and
files.

Since the GAP detection uses `last_ack` to determine GAPs, not moving
`last_ack` addresses the GAP false positives.

Ticket: #7422.
2 months ago
Victor Julien 829ba7d114 flow/manager: improve doc; minor cleanup
Explain meaning of `ts` in flow managers main loop.
2 months ago
Victor Julien 14864cda59 flow: skip lock for skippable flows
Some checks can be done w/o holding a lock:
- seeing if the flow matches the packet
- if the hash row needs a timeout check

This patch skips taking a lock in these conditions.
2 months ago
Victor Julien 2af67e17bc threads: align struct to CLS to avoid false sharing
Since `Thread` objects are part of a big allocation, more than one
Thread could be on a single cache line, leading to false sharing. Atomic
updates to one `Thread` could then lead to poor performance accessing
another `Thread`. Align to CLS (cache line size) to avoid this.
2 months ago
Victor Julien b75d1ab37f threads: seal after setup; unseal at shutdown
The idea of sealing the thread store is that its members can be accessed
w/o holding a lock to the whole store at runtime.
2 months ago
Victor Julien 276d625a66 threads: fine grained locking for Thread
Until now many accesses to the Thread structure required taking a global
lock, leading to performance issues. In practice this only happened in
offline mode.

This patch adds a finer grained locking scheme. It assumes that the
Thread object itself cannot disappear, and adds a spinlock to protect
updates to the structure.

Additionally, the `pktts` field is made an atomic, so that it can be
read w/o taking the spinlock. Updates to it are still done under lock.
2 months ago
Victor Julien ef396f7509 flow/manager: in offline mode, use owning threads time
As this may mean that a threads ts is a bit ahead of the minimum time
the flow manager normally uses, it can evict flows a bit faster.

Ticket: #7455.
2 months ago