template: rename template-rust to template

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.
pull/8251/head
Jason Ish 2 years ago committed by Victor Julien
parent 8683154115
commit 4a7567b3f0

@ -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 */

@ -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)

@ -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)

@ -56,7 +56,7 @@ enum AppProtoEnum {
ALPROTO_MQTT,
ALPROTO_PGSQL,
ALPROTO_TELNET,
ALPROTO_TEMPLATE_RUST,
ALPROTO_TEMPLATE,
ALPROTO_RDP,
ALPROTO_HTTP2,
ALPROTO_BITTORRENT_DHT,

@ -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,

@ -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);

@ -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.");
}

Loading…
Cancel
Save