From 5a5dcdab3ed7da488efd58eb20e8cde43391f2c3 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 7 Jul 2026 16:00:33 +0200 Subject: [PATCH] http2/doc: list possible values for enum keywords Ticket: 8675 --- doc/userguide/rules/http2-keywords.rst | 4 ++++ rust/src/http2/detect.rs | 15 ++++++++++++++- src/detect-http2.c | 12 ++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/userguide/rules/http2-keywords.rst b/doc/userguide/rules/http2-keywords.rst index 6497ffb523..d429d5e0c3 100644 --- a/doc/userguide/rules/http2-keywords.rst +++ b/doc/userguide/rules/http2-keywords.rst @@ -26,6 +26,8 @@ http2.frametype is also a :ref:`multi-integer `. http2.frametype does not have any corresponding log output. +See ``suricata --list-keywords=json | jq '."http2.frametype".enum_values'`` + Examples:: http2.frametype:GOAWAY; @@ -40,6 +42,8 @@ http2.errorcode uses an :ref:`unsigned 32-bit integer `. http2.errorcode is also a :ref:`multi-integer `. +See ``suricata --list-keywords=json | jq '."http2.errorcode".enum_values'`` + Examples:: http2.errorcode: NO_ERROR; diff --git a/rust/src/http2/detect.rs b/rust/src/http2/detect.rs index 5e57bbb2a6..380f1e8ad8 100644 --- a/rust/src/http2/detect.rs +++ b/rust/src/http2/detect.rs @@ -25,12 +25,13 @@ use crate::detect::uint::{ DetectUintArrayData, DetectUintData, DetectUintIndex, DetectUintMode, }; use crate::detect::{DetectThreadBuf, EnumString}; +use crate::jsonbuilder::JsonBuilder; use crate::direction::Direction; use base64::{engine::general_purpose::STANDARD, Engine}; use std::ffi::CStr; use std::os::raw::c_void; use std::rc::Rc; -use suricata_sys::sys::DetectEngineThreadCtx; +use suricata_sys::sys::{DetectEngineThreadCtx, SCJsonBuilder}; #[no_mangle] pub unsafe extern "C" fn SCHttp2TxHasFrametype( @@ -1178,3 +1179,15 @@ mod tests { } } } + +#[no_mangle] +pub unsafe extern "C" fn SCDetectHTTP2frameTypeListValues(jsb: *mut SCJsonBuilder) { + let jsb = cast_pointer!(jsb, JsonBuilder); + let _ = parser::HTTP2FrameType::list_values(jsb); +} + +#[no_mangle] +pub unsafe extern "C" fn SCDetectHTTP2errorcodeListValues(jsb: *mut SCJsonBuilder) { + let jsb = cast_pointer!(jsb, JsonBuilder); + let _ = parser::HTTP2ErrorCode::list_values(jsb); +} \ No newline at end of file diff --git a/src/detect-http2.c b/src/detect-http2.c index 14d9662b6c..c451aae696 100644 --- a/src/detect-http2.c +++ b/src/detect-http2.c @@ -97,6 +97,16 @@ static int g_http2_match_buffer_id = 0; static int g_http2_complete_buffer_id = 0; static int g_http2_header_buffer_id = 0; +static void DetectHTTP2frameTypeListValues(SCJsonBuilder *jsb) +{ + SCDetectHTTP2frameTypeListValues(jsb); +} + +static void DetectHTTP2errorcodeListValues(SCJsonBuilder *jsb) +{ + SCDetectHTTP2errorcodeListValues(jsb); +} + /** * \brief Registration function for HTTP2 keywords */ @@ -112,6 +122,7 @@ void DetectHttp2Register(void) sigmatch_table[DETECT_HTTP2_FRAMETYPE].Free = DetectHTTP2frametypeFree; sigmatch_table[DETECT_HTTP2_FRAMETYPE].flags = SIGMATCH_INFO_UINT8 | SIGMATCH_INFO_MULTI_UINT | SIGMATCH_INFO_ENUM_UINT; + sigmatch_table[DETECT_HTTP2_FRAMETYPE].JsonAdditionalInfo = DetectHTTP2frameTypeListValues; #ifdef UNITTESTS sigmatch_table[DETECT_HTTP2_FRAMETYPE].RegisterTests = DetectHTTP2frameTypeRegisterTests; #endif @@ -125,6 +136,7 @@ void DetectHttp2Register(void) sigmatch_table[DETECT_HTTP2_ERRORCODE].Free = DetectHTTP2errorcodeFree; sigmatch_table[DETECT_HTTP2_ERRORCODE].flags = SIGMATCH_INFO_UINT32 | SIGMATCH_INFO_MULTI_UINT | SIGMATCH_INFO_ENUM_UINT; + sigmatch_table[DETECT_HTTP2_ERRORCODE].JsonAdditionalInfo = DetectHTTP2errorcodeListValues; #ifdef UNITTESTS sigmatch_table[DETECT_HTTP2_ERRORCODE].RegisterTests = DetectHTTP2errorCodeRegisterTests; #endif