Commit Graph

1929 Commits (master)

Author SHA1 Message Date
Philippe Antoine c2756dec75 htp: move transactions list from BTree to VecDeque
As it is more efficient in our case of pipelining requests
2 months ago
Philippe Antoine 756f28d086 http: simplify tx removal interface 2 months ago
Philippe Antoine ba186f5d25 htp: remove unused code 2 months ago
Jeff Lucovsky 07205ab057 detect/xform: Support transform identity data
Transforms that support optional strings, like from_base64 and
pcrexform, should also support identity-strings to treat transforms with
like transform options as the same.

This commit adds transform identity data handling:
- When computing a hash, include identity data from the transform
- When comparing, include the identity data from the transforms
- Omitting the "options" ptr from the transform hash/compare
- Modify xor, pcrexform and from_base64 to supply identification data for
  disambiguation in the compare/hash logic.
2 months ago
Jeff Lucovsky c6e0ba2b85 detect/ftp: Add parser for ftp.mode keyword
Issue: 7505

Add a parser for the ftp.mode command that returns the state struct. Add
a function to free the object it allocates.
2 months ago
Philippe Antoine 4af3bd9c91 rust: bindgen SCDetectHelperKeywordSetCleanCString
Ticket: 7667
2 months ago
Philippe Antoine 13449344e8 rust: bindgen SCDetectHelperKeywordRegister
Ticket: 7667
2 months ago
Philippe Antoine f909bbba68 rust: bindgen SCDetectHelperKeywordAliasRegister
Ticket: 7667
2 months ago
Philippe Antoine a7448a0c16 rust: bindgen SCDetectHelperBufferRegister
Ticket: 7667
2 months ago
Philippe Antoine 0d82e905bc rust: bindgen DetectHelperMultiBufferMpmRegister
Ticket: 7667
2 months ago
Philippe Antoine dfa4df9f54 rust: bindgen SCDetectHelperMultiBufferProgressMpmRegister
Ticket: 7667
2 months ago
Juliana Fajardini 62949b3815 pgsql: remove unused "password_message" code
``Password message`` is actually logged just as ``Password``.
Remove related dead code.
2 months ago
Juliana Fajardini 6f81caf8d4 pgsql: clearly indicate redacted password message
If a password message was seen while logging passwords was disabled
for pgsql, this would lead to an empty request being logged.
Instead of simply not logging anything when there is a password message
and this is disabled, however, log instead that said password is
redacted.

Bug #7647
2 months ago
Philippe Antoine fd7bd9c200 src: new file detect-engine-inspect-buffer.h
For InspectionBuffer structure and related functions

Bindgen it for rust, especially transforms

Ticket: 7667
2 months ago
Philippe Antoine df0dc2e8ea rust: bindgen SCDetectSignatureAddTransform
by moving it to detect-engine-buffer.h and prefixing it

Ticket: 7667
2 months ago
Philippe Antoine 1f871cdd64 rust: reuse/reexport suricata_sys DetectEngineThreadCtx
Use the bindgen'd version instead of our own recoded one
2 months ago
Philippe Antoine cf336396c3 rust: bindgen detect-engine-helper.h
Ticket: 7667

Begin by focusing on transforms
2 months ago
Jason Ish 97eaeef7d8 lua: convert SMTP functions to lib: suricata.smtp
Ticket: #7606
2 months ago
Philippe Antoine 06ad72e83e quic: ja3 getter function uses direction
so that future lua code can specify a direction
2 months ago
Jason Ish bf427c69cd rust: remaining rs_ to SC conversions 2 months ago
Jason Ish d16c014641 rust/x509: replace rs_ naming with SC 2 months ago
Jason Ish afce53c8b7 rust/websocket: replace rs_ naming with SC 2 months ago
Jason Ish 7321d7c7db rust/applayertemplate: replace rs_ naming with SC 2 months ago
Jason Ish 2c98ee73ce rust/rfb: replace rs_ naming with SC 2 months ago
Jason Ish e74b4177ac rust/nfs: rust format 2 months ago
Jason Ish 8c1bd60ab1 rust/nfs: replace rs_ naming with SC 2 months ago
Jason Ish 01ce0f92e8 rust/modbus: replace rs_ naming to SC
This was missed in the previous round.
2 months ago
Jason Ish 4e2f1de308 rust/quic: replace rs_ naming with SC 2 months ago
Jason Ish bfa0acf278 rust/ike: replace rs_ naming with SC 2 months ago
Jason Ish 717e06e351 rust/http2: replace rs_ naming with SC 2 months ago
Jason Ish af15986d41 rust/modbus: replace rs_ naming with SC 2 months ago
Jason Ish c994cfb615 rust/sip: replace rs_ naming with SC 2 months ago
Jason Ish 9b830c92dc rust/tftp: replace rs_ naming with SC 2 months ago
Jason Ish aa24276999 rust/telnet: replace rs_ naming with SC 2 months ago
Jason Ish 1c580f9001 rust/detect: replace rs_ naming with SC 2 months ago
Jason Ish 713034d0dd rust/asn1: replace rs_ naming with SC naming 2 months ago
Jason Ish 90116827fe rust/krb: rust format 2 months ago
Jason Ish 8ba0a5c8ec rust/krb: remove rs_ prefix; visibility fixes
- remove pub/no_mangle where not needed
- replace rs_ naming with SC naming
2 months ago
Jason Ish 1f30746e07 rust/dns: rs_ prefix name cleanup 2 months ago
Victor Julien 3c5ce91cbb ftp: per direction tx progress
For request side, having a tx means the request is done.

For response, wait for tx to be marked complete.

Remove unused states.
2 months ago
Philippe Antoine 033e0480cf detect/single-buf: helper with more explicit direction 3 months ago
Philippe Antoine dadf9012fc rust: bindgen detect-engine-buffer.h
Ticket: 7667

And prefix SCDetectBufferSetActiveList to be exported

Allows less use of suricata crate in plugin as we get the functions
prototypes from suricata_sys and they are more correct.
3 months ago
Philippe Antoine 31e30d4aa1 sdp: use rust join
It is much faster as it does not do an allocation for each element
3 months ago
Philippe Antoine 6436a5cebe websocket: limit allocation for small sizes
Fixes: 16f74c68aa ("websocket: use max window bits of 15")

We do not need to allocate 8kbytes for a small message
3 months ago
Philippe Antoine 1f2cb21786 ssh: rustfmt 3 months ago
Philippe Antoine fcac063cfe ssh: make hooks available
Allows signature like `alert ssh:request_banner_done`
3 months ago
Philippe Antoine bbc007b4d4 rust: derive for AppLayerState
To enable easily hooks for rust app-layers such as SSH
3 months ago
Jeff Lucovsky 87b7a0cef6 ftp: Apply rustfmt changes 3 months ago
Jeff Lucovsky 04bf28d6a1 app/ftp: Use common API naming
Modify the Rust API functions to conform to project naming format:
SCFTP*

Issue: 7504
3 months ago
Philippe Antoine 808f8a877a detect/multi-buf: helper with more explicit direction 3 months ago
Philippe Antoine 8ecc3efdc8 detect/multi-buf: harmonize wrapper
Introduce DetectGetMultiData which does the generic wrapping,
including the transforms.

And let each keyword do just the getter.
3 months ago
Philippe Antoine a6392ac5d4 rust: use pure rust helper for registering sticky buffers
Mark sdp and sip keywords with flags SIGMATCH_INFO_STICKY_BUFFER
as a side effect.
3 months ago
Philippe Antoine 833a738dd1 http: fail tx creation if we cannot allocate user data
So, we always have a libhtp.rs htp_tx_t and a Suricata tx
with its AppLayerTxData

Thus AppLayerParserGetTxData cannot return NULL

Ticket: 5739
3 months ago
Philippe Antoine 0167001ce8 rust/htp: remove unused code 3 months ago
Philippe Antoine e728aae1e0 websocket: fixes substraction
Fixes: 16f74c68aa ("websocket: use max window bits of 15")
3 months ago
Philippe Antoine aa7f926ff4 detect: rust helper to register sticky buffer 3 months ago
Philippe Antoine 96afdce283 detect: rename SCSigTableElmt to SCSigTableAppLiteElmt 3 months ago
Philippe Antoine 8757ad5fd3 detect/dns: support string for dns.rrtype
Ticket: 6723
3 months ago
Philippe Antoine 44a6f7f8ca detect/dns: support string for dns.rcode
Ticket: 6723
3 months ago
Philippe Antoine 9814b698c8 detect/dns: move keywords to rust
Ticket: 7529
Ticket: 3725

Adds url for dns.opcode on the way
3 months ago
Philippe Antoine bb9b8d2460 detect: new helper to register multi-buffer with progress
This allows to use these engines for hook rules needing exact
progress (checked in SigValidate)
3 months ago
Philippe Antoine a1ff7424e4 http1: brotli decompression
Ticket: 5692

http2 already used brotli crate for decompression
3 months ago
Philippe Antoine 16f74c68aa websocket: use max window bits of 15
Ticket: 7285

As this is the default for websocket, which is bigger than the
defaut for zlib usage

Also limit the decompressed content to the max-payload-size
configuration parameter also used for non-compressed content.

And also use a stateful decoder to store/remember the compression
state to be able to decompress later messages.
3 months ago
Philippe Antoine 44c8632284 rust: use flate2 with C zlib
move flate2.rs to a backend supporting the setting
of window_bits, which is not the case for miniz-oxide.

This will allow WebSocket to use Sec-WebSocket-Extensions
which can set a non-default window_bits
3 months ago
Philippe Antoine ff57a162d7 websocket: decompress single pdu message
Ticket: 7285

Previously, only messages over multiple PDUs could get decompressed
3 months ago
Alice Akaki bda0890834 detect: add email.received keyword
email.received matches on MIME EMAIL Received
This keyword maps to the EVE field email.received[]
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7599
3 months ago
Alice Akaki ca429ef5e3 detect: add email.url keyword
email.url matches on URLs extracted from an email
This keyword maps to the EVE field email.url[]
Supports multiple buffer matching
Supports prefiltering

Ticket: #7597
3 months ago
Jason Ish bea685bfcd rust/htp: remove authors; fix homepage
Remove the authors field as it is deprecated.

Update the repository page to the Suricata repository.

Remove the homepage, it can be found via the reposistory page.
3 months ago
Jason Ish e3a400a581 htp: rename to suricata-htp; allow publishing to crates.io
As the "suricata" crate depends on htp, we need to publish htp to
crates.io first, however "htp" name is already taken. So rename "htp" to
"suricata-htp".
3 months ago
Jason Ish b98b44a576 suricatactl: add description to Cargo.toml
For publishing to crates.io.
3 months ago
Jason Ish 0e65cccc09 rust: always update Cargo.lock.in
On a normal project where the Cargo.lock is checked in, it would be
normal to see an updated Cargo.lock in git status and the like. As we
use autoconf to generate this file, we should just copy it back to the
input file so we get the same convenience of seeing when it is
updated, which usually means it needs to be checked in.

However, to satisfy "make distcheck", only copy it if the input
template exists, if the input template does not exist we are in an out
of tree build.
3 months ago
Victor Julien 88e96c9d49 detect/domain: move transform fully to rust 3 months ago
Jason Ish 8b2fafcfa2 version: start development towards 8.0.0-rc1 3 months ago
Alice Akaki d4ec5b9765 detect: add ldap.responses.attribute_type
ldap.responses.attribute_type matches on LDAP attribute type/description
This keyword maps the eve field ldap.responses[].search_result_entry.attributes[].type
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7533
3 months ago
Alice Akaki 75fb352bde detect: add ldap.request.attribute_type
ldap.request.attribute_type matches on LDAP attribute type/description
This keyword maps the following eve fields:
ldap.request.search_request.attributes[]
ldap.request.modify_request.changes[].modification.attribute_type
ldap.request.add_request.attributes[].name
ldap.request.compare_request.attribute_value_assertion.description
It is a sticky buffer
Supports multiple buffer matching
Supports prefiltering

Ticket: #7533
3 months ago
Alice Akaki 6d48acdd63 rustfmt: rust/src/ldap/detect.rs 3 months ago
Jeff Lucovsky dfc896e2a7 app/ftp: Move FTP response handling to rust
Move handling of FTP responses to Rust to improve support for FTP
keyword matching. Parsing the response line when encountered
simplifies multi-buffer matching and metadata output.

Issue: 4082
3 months ago
Alex Savage 778053876b pop3: app-layer parser using sawp-pop3
This module uses the sawp-pop3 crate to parse POP3 requests and responses
Features:
- eve logging
- events for parsable but non-RFC-compliant messages

Ticket: 3243
3 months ago
Eric Leblond 585c624482 tld: add new transform
Extract the TLD from a buffer.

Ticket: #5639
3 months ago
Eric Leblond 0b031a33c6 domain: add new transformation
Ticket: #5639
3 months ago
Philippe Antoine 51859050cb rust: export jsonbuilder API in sys crate
using cbindgen + bindgen
3 months ago
Victor Julien 31d048ed4b firewall: start of firewall rules support
Config:

Firewall rules are like normal rule, with some key differences.

They are loaded separate, and first, from:

```yaml
firewall-rule-path: /etc/suricata/firewall/
firewall-rule-files:
  - fw.rules
```

Can also be loaded with --firewall-rules-exclusive: Mostly for QA purposes.

Allow -S with --firewall-rules-exclusive, so that firewall and threat detection
rules can be tested together.

Rules:

Differences with regular "threat detection" rules:

1. these rules are evaluated before threat detection rules

2. these rules are evaluated in the order as they appear in the rule file

3. currently only rules specifying an explicit hook at supported

   a. as a consequence, no rules will be treated as (like) IP-only, PD-only or
      DE-only

Require explicit action scope for firewall rules. Default policy is
drop for the firewall tables.

Actions:

New action "accept" is added to allow traffic in the filter tables.

New scope "accept:tx" is added to allow accepting a transaction.

Tables:

Rulesets are per table.

Table processing order: `packet:filter` -> `packet:td` -> `app:*:*` -> `app:td`.

Each of the tables has some unique properties:

`packet:filter`:
- default policy is `drop:packet`
- rules are process in order
- action scopes are explicit
- `drop` or `accept` is immediate
- `accept:hook` continues to `packet:td`

`packet:td`:
- default policy is `accept:hook`
- rules are ordered by IDS/IPS ordering logic
- action scopes are implicit
- actions are queued
- continues to `app:*:*` or `alert/action finalize`

`app:*:*`:
- default policy is `drop:flow`
- rules are process in order
- action scopes are explicit
- `drop` is immediate
- `accept` is conditional on possible `drop` from `packet:td`
- `accept:hook` continues to `app:td`, `accept:packet` or `accept:flow`
  continues to `alert/action finalize`

`app:td`:
- default policy is `accept:hook`
- rules are ordered by IDS/IPS ordering logic
- action scopes are implicit
- actions are queued
- continues to `alert/action finalize`

Implementation:

During sigorder, split into packet:filter, app:*:* and general td.

Allow fw rules to work when in pass:flow mode. When firewall mode is enabled,
`pass:flow` will not skip the detection engine anymore, but instead
process the firewall rules and then apply the pass before inspecting threat
detect rules.
3 months ago
Victor Julien 10dcc383ae detect/xbits: implement tx bits
Implement `xbits:set,mybit,track tx;` and `xbits:isset,mybit,track tx;`.

Store these in the AppLayerTxData.

Ticket: #6455.
3 months ago
Victor Julien add7d3fcf5 app-layer: API for mapping progress name vs id 3 months ago
Philippe Antoine c203ff774d http: restore behavior for event http.uri_delim_non_compliant
If we see a space-like character that is not space 0x20 in uri,
we set this event, even it the request line finished with a normal
space and protocol

Fixes: 9c324b796e ("http: Use libhtp-rs.)
3 months ago
Lukas Sismis 5e8c775d77 ssh: add option to select behavior of encrypted parts
Ticket: 6788
3 months ago
Philippe Antoine 3b271b3f5b detect: rename with prefix SCSigTablePreRegister
to make it available to rust via bindgen
3 months ago
Philippe Antoine e3ee922fbf snmp: restrict rust visibility 3 months ago
Philippe Antoine d24a3eb5f6 snmp: register protocol dynamically
Ticket: 4103
3 months ago
Philippe Antoine 640a4c8b11 snmp: make log function use the generic prototype
and cast

and also remove unneeded mut

and rustfmt
3 months ago
Philippe Antoine 924129b185 output: public header for use in rust
Ticket: 5053

Move enum OutputJsonLogDirection and struct
EveJsonTxLoggerRegistrationData to a public header user by rust
thanks to bindgen

Rename to use SC prefix on the way

And make EveJsonSimpleTxLogFunc use a const pointer to transaction
3 months ago
Philippe Antoine 243d14cda2 output: plugins can log flow or packet direction 3 months ago
Philippe Antoine 850bd72399 app-layer: helper function AppProtoNewProtoFromString
So that we do not have to know g_alproto_max to register
dynamically a new protocol from its name
3 months ago
Philippe Antoine 6afad1af51 smb/log: configuration option for types logging
suricata.yaml output section for smb now parses a types list
and will restrict logging of transactions to these types.

By default, everything still gets logged

Remove unused rs_smb_log_json_request on the way

Ticket: 7620
3 months ago
Philippe Antoine 30af626a92 conf: extend API for rust
Will allow rust to list the values of an array such as
dns.types for outputs
3 months ago
Juliana Fajardini ef8b13c1ef pgsql: use generic name for TerminationMessage msg
Since this structure can be used for different messages with other
meanings.

Related to
Task #4854
3 months ago
Juliana Fajardini e75fcffa29 pgsql: add initial support to copy-out subproto
This sub-protocol inspects messages exchanged between postgresql backend
and frontend after a 'COPY TO STDOUT' has been processed.

Parses new messages:
- CopyOutResponse -- initiates copy-out mode/sub-protocol
- CopyData -- data transfer messages
- CopyDone -- signals that no more CopyData messages will be seen from
  the sender for the current transaction

Task #4854
3 months ago
Jeff Lucovsky 22ea5ddbb7 detect/transforms: Add engine detect thread ctx to signature
Modify the transform function signature to include the detect engine
thread ctx.
3 months ago
Philippe Antoine 0f3932afb7 rust: fix clippy warning manual_contains
warning: using `contains()` instead of `iter().any()` is more efficient
   --> src/http2/http2.rs:267:20
    |
267 |                 if block.value.iter().any(|&x| x == b'@') {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `block.value.contains(&b'@')`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains
    = note: `#[warn(clippy::manual_contains)]` on by default
3 months ago
Philippe Antoine 857efdde62 rust: fix clippy warnings doc_overindented_list_items
warning: doc list item overindented
   --> src/nfs/rpc_records.rs:284:5
    |
284 | ///           type: bool
    |     ^^^^^^^^^^ help: try using `  ` (2 spaces)
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
    = note: `#[warn(clippy::doc_overindented_list_items)]` on by default
3 months ago
Philippe Antoine e4f71621b7 rust: fix clippy missing_abi warning
warning: extern declarations without an explicit ABI are deprecated
  --> src/core.rs:72:1
   |
72 | extern {
   | ^^^^^^ help: explicitly specify the "C" ABI: `extern "C"`
   |
   = note: `#[warn(missing_abi)]` on by default
3 months ago
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
3 months ago
Jason Ish 155706f96b jsonbuilder: prefix C API with SC 3 months ago
Alice Akaki 2dfd2a752f mime/email: remove unnecessary logs
fields 'date' and 'subject' are logged by enabling extended logging mode
3 months ago
Victor Julien 4da69a52fe detect/sdp: minor style fixup 3 months ago
Giuseppe Longo 300889a30b sdp: add sdp.media.encryption_key sticky buffer
This adds a sticky (multi) buffer to match the "Encryption key" subfield
of the "Media description" field in both requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo b4e24742dd sdp: add sdp.media.connection_data sticky buffer
This adds a sticky (multi) buffer to match the "Connection data"
subfield of the "Media description" field in both requests and
responses.

Ticket #7291
3 months ago
Giuseppe Longo ccd2407a47 sdp: add sdp.media.media_info sticky buffer
This adds a stick (multi) buffer to match the "Session information"
subfield of the "Media description" field in both requests and
responses.

Ticket #7291
3 months ago
Giuseppe Longo ae7301cce3 sdp: add sdp.media.media sticky buffer
This adds a sticky (multi) buffer to match the "Media" subfield of the
"Media description" field in both requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo cee6f670d5 sdp: add sdp.attribute sticky buffer
This adds a sticky (multi) buffer to match the "Attribute" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo 038dac7ebe sdp: add sdp.encryption_key sticky buffer
This adds a sticky buffer to match the "Encryption key" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo 5f841179db sdp: add sdp.timezone sticky buffer
This adds a sticky bufffer to match the "Timezone" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo d9df3a3a5a sdp: add sdp.repeat_time sticky buffer
This adds a sticky buffer to match the "Repeat time" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo 38d9e8a628 sdp: add sdp.time sticky buffer
This adds a sticky buffer to match the "Time" field in both requests and
responses.

Ticket #7291
3 months ago
Giuseppe Longo 086345f30b sdp: add sdp.bandwidth sticky buffer
This adds a sticky (multi) buffer to match the "Bandwidth" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo 47d7024b8a sdp: add sdp.connection_data sticky buffer
This adds a sticky buffer to match the "Connection data" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo 6fef5db5f7 sdp: add sdp.phone_number sticky buffer
This adds a sticky buffer to match the "Phone number" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo 24f1da27b5 sdp: add sdp.email sticky buffer
This adds a sticky buffer to match the "Email" field in both requests
and responses.

Ticket #7291
3 months ago
Giuseppe Longo 82af560a54 sdp: add sdp.uri sticky buffer
This adds a sticky buffer to match the "Uri" field in both requests and
responses.

Ticket #7291
3 months ago
Giuseppe Longo 38cfe97ddc sdp: add sdp.origin sticky buffer
This adds a sticky buffer to match the "Origin" field in both requests
and responses.

Ticket #7291
3 months ago
Giuseppe Longo 2390f21033 sdp: add sdp.session_info sticky buffer
This adds a sticky buffer to match the "Session information" field in
both requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo 2f24f49dba sdp: add sdp.session_name sticky buffer
This adds a sticky buffer to match the "Session name" field in both
requests and responses.

Ticket #7291
3 months ago
Giuseppe Longo a7b38ccae3 sdp: parse time and repeat_time multiple times
As defined in RFC4566, the time and repeat_time fields can be present
multiple times but they are currently parsed only once.

Ticket #7325
3 months ago
Giuseppe Longo b481705ff8 sdp: stringify structured fields
The current parser implementations take a field, such as connection data, and
split it into subfields for a specific structure (e.g., struct ConnectionData).
However, following this approach requires several sticky buffers to match the
whole field, which can make a rule a bit verbose and doesn't offer any advantage
for matching specific parts of a field.

With this patch, a single line is still split into pieces if it makes sense for
parsing purposes, but these pieces are then reassembled into a single string.
This way, only one sticky buffer is needed to match the entire field.

Ticket #7291
3 months ago
Giuseppe Longo 891da0fa4a sdp: log media's encryption key
The encryption key subfield of the media description field is not
logged when it should be.

Ticket #7305
3 months ago
Jason Ish 640dd7c582 rust/conf: rust format 4 months ago
Jason Ish 813eb27b95 rust/conf: use generated bindings to SCConf API 4 months ago
Jason Ish 22b77b0c56 conf: prefix conf API with SC 4 months ago
Jason Ish b67917489d rust/rdp: namespace and visibility cleanups
Ticket: #7498
4 months ago
Jason Ish 018e46bfcf rust/smb: namespace and visibility cleanups
Ticket: #7498
4 months ago
Jeff Lucovsky fdc0ac590e detect/entropy: Add entropy keyword
This commit adds keyword/build support for the entropy keyword. The
entropy keyword compares an entropy value with a value calculated
according to the Shannon entropy on the available content.

Issue: 4162
4 months ago
Jeff Lucovsky c92f0f6d27 rust/detect: Add entropy support
This commit adds
- Parser for the entropy keyword
- Calculation of content the Shannon entropy value

Issue: 4162

The entropy keyword syntax is the keyword entropy followed by options
and the entropy value for comparison.

The minimum entropy keyword specification is:
entropy: value <entropy-spec>

This results in the calculated entropy value being compared with
<entropy-spec> with the equality operator.

Calculated entropy values are between 0.0 and 8.0, inclusive.

A match occurs when the values and operator agree. This example matches
if the calculated and entropy value are the same.

When entropy keyword options are specified, all options and "value" must
be comma-separated. Options and value may be specified in any order.

Options have default values:
- bytes is equal to the current content length
- offset is 0
- comparison with value is equality

entropy: [bytes <byteval>] [offset <offsetval>] value <entropy-spec>

Using default values:
entropy: bytes 0, offset 0, value =<entropy-spec>

<entropy-spec> is: <operator> (see below) and a value, e.g., "< 4.1"

The following operators are available from the float crate:
    - =  (default): Match when calculated entropy value equals specified entropy value
    - <  Match when calculated entropy value is strictly less than specified entropy value
    - <= Match when calculated entropy value is less than or equal to specified entropy value
    - >  Match when calculated entropy value is strictly greater than specified entropy value
    - >= Match when calculated entropy value is greater than or equal to specified entropy value
    - != Match when calculated entropy value is not equal to specified entropy value
    - x-y Match when calculated entropy value is in the range, exclusive
    - !x-y Match when calculated entropy value is not in the range, exclusive
4 months ago
Jeff Lucovsky d527021234 float: General purpose floating point functions
Issue: 4162

This commit adds a floating-point analog to `uint.rs` targeted
initially to be used by the forthcoming entropy keyword.
4 months ago
Jeff Lucovsky 8e373e46a3 decode/datalink: Add datalink value/name logic
Issue: 6954

Add Rust based logic that maintains a hash map of link type values and
their associated output names.
4 months ago
Jason Ish bfd6c29f5a detect: SC prefix for extern pub Rust functions
Ticket: #7498
4 months ago
Jason Ish 27fd2fe74b snmp: rust naming and visibility cleanups
Ticket: #7498
4 months ago
Alice Akaki 7750129c65 mime/email: log date and subject fields 4 months ago
Victor Julien 834378ff88 detect: per tx detect flags to a u8 progress value
Reduce per tx space for tracking detection/prefilter progress. Instead
of a per direction u64 of flags, where each bit reflected a progress
value, use a simple u8 to track the linear progression through the
progress values. Use an offset to allow 0 to mean no value.

Add flags field as well to track "skip detect" and "inspect complete".
4 months ago
Victor Julien 1542bcdc67 app-layer: add helper for AppLayerTxData cleanup 4 months ago
Philippe Antoine c164cfcf6b plugins: check version for all plugins 4 months ago
Philippe Antoine 5742df3783 plugins: bind constant SC_PLUGIN_API_VERSION 4 months ago
Philippe Antoine 52862e50be plugin: constify some fields
including the tx parameter to the logger function
4 months ago
Philippe Antoine 1db49487a1 rust/detect: extend visibility of SIGMATH_NOOPT
so that it can be used by plugins

Avoid export by cbindgen as this constant is also defined in C
4 months ago
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
4 months ago
Alice Akaki 7ba4ebdc2c detect: add email.cc keyword
email.cc matches on MIME EMAIL Carbon Copy
This keyword maps to the EVE field email.cc[]
It is a sticky buffer
Supports prefiltering

Ticket: #7588
4 months ago
Jason Ish 77b94b8713 rust: fixes for breaking change on deranged crate
Deranged v0.4.1 (a dependency of the time crate) has implemented
PartialOrd for some integer types that conflict with the
implementation in the standard library creating an ambiguity as such
implementation are global. For more info see
https://github.com/jhpratt/deranged/issues/18.

To fix, use "::from" directly, instead of using .into() which is where
we run into amgibuity.
4 months ago
Juliana Fajardini c595bfed87 pgsql/parser: use fn for length parsing...
... there was still one parser missing this conversion.
4 months ago
Jason Ish 7568b8020d dns: stop renaming DNSTransaction to RSDNSTransaction
Not needed anymore as there is no DNSTransaction in the C src to
conflict.
4 months ago
Jason Ish 1206c1c5af lua: convert dns function into suricata.dns lib
Notable changes from the previous API:
- rcode will return the rcode as an integer
- rcode_string will return the string representation

Also fixes an issue where an rcode of 0 was returned as nil.

Ticket: #7602
4 months ago
Alice Akaki 90aab0d62f detect: add email.from
email.from matches on MIME EMAIL FROM
This keyword maps to the EVE field email.from
It is a sticky buffer
Supports prefiltering

Ticket: #7592
4 months ago