Commit graph

147 commits

Author SHA1 Message Date
Philippe Antoine
cf88ed518c jsonschema: check for duplicate keys
Some checks failed
builds / Fedora (non-root, debug, clang, asan, wshadow, rust-strict, no-ja) (push) Has been cancelled
builds / AlmaLinux 9 (no jansson) (push) Has been cancelled
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 24.04 (cocci) (push) Has been cancelled
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Has been cancelled
builds / Ubuntu 24.04 (unittests coverage) (push) Has been cancelled
builds / Ubuntu 22.04 (unix socket mode coverage) (push) Has been cancelled
builds / Ubuntu 22.04 (afpacket and dpdk coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Has been cancelled
builds / Ubuntu 22.04 (fuzz corpus coverage) (push) Has been cancelled
builds / Ubuntu 20.04 (-DNDEBUG) (push) Has been cancelled
builds / Ubuntu 20.04 (unsupported rust) (push) Has been cancelled
builds / Ubuntu 22.04 (Debug Validation) (push) Has been cancelled
builds / Ubuntu 22.04 (Fuzz) (push) Has been cancelled
builds / Ubuntu 22.04 (Netmap build) (push) Has been cancelled
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 22.04 (DPDK Build) (push) Has been cancelled
builds / Debian 12 (xdp) (push) Has been cancelled
builds / Debian 13 (xdp) (push) Has been cancelled
builds / Ubuntu 22.04 Dist Builder (push) Has been cancelled
builds / Debian 12 MSRV (push) Has been cancelled
builds / Debian 11 (push) Has been cancelled
builds / MacOS Latest (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (NPcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 UCRT64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Has been cancelled
builds / PF_RING (push) Has been cancelled
docs / Ubuntu 22.04 Dist Builder (push) Has been cancelled
Ticket: 6691

And fix the one duplicate found
2025-12-10 06:38:12 +00:00
Philippe Antoine
273e9f55eb scripts: eve-parity hard fail on unknown keyword 2025-11-26 01:13:05 +00:00
Philippe Antoine
f581b8f1ae scripts: complete eve-parity type check 2025-11-26 01:13:05 +00:00
Jason Ish
6bd360570a dnp3: fix dnp3 generation script to match code
Some checks failed
builds / Fedora 42 (gcc, debug, flto, asan, wshadow, rust-strict) (push) Has been cancelled
builds / Fedora (non-root, debug, clang, asan, wshadow, rust-strict, no-ja) (push) Has been cancelled
builds / AlmaLinux 9 (no jansson) (push) Has been cancelled
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 24.04 (cocci) (push) Has been cancelled
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Has been cancelled
builds / Ubuntu 24.04 (unittests coverage) (push) Has been cancelled
builds / Ubuntu 22.04 (unix socket mode coverage) (push) Has been cancelled
builds / Ubuntu 22.04 (afpacket and dpdk coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Has been cancelled
builds / Ubuntu 22.04 (fuzz corpus coverage) (push) Has been cancelled
builds / Ubuntu 20.04 (-DNDEBUG) (push) Has been cancelled
builds / Ubuntu 20.04 (unsupported rust) (push) Has been cancelled
builds / Ubuntu 22.04 (Debug Validation) (push) Has been cancelled
builds / Ubuntu 22.04 (Fuzz) (push) Has been cancelled
builds / Ubuntu 22.04 (Netmap build) (push) Has been cancelled
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 22.04 (DPDK Build) (push) Has been cancelled
builds / Debian 12 (xdp) (push) Has been cancelled
builds / Debian 13 (xdp) (push) Has been cancelled
builds / Ubuntu 22.04 Dist Builder (push) Has been cancelled
builds / Debian 12 MSRV (push) Has been cancelled
builds / Debian 11 (push) Has been cancelled
builds / MacOS Latest (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (NPcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 UCRT64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Has been cancelled
builds / PF_RING (push) Has been cancelled
2025-11-07 19:28:17 +00:00
Jason Ish
2848061d0d scripts/evedoc.py: handle union types in schema
Update EVE documentation script to handle union types like:

    "type": ["string", "number"]
2025-10-06 19:56:12 +02:00
Philippe Antoine
f7f8fbc116 scripts: setup app layer rustfmt mod.rs last
Otherwise rustfmt complains that parser.rs does not exist yet
2025-09-29 19:08:20 +02:00
Philippe Antoine
24503b0ead rust: move file functions out of SuricataContext
Ticket: 7667
2025-09-22 10:02:19 +02:00
Victor Julien
b58c8461c3 clang-format: adjust for master to main rename 2025-09-16 15:09:50 +02:00
Jason Ish
8d67c91c0d clang-format: don't reformat schema on rewrite-branch
Add --extensions c,h flag to git clang-format when reformatting
commits on a branch. This prevents clang-format from modifying
non-C files like JSON schemas.

The extensions is used elsewhere in this script, so I suspect it was
just an oversight.

Also, ./scripts/schema-order.py --in-place will consistently format the
schema, while sorting the keys.
2025-05-27 21:43:51 +02:00
Philippe Antoine
cca169f307 scripts: clang-format can use a different base than master
useful for git hook running on main-7.0.x branches so that
not every commit gets its format checked again.

Ticket: 7292
2025-05-21 19:42:08 +02:00
Jason Ish
371d7cba06 schema: add script to check or sort the schema 2025-05-18 21:17:22 +02:00
Jason Ish
e8d7d3d83d scripts/setup-app-layer: fixes for name changes 2025-05-05 21:41:03 +02:00
Jason Ish
7321d7c7db rust/applayertemplate: replace rs_ naming with SC 2025-05-05 21:41:03 +02:00
Philippe Antoine
7d806dc7b7 ci: rustc wrapper to disable coverage for external crates
To keep the disk usage good even when we use new crates
2025-04-19 18:20:01 +02:00
Philippe Antoine
c32f2dee70 scripts: remove unused code in setup-app-layer
and fix typo
2025-04-07 06:57:45 +02:00
Todd Mortimer
9c324b796e http: Use libhtp-rs.
Ticket: #2696

There are a lot of changes here, which are described below.

In general these changes are renaming constants to conform to the
libhtp-rs versions (which are generated by cbindgen); making all htp
types opaque and changing struct->member references to
htp_struct_member() function calls; and a handful of changes to offload
functionality onto libhtp-rs from suricata, such as URI normalization
and transaction cleanup.

Functions introduced to handle opaque htp_tx_t:
- tx->parsed_uri => htp_tx_parsed_uri(tx)
- tx->parsed_uri->path => htp_uri_path(htp_tx_parsed_uri(tx)
- tx->parsed_uri->hostname => htp_uri_hostname(htp_tx_parsed_uri(tx))
- htp_tx_get_user_data() => htp_tx_user_data(tx)
- htp_tx_is_http_2_upgrade(tx) convenience function introduced to detect response status 101
  and “Upgrade: h2c" header.

Functions introduced to handle opaque htp_tx_data_t:
- d->len => htp_tx_data_len()
- d->data => htp_tx_data_data()
- htp_tx_data_tx(data) function to get the htp_tx_t from the htp_tx_data_t
- htp_tx_data_is_empty(data) convenience function introduced to test if the data is empty.

Other changes:

Build libhtp-rs as a crate inside rust. Update autoconf to no longer
use libhtp as an external dependency. Remove HAVE_HTP feature defines
since they are no longer needed.

Make function arguments and return values const where possible

htp_tx_destroy(tx) will now free an incomplete transaction

htp_time_t replaced with standard struct timeval

Callbacks from libhtp now provide the htp_connp_t and the htp_tx_data_t
as separate arguments. This means the connection parser is no longer
fetched from the transaction inside callbacks.

SCHTPGenerateNormalizedUri() functionality moved inside libhtp-rs, which
now provides normalized URI values.
The normalized URI is available with accessor function: htp_tx_normalized_uri()
Configuration settings added to control the behaviour of the URI normalization:
- htp_config_set_normalized_uri_include_all()
- htp_config_set_plusspace_decode()
- htp_config_set_convert_lowercase()
- htp_config_set_double_decode_normalized_query()
- htp_config_set_double_decode_normalized_path()
- htp_config_set_backslash_convert_slashes()
- htp_config_set_bestfit_replacement_byte()
- htp_config_set_convert_lowercase()
- htp_config_set_nul_encoded_terminates()
- htp_config_set_nul_raw_terminates()
- htp_config_set_path_separators_compress()
- htp_config_set_path_separators_decode()
- htp_config_set_u_encoding_decode()
- htp_config_set_url_encoding_invalid_handling()
- htp_config_set_utf8_convert_bestfit()
- htp_config_set_normalized_uri_include_all()
- htp_config_set_plusspace_decode()
Constants related to configuring uri normalization:
- HTP_URL_DECODE_PRESERVE_PERCENT => HTP_URL_ENCODING_HANDLING_PRESERVE_PERCENT
- HTP_URL_DECODE_REMOVE_PERCENT => HTP_URL_ENCODING_HANDLING_REMOVE_PERCENT
- HTP_URL_DECODE_PROCESS_INVALID => HTP_URL_ENCODING_HANDLING_PROCESS_INVALID

htp_config_set_field_limits(soft_limit, hard_limit) changed to
htp_config_set_field_limit(limit) because libhtp didn't implement soft
limits.

libhtp logging API updated to provide HTP_LOG_CODE constants along with
the message. This eliminates the need to perform string matching on
message text to map log messages to HTTP_DECODER_EVENT values, and the
HTP_LOG_CODE values can be used directly. In support of this,
HTP_DECODER_EVENT values are mapped to their corresponding HTP_LOG_CODE
values.

New log events to describe additional anomalies:
HTP_LOG_CODE_REQUEST_TOO_MANY_LZMA_LAYERS
HTP_LOG_CODE_RESPONSE_TOO_MANY_LZMA_LAYERS
HTP_LOG_CODE_PROTOCOL_CONTAINS_EXTRA_DATA
HTP_LOG_CODE_CONTENT_LENGTH_EXTRA_DATA_START
HTP_LOG_CODE_CONTENT_LENGTH_EXTRA_DATA_END
HTP_LOG_CODE_SWITCHING_PROTO_WITH_CONTENT_LENGTH
HTP_LOG_CODE_DEFORMED_EOL
HTP_LOG_CODE_PARSER_STATE_ERROR
HTP_LOG_CODE_MISSING_OUTBOUND_TRANSACTION_DATA
HTP_LOG_CODE_MISSING_INBOUND_TRANSACTION_DATA
HTP_LOG_CODE_ZERO_LENGTH_DATA_CHUNKS
HTP_LOG_CODE_REQUEST_LINE_UNKNOWN_METHOD
HTP_LOG_CODE_REQUEST_LINE_UNKNOWN_METHOD_NO_PROTOCOL
HTP_LOG_CODE_REQUEST_LINE_UNKNOWN_METHOD_INVALID_PROTOCOL
HTP_LOG_CODE_REQUEST_LINE_NO_PROTOCOL
HTP_LOG_CODE_RESPONSE_LINE_INVALID_PROTOCOL
HTP_LOG_CODE_RESPONSE_LINE_INVALID_RESPONSE_STATUS
HTP_LOG_CODE_RESPONSE_BODY_INTERNAL_ERROR
HTP_LOG_CODE_REQUEST_BODY_DATA_CALLBACK_ERROR
HTP_LOG_CODE_RESPONSE_INVALID_EMPTY_NAME
HTP_LOG_CODE_REQUEST_INVALID_EMPTY_NAME
HTP_LOG_CODE_RESPONSE_INVALID_LWS_AFTER_NAME
HTP_LOG_CODE_RESPONSE_HEADER_NAME_NOT_TOKEN
HTP_LOG_CODE_REQUEST_INVALID_LWS_AFTER_NAME
HTP_LOG_CODE_LZMA_DECOMPRESSION_DISABLED
HTP_LOG_CODE_CONNECTION_ALREADY_OPEN
HTP_LOG_CODE_COMPRESSION_BOMB_DOUBLE_LZMA
HTP_LOG_CODE_INVALID_CONTENT_ENCODING
HTP_LOG_CODE_INVALID_GAP
HTP_LOG_CODE_ERROR

The new htp_log API supports consuming log messages more easily than
walking a list and tracking the current offset. Internally, libhtp-rs
now provides log messages as a queue of htp_log_t, which means the
application can simply call htp_conn_next_log() to fetch the next log
message until the queue is empty. Once the application is done with a
log message, they can call htp_log_free() to dispose of it.

Functions supporting htp_log_t:
htp_conn_next_log(conn) - Get the next log message
htp_log_message(log) - To get the text of the message
htp_log_code(log) - To get the HTP_LOG_CODE value
htp_log_free(log) - To free the htp_log_t
2025-04-04 02:35:12 +02:00
Jason Ish
155706f96b jsonbuilder: prefix C API with SC 2025-04-03 10:05:49 +02:00
Philippe Antoine
2fa3a9fe62 template: rustfmt
and use generic logger callback prototype with later cast

and do some other small modifications so that the plugin
has less diff
2025-03-29 06:38:00 +01:00
Jason Ish
640e4b343d script/dnp3_gen.py: use current clang style 2025-03-27 08:31:44 -06:00
Jason Ish
bb7089df93 script/dnp3-gen.py: update for newer versions of Python
More recent yaml loaders require the loader as an argument.
2025-03-27 08:31:44 -06:00
Jason Ish
facd525692 eve-parity: merge $ref props into current object
Allows for a "suricata" entry along with a "$ref".
2025-03-09 07:29:34 +01:00
Jason Ish
744f301df4 eve-parity: handle arrays of scalars
And add an example with "client_alpns".
2025-03-09 07:29:34 +01:00
Jason Ish
6477b31199 eve-parity: skip transform keywords 2025-03-05 15:59:58 +01:00
Jason Ish
861896ed39 script/eve-parity: add script for checking eve/keyword parity
Currently this script has two commands: "missing" and "having".

"missing" will show eve fields that do not map to any keywords.

"having" will sohw eve fields along with their keyword mappsings,
while also validating that those keywords really exist.

Related to tickets: #6463, #4772
2025-03-05 15:59:58 +01:00
Alice Akaki
7b350e9933 misc: fix name prefix in detect register functions 2025-02-21 14:57:14 +01:00
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.
2025-01-13 13:35:13 +01:00
Philippe Antoine
96c8470cdd template: move detect keywords to pure rust
Ticket: 3195

Also remove unused src/tests/detect-template-buffer.c

Completes commit 4a7567b3f0
to remove references to template-rust
2024-10-12 11:03:38 +02:00
Jason Ish
2626895a93 evedoc.py: script to generate rst doc from eve schema
Also supports a "--flat" command line option to produce a "dot"
separated version of all the fields in the EVE schema.
2024-10-07 22:28:04 +02:00
Lukas Sismis
cd7c35eb5a github-ci: add minimal build for Ubuntu and AlmaLinux 2024-06-15 15:43:30 +02:00
Jason Ish
10a367b116 lua: use quoted include style to avoid system includes
Use quoted include style for Lua includes ("lua.h" instead of <lua.h>)
as this could result in system includes being picked up instead of the
includes from our vendor directory.
2024-05-31 13:11:10 +02:00
Jason Ish
2e440169d6 lua: remove lua as a compile time feature
Its always built-in. However, can be disabled at runtime.
2024-05-27 16:44:54 -06:00
Jason Ish
cec1c9d853 bundle.sh: accept more forms of a branch name
For GitHub, add the following branch name formats:
- https://github.com/OISF/libhtp/pull/123
- OISF/libhtp#123
2024-05-07 16:28:07 -06:00
Philippe Antoine
3643b6ed4b output: generic simple tx json logger
Ticket: 3827
2024-04-13 08:50:18 +02:00
Jason Ish
5ebae1e8ed clang-format.sh: prefer clang-format-14
Add clang-format-14 as the preferred version, this is the default on
Ubuntu 22.04.
2023-12-13 06:59:31 +01:00
Philippe Antoine
0b6b015e26 output/alert: rewrite code for app-layer properties
Especially fix setup-app-layer script to not forget this part

This allows, for simple loggers, to have a unique definition
of the actual logging function with the jsonbuilder.
This way, alerts, files, and app-layer event can share the code
to output the same data.

Ticket: #3827
2023-11-20 21:53:13 +01:00
Victor Julien
8e5e9a289b scripts: fix bundle script spelling
Thanks to Josh Soref.
2023-05-08 11:59:33 +02:00
Victor Julien
fe867a302c scripts: spelling 2023-05-06 14:50:43 +02:00
Juliana Fajardini
dc71faaa8a scripts/clang: remove mention to rewrite-branch
Although we prefer that formatting changes (e.g. the ones made by
running clang) go in a different commit, our script error message was
still suggesting `rewrite-branch` as an option. Removed that and added
that the changes made by the script should go into a separate commit.
2023-05-05 11:03:13 +02:00
Philippe Antoine
6b9fce7728 app-layer: shorter code for proto string helpers 2023-05-05 10:34:33 +02:00
Philippe Antoine
e1046239ea scripts: fix setup app layer for output
using rust nowadays.

Also remove useless code about files that do not need changes
anymore
2023-05-05 10:34:33 +02:00
Philippe Antoine
5b2605bdfe debug: use AppProtoToString
instead of recoding it.
This way, setup-app-layer.py needs to patch one file less
2023-05-05 10:34:33 +02:00
Jason Ish
76c71a9120 bundle.sh: allow a PR # to be specified
Allow pull requests (and merge requests) to be specified by using a
branch name like "pr/111" or "mr/222". This allows CI to use this
script as well, instead of multiple variations of the same thing.

Additonally allow the destination directory to be overridden with the
DESTDIR environment variable.
2023-04-24 16:59:52 +02:00
Shivani Bhardwaj
21edf136a5 scripts: fix app-layer-protos.c setup
After the changes in the script in 05e16820de, the file
app-layer-protos.c was to be modified properly iff it was left unformatted.
However, the file was also formatted as a part of the same commit making
the lines split which broke the output of the script. Fix that by
looking for another pattern and changing the lines following that.
2022-12-20 16:17:11 +01:00
Jason Ish
0bb4546af4 setup-app-layer: rustfmt new rust files 2022-12-06 14:09:10 +01:00
Jason Ish
0b2d0324e5 setup-app-layer: set copyright year to current year
Ticket: 4939
2022-12-06 14:09:10 +01:00
Jason Ish
05e16820de templates: clang format cleanups
Cleanup the trivial clang-formatting issues in templates.  Length of
protocol names may require clang-format after new protocol generation.
2022-12-06 14:09:10 +01:00
Jason Ish
712d80107f setup-app-layer: remove generator for C parsers
Ticket: 4939
2022-12-06 14:09:10 +01:00
Jason Ish
50a787a9a3 app-layer-template-rust: remove C app-layer stub
Remove the app-layer-PROTO stub for Rust based parsers.  It is no longer
needed as Rust parsers now contain the registration function in Rust.

Ticket: 4939
2022-12-06 14:09:10 +01:00
Philippe Antoine
62352ad030 src: fix remaining cppclean warnings 2022-11-18 08:27:01 +01:00
Jason Ish
a5d66a7452 bundle.sh: comment line fixup
Accept lines that start with a hash, but not immediately followed by a
space as a comment as well.
2022-08-06 08:17:57 +02:00