]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
template: rename template-rust to template
authorJason Ish <jason.ish@oisf.net>
Thu, 17 Nov 2022 22:05:15 +0000 (16:05 -0600)
committerVictor Julien <vjulien@oisf.net>
Tue, 6 Dec 2022 13:09:10 +0000 (14:09 +0100)
Remove the distinction between the C template protocol "template" and
the Rust template protocol "template-rust" and make the Rust parser
simply template now that we no longer have support to generate a C
protocol template.

rust/src/applayertemplate/template.rs
src/app-layer-detect-proto.c
src/app-layer-protos.c
src/app-layer-protos.h
src/detect-engine-register.h
src/detect-template-rust-buffer.c
src/output-json-template-rust.c

index cd3bd8803f1946b57b84fd3a9b03d7249f10d8d9..67555c3ef9ccba138b66395527ac44356d59e2d7 100644 (file)
@@ -399,12 +399,12 @@ export_tx_data_get!(rs_template_get_tx_data, TemplateTransaction);
 export_state_data_get!(rs_template_get_state_data, TemplateState);
 
 // Parser name as a C style string.
-const PARSER_NAME: &[u8] = b"template-rust\0";
+const PARSER_NAME: &[u8] = b"template\0";
 
 #[no_mangle]
 pub unsafe extern "C" fn rs_template_register_parser() {
     /* TEMPLATE_START_REMOVE */
-    if crate::conf::conf_get_node("app-layer.protocols.template-rust").is_none() {
+    if crate::conf::conf_get_node("app-layer.protocols.template").is_none() {
         return;
     }
     /* TEMPLATE_END_REMOVE */
index ac7e41e30384556f80bfdccadb0082932231ebfa..c826bbcd6a5645a958db00cde3596a096e2eb349 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2021 Open Information Security Foundation
+/* Copyright (C) 2007-2022 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -905,8 +905,8 @@ static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingPar
                         printf("            alproto: ALPROTO_SNMP\n");
                     else if (pp_pe->alproto == ALPROTO_SIP)
                         printf("            alproto: ALPROTO_SIP\n");
-                    else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST)
-                        printf("            alproto: ALPROTO_TEMPLATE_RUST\n");
+                    else if (pp_pe->alproto == ALPROTO_TEMPLATE)
+                        printf("            alproto: ALPROTO_TEMPLATE\n");
                     else if (pp_pe->alproto == ALPROTO_RFB)
                         printf("            alproto: ALPROTO_RFB\n");
                     else if (pp_pe->alproto == ALPROTO_MQTT)
@@ -988,8 +988,8 @@ static void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingPar
                     printf("            alproto: ALPROTO_SNMP\n");
                 else if (pp_pe->alproto == ALPROTO_SIP)
                     printf("            alproto: ALPROTO_SIP\n");
-                else if (pp_pe->alproto == ALPROTO_TEMPLATE_RUST)
-                    printf("            alproto: ALPROTO_TEMPLATE_RUST\n");
+                else if (pp_pe->alproto == ALPROTO_TEMPLATE)
+                    printf("            alproto: ALPROTO_TEMPLATE\n");
                 else if (pp_pe->alproto == ALPROTO_RFB)
                     printf("            alproto: ALPROTO_RFB\n");
                 else if (pp_pe->alproto == ALPROTO_MQTT)
index 41fe5ba718258a114c50a2ee36c009e4836bd76d..1ef39115c2517a2e5a0c35c92f9ccd048ef84287 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2021 Open Information Security Foundation
+/* Copyright (C) 2007-2022 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -117,8 +117,8 @@ const char *AppProtoToString(AppProto alproto)
         case ALPROTO_TELNET:
             proto_name = "telnet";
             break;
-        case ALPROTO_TEMPLATE_RUST:
-            proto_name = "template-rust";
+        case ALPROTO_TEMPLATE:
+            proto_name = "template";
             break;
         case ALPROTO_RDP:
             proto_name = "rdp";
@@ -187,8 +187,8 @@ AppProto StringToAppProto(const char *proto_name)
         return ALPROTO_PGSQL;
     if (strcmp(proto_name, "telnet") == 0)
         return ALPROTO_TELNET;
-    if (strcmp(proto_name, "template-rust") == 0)
-        return ALPROTO_TEMPLATE_RUST;
+    if (strcmp(proto_name, "template") == 0)
+        return ALPROTO_TEMPLATE;
     if (strcmp(proto_name,"rdp")==0) return ALPROTO_RDP;
     if (strcmp(proto_name,"http2")==0) return ALPROTO_HTTP2;
     if (strcmp(proto_name, "bittorrent-dht") == 0)
index 6ed7a0de3a9a74dd9de9b254e1ff4f905bfd9b79..b0a5db1c8a0144b08cf6d22aa6891a5a82a8cae6 100644 (file)
@@ -56,7 +56,7 @@ enum AppProtoEnum {
     ALPROTO_MQTT,
     ALPROTO_PGSQL,
     ALPROTO_TELNET,
-    ALPROTO_TEMPLATE_RUST,
+    ALPROTO_TEMPLATE,
     ALPROTO_RDP,
     ALPROTO_HTTP2,
     ALPROTO_BITTORRENT_DHT,
index 9af94d7a16355fb294063b7270d3d321678e24a4..633e747a318a927f4eba58b0b7f25b74b5f00b7a 100644 (file)
@@ -277,7 +277,7 @@ enum DetectKeywordId {
     DETECT_TCPMSS,
     DETECT_FTPDATA,
     DETECT_TARGET,
-    DETECT_AL_TEMPLATE_RUST_BUFFER,
+    DETECT_AL_TEMPLATE_BUFFER,
     DETECT_AL_DHCP_LEASETIME,
     DETECT_AL_DHCP_REBINDING_TIME,
     DETECT_AL_DHCP_RENEWAL_TIME,
index eb856617e9e71cbdc3cc3aaac0a029d9eb28279a..86fc282712baf37c0189e2773c78da86edb6be58 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2017 Open Information Security Foundation
+/* Copyright (C) 2015-2022 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -57,25 +57,22 @@ void DetectTemplateRustBufferRegister(void)
         return;
     }
     /* TEMPLATE_END_REMOVE */
-    sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].name =
-        "template_rust_buffer";
-    sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].desc =
+    sigmatch_table[DETECT_AL_TEMPLATE_BUFFER].name = "template_rust_buffer";
+    sigmatch_table[DETECT_AL_TEMPLATE_BUFFER].desc =
             "Template content modifier to match on the template buffers";
-    sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].Setup =
-        DetectTemplateRustBufferSetup;
+    sigmatch_table[DETECT_AL_TEMPLATE_BUFFER].Setup = DetectTemplateRustBufferSetup;
 #ifdef UNITTESTS
-    sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].RegisterTests =
-        DetectTemplateRustBufferRegisterTests;
+    sigmatch_table[DETECT_AL_TEMPLATE_BUFFER].RegisterTests = DetectTemplateRustBufferRegisterTests;
 #endif
-    sigmatch_table[DETECT_AL_TEMPLATE_RUST_BUFFER].flags |= SIGMATCH_NOOPT;
+    sigmatch_table[DETECT_AL_TEMPLATE_BUFFER].flags |= SIGMATCH_NOOPT;
 
     /* register inspect engines */
-    DetectAppLayerInspectEngineRegister2("template_rust_buffer", ALPROTO_TEMPLATE_RUST,
-            SIG_FLAG_TOSERVER, 0, DetectEngineInspectTemplateRustBuffer, NULL);
-    DetectAppLayerInspectEngineRegister2("template_rust_buffer", ALPROTO_TEMPLATE_RUST,
-            SIG_FLAG_TOCLIENT, 0, DetectEngineInspectTemplateRustBuffer, NULL);
+    DetectAppLayerInspectEngineRegister2("template_buffer", ALPROTO_TEMPLATE, SIG_FLAG_TOSERVER, 0,
+            DetectEngineInspectTemplateRustBuffer, NULL);
+    DetectAppLayerInspectEngineRegister2("template_buffer", ALPROTO_TEMPLATE, SIG_FLAG_TOCLIENT, 0,
+            DetectEngineInspectTemplateRustBuffer, NULL);
 
-    g_template_rust_id = DetectBufferTypeGetByName("template_rust_buffer");
+    g_template_rust_id = DetectBufferTypeGetByName("template_buffer");
 
     SCLogNotice("Template application layer detect registered.");
 }
@@ -84,7 +81,7 @@ static int DetectTemplateRustBufferSetup(DetectEngineCtx *de_ctx, Signature *s,
 {
     s->init_data->list = g_template_rust_id;
 
-    if (DetectSignatureSetAppProto(s, ALPROTO_TEMPLATE_RUST) != 0)
+    if (DetectSignatureSetAppProto(s, ALPROTO_TEMPLATE) != 0)
         return -1;
 
     return 0;
@@ -141,7 +138,7 @@ static int DetectTemplateRustBufferTest(void)
     memset(&tv, 0, sizeof(ThreadVars));
     p = UTHBuildPacket(request, sizeof(request), IPPROTO_TCP);
     FLOW_INITIALIZE(&f);
-    f.alproto = ALPROTO_TEMPLATE_RUST;
+    f.alproto = ALPROTO_TEMPLATE;
     f.protoctx = (void *)&tcp;
     f.proto = IPPROTO_TCP;
     f.flags |= FLOW_IPV4;
@@ -171,7 +168,7 @@ static int DetectTemplateRustBufferTest(void)
     DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
 
     AppLayerParserParse(
-            NULL, alp_tctx, &f, ALPROTO_TEMPLATE_RUST, STREAM_TOSERVER, request, sizeof(request));
+            NULL, alp_tctx, &f, ALPROTO_TEMPLATE, STREAM_TOSERVER, request, sizeof(request));
 
     /* Check that we have app-layer state. */
     FAIL_IF_NULL(f.alstate);
index 1d7f5da241d7d8cc3ff04244dc7121467e97235c..2634b1dc3b4b3bc69054e45d12a264e817d858b0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018-2021 Open Information Security Foundation
+/* Copyright (C) 2018-2022 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -68,8 +68,8 @@ static int JsonTemplateLogger(ThreadVars *tv, void *thread_data, const Packet *p
     SCLogNotice("JsonTemplateLogger");
     LogTemplateLogThread *thread = thread_data;
 
-    JsonBuilder *js = CreateEveHeader(
-            p, LOG_DIR_PACKET, "template-rust", NULL, thread->templatelog_ctx->eve_ctx);
+    JsonBuilder *js =
+            CreateEveHeader(p, LOG_DIR_PACKET, "template", NULL, thread->templatelog_ctx->eve_ctx);
     if (unlikely(js == NULL)) {
         return TM_ECODE_FAILED;
     }
@@ -118,7 +118,7 @@ static OutputInitResult OutputTemplateLogInitSub(ConfNode *conf, OutputCtx *pare
 
     SCLogNotice("Template log sub-module initialized.");
 
-    AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_TEMPLATE_RUST);
+    AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_TEMPLATE);
 
     result.ctx = output_ctx;
     result.ok = true;
@@ -165,14 +165,14 @@ static TmEcode JsonTemplateLogThreadDeinit(ThreadVars *t, void *data)
 void JsonTemplateRustLogRegister(void)
 {
     /* TEMPLATE_START_REMOVE */
-    if (ConfGetNode("app-layer.protocols.template-rust") == NULL) {
+    if (ConfGetNode("app-layer.protocols.template") == NULL) {
         return;
     }
     /* TEMPLATE_END_REMOVE */
     /* Register as an eve sub-module. */
-    OutputRegisterTxSubModule(LOGGER_JSON_TX, "eve-log", "JsonTemplateRustLog",
-            "eve-log.template-rust", OutputTemplateLogInitSub, ALPROTO_TEMPLATE_RUST,
-            JsonTemplateLogger, JsonTemplateLogThreadInit, JsonTemplateLogThreadDeinit, NULL);
+    OutputRegisterTxSubModule(LOGGER_JSON_TX, "eve-log", "JsonTemplateLog", "eve-log.template",
+            OutputTemplateLogInitSub, ALPROTO_TEMPLATE, JsonTemplateLogger,
+            JsonTemplateLogThreadInit, JsonTemplateLogThreadDeinit, NULL);
 
     SCLogNotice("Template JSON logger registered.");
 }