]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/http: add http.uri.raw sticky buffer keyword
authorVictor Julien <victor@inliniac.net>
Sun, 25 Nov 2018 11:05:24 +0000 (12:05 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 29 Jan 2019 12:27:57 +0000 (13:27 +0100)
src/detect-engine-register.h
src/detect-http-uri.c

index 9cc563fa464ee11e9075e16b7624a0ad7da53514..b3787a2b69c6bf9b49909a2b8df10f0f3c738398 100644 (file)
@@ -130,6 +130,7 @@ enum {
     DETECT_AL_HTTP_RAW_HEADER,
     DETECT_AL_HTTP_URI,
     DETECT_HTTP_URI,
+    DETECT_HTTP_URI_RAW,
     DETECT_AL_HTTP_RAW_URI,
     DETECT_AL_HTTP_STAT_MSG,
     DETECT_AL_HTTP_STAT_CODE,
index 5b9041ae9156503cdb97c8918dc632baf5a71f7e..d7852b98f675265f42d53b88ecb01abc8a0183ed 100644 (file)
@@ -77,6 +77,7 @@ static InspectionBuffer *GetRawData(DetectEngineThreadCtx *det_ctx,
         const DetectEngineTransforms *transforms,
         Flow *_f, const uint8_t _flow_flags,
         void *txv, const int list_id);
+static int DetectHttpRawUriSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str);
 
 static int g_http_raw_uri_buffer_id = 0;
 static int g_http_uri_buffer_id = 0;
@@ -130,6 +131,13 @@ void DetectHttpUriRegister (void)
     sigmatch_table[DETECT_AL_HTTP_RAW_URI].Setup = DetectHttpRawUriSetup;
     sigmatch_table[DETECT_AL_HTTP_RAW_URI].flags |= SIGMATCH_NOOPT;
 
+    /* http.uri.raw sticky buffer */
+    sigmatch_table[DETECT_HTTP_URI_RAW].name = "http.uri.raw";
+    sigmatch_table[DETECT_HTTP_URI_RAW].desc = "sticky buffer to match specifically and only on the raw HTTP URI buffer";
+    sigmatch_table[DETECT_HTTP_URI_RAW].url = DOC_URL DOC_VERSION "/rules/tls-keywords.html#http-uri";
+    sigmatch_table[DETECT_HTTP_URI_RAW].Setup = DetectHttpRawUriSetupSticky;
+    sigmatch_table[DETECT_HTTP_URI_RAW].flags |= SIGMATCH_NOOPT;
+
     DetectAppLayerInspectEngineRegister2("http_raw_uri", ALPROTO_HTTP,
             SIG_FLAG_TOSERVER, HTP_REQUEST_LINE,
             DetectEngineInspectBufferGeneric, GetRawData);
@@ -253,6 +261,22 @@ static void DetectHttpRawUriSetupCallback(const DetectEngineCtx *de_ctx,
     DetectUrilenApplyToContent(s, g_http_raw_uri_buffer_id);
 }
 
+/**
+ * \brief this function setup the http.uri.raw keyword used in the rule
+ *
+ * \param de_ctx   Pointer to the Detection Engine Context
+ * \param s        Pointer to the Signature to which the current keyword belongs
+ * \param str      Should hold an empty string always
+ *
+ * \retval 0       On success
+ */
+static int DetectHttpRawUriSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str)
+{
+    DetectBufferSetActiveList(s, g_http_raw_uri_buffer_id);
+    s->alproto = ALPROTO_HTTP;
+    return 0;
+}
+
 static InspectionBuffer *GetRawData(DetectEngineThreadCtx *det_ctx,
         const DetectEngineTransforms *transforms, Flow *_f,
         const uint8_t _flow_flags, void *txv, const int list_id)