detect: expose the sigmatch list ids to Rust

Move enum DetectSigmatchListEnum to detect-engine-register.h, which is
already included by detect.h and the bindgen header, and allowlist it in
the Rust bindings. Packet keywords implemented in Rust or in plugins
need DETECT_SM_LIST_MATCH to add their SigMatch and to look up earlier
ones, and had to hardcode its value.

Related to ticket: 7499
pull/16454/head
Jason Ish 1 week ago
parent 4651b30bd3
commit 1a73276acb

@ -157,6 +157,7 @@ if HAVE_BINDGEN
--allowlist-function 'SC.*' \
--allowlist-var 'SC.*' \
--allowlist-var 'SIGMATCH.*' \
--allowlist-type 'DetectSigmatchListEnum' \
--opaque-type 'SCConfNode' \
--allowlist-type 'ThreadVars.?' \
--opaque-type 'ThreadVars.?' \

@ -635,6 +635,23 @@ extern "C" {
tv: *mut ThreadVars, p: *const Packet, f: *mut Flow, jb: *mut SCJsonBuilder,
);
}
impl DetectSigmatchListEnum {
pub const DETECT_SM_LIST_DYNAMIC_START: DetectSigmatchListEnum =
DetectSigmatchListEnum::DETECT_SM_LIST_MAX;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum DetectSigmatchListEnum {
DETECT_SM_LIST_MATCH = 0,
DETECT_SM_LIST_PMATCH = 1,
DETECT_SM_LIST_BASE64_DATA = 2,
DETECT_SM_LIST_POSTMATCH = 3,
#[doc = "< post-detection tagging"]
DETECT_SM_LIST_TMATCH = 4,
DETECT_SM_LIST_SUPPRESS = 5,
DETECT_SM_LIST_THRESHOLD = 6,
DETECT_SM_LIST_MAX = 7,
}
extern "C" {
pub fn SCSigTablePreRegister(
KeywordsRegister: ::std::option::Option<unsafe extern "C" fn()>,

@ -298,6 +298,35 @@ enum DetectKeywordId {
DETECT_TBLSIZE_STATIC,
};
/* holds the values for different possible lists in struct Signature.
* These codes are access points to particular lists in the array
* Signature->init_data->smlists[DETECT_SM_LIST_MAX]. */
enum DetectSigmatchListEnum {
/* list for non-payload per packet matches, e.g. ttl, flow keyword */
DETECT_SM_LIST_MATCH = 0,
/* list for payload and stream match */
DETECT_SM_LIST_PMATCH,
/* base64_data keyword uses some hardcoded logic so consider
* built-in
* TODO convert to inspect engine */
DETECT_SM_LIST_BASE64_DATA,
/* list for post match actions: flowbit set, flowint increment, etc */
DETECT_SM_LIST_POSTMATCH,
DETECT_SM_LIST_TMATCH, /**< post-detection tagging */
/* lists for alert thresholding and suppression */
DETECT_SM_LIST_SUPPRESS,
DETECT_SM_LIST_THRESHOLD,
DETECT_SM_LIST_MAX,
/* start of dynamically registered lists */
DETECT_SM_LIST_DYNAMIC_START = DETECT_SM_LIST_MAX,
};
extern int DETECT_TBLSIZE;
extern int DETECT_TBLSIZE_IDX;
// step for reallocating sigmatch_table

@ -110,35 +110,6 @@ extern const struct SignatureProperties signature_properties[SIG_TYPE_MAX];
-- Protocol
*/
/* holds the values for different possible lists in struct Signature.
* These codes are access points to particular lists in the array
* Signature->init_data->smlists[DETECT_SM_LIST_MAX]. */
enum DetectSigmatchListEnum {
/* list for non-payload per packet matches, e.g. ttl, flow keyword */
DETECT_SM_LIST_MATCH = 0,
/* list for payload and stream match */
DETECT_SM_LIST_PMATCH,
/* base64_data keyword uses some hardcoded logic so consider
* built-in
* TODO convert to inspect engine */
DETECT_SM_LIST_BASE64_DATA,
/* list for post match actions: flowbit set, flowint increment, etc */
DETECT_SM_LIST_POSTMATCH,
DETECT_SM_LIST_TMATCH, /**< post-detection tagging */
/* lists for alert thresholding and suppression */
DETECT_SM_LIST_SUPPRESS,
DETECT_SM_LIST_THRESHOLD,
DETECT_SM_LIST_MAX,
/* start of dynamically registered lists */
DETECT_SM_LIST_DYNAMIC_START = DETECT_SM_LIST_MAX,
};
/* used for Signature->list, which indicates which list
* we're adding keywords to in cases of sticky buffers like
* file_data */

Loading…
Cancel
Save