mirror of
https://github.com/OISF/suricata.git
synced 2026-06-13 10:50:28 -04:00
templates: clang format cleanups
Cleanup the trivial clang-formatting issues in templates. Length of protocol names may require clang-format after new protocol generation.
This commit is contained in:
parent
712d80107f
commit
05e16820de
5 changed files with 28 additions and 29 deletions
|
|
@ -120,7 +120,7 @@ def patch_app_layer_protos_c(protoname):
|
|||
for i, line in enumerate(inlines):
|
||||
|
||||
if line.find("case ALPROTO_TEMPLATE:") > -1:
|
||||
# Duplicate the section starting an this line and
|
||||
# Duplicate the section starting at this line and
|
||||
# including the following 2 lines.
|
||||
for j in range(i, i + 3):
|
||||
temp = inlines[j]
|
||||
|
|
@ -129,9 +129,13 @@ def patch_app_layer_protos_c(protoname):
|
|||
output.write(temp)
|
||||
|
||||
if line.find("return ALPROTO_TEMPLATE;") > -1:
|
||||
output.write(
|
||||
line.replace("TEMPLATE", protoname.upper()).replace(
|
||||
"template", protoname.lower()))
|
||||
# Duplicate the section starting at this line and
|
||||
# including the following line.
|
||||
for j in range(i, i + 2):
|
||||
temp = inlines[j]
|
||||
temp = temp.replace("TEMPLATE", protoname.upper())
|
||||
temp = temp.replace("template", protoname.lower())
|
||||
output.write(temp)
|
||||
|
||||
output.write(line)
|
||||
open(filename, "w").write(output.getvalue())
|
||||
|
|
|
|||
|
|
@ -190,8 +190,10 @@ AppProto StringToAppProto(const char *proto_name)
|
|||
return ALPROTO_PGSQL;
|
||||
if (strcmp(proto_name, "telnet") == 0)
|
||||
return ALPROTO_TELNET;
|
||||
if (strcmp(proto_name,"template")==0) return ALPROTO_TEMPLATE;
|
||||
if (strcmp(proto_name,"template-rust")==0) return ALPROTO_TEMPLATE_RUST;
|
||||
if (strcmp(proto_name, "template") == 0)
|
||||
return ALPROTO_TEMPLATE;
|
||||
if (strcmp(proto_name, "template-rust") == 0)
|
||||
return ALPROTO_TEMPLATE_RUST;
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@
|
|||
#include "detect-engine-build.h"
|
||||
#include "rust.h"
|
||||
|
||||
|
||||
static int DetectTemplateRustBufferSetup(DetectEngineCtx *, Signature *,
|
||||
const char *);
|
||||
static int DetectTemplateRustBufferSetup(DetectEngineCtx *, Signature *, const char *);
|
||||
static uint8_t DetectEngineInspectTemplateRustBuffer(DetectEngineCtx *de_ctx,
|
||||
DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine,
|
||||
const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id);
|
||||
|
|
@ -82,8 +80,7 @@ void DetectTemplateRustBufferRegister(void)
|
|||
SCLogNotice("Template application layer detect registered.");
|
||||
}
|
||||
|
||||
static int DetectTemplateRustBufferSetup(DetectEngineCtx *de_ctx, Signature *s,
|
||||
const char *str)
|
||||
static int DetectTemplateRustBufferSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
|
||||
{
|
||||
s->init_data->list = g_template_rust_id;
|
||||
|
||||
|
|
@ -157,26 +154,24 @@ static int DetectTemplateRustBufferTest(void)
|
|||
FAIL_IF_NULL(de_ctx);
|
||||
|
||||
/* This rule should match. */
|
||||
s = DetectEngineAppendSig(de_ctx,
|
||||
"alert tcp any any -> any any ("
|
||||
"msg:\"TEMPLATE Test Rule\"; "
|
||||
"template_rust_buffer; content:\"World!\"; "
|
||||
"sid:1; rev:1;)");
|
||||
s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any ("
|
||||
"msg:\"TEMPLATE Test Rule\"; "
|
||||
"template_rust_buffer; content:\"World!\"; "
|
||||
"sid:1; rev:1;)");
|
||||
FAIL_IF_NULL(s);
|
||||
|
||||
/* This rule should not match. */
|
||||
s = DetectEngineAppendSig(de_ctx,
|
||||
"alert tcp any any -> any any ("
|
||||
"msg:\"TEMPLATE Test Rule\"; "
|
||||
"template_rust_buffer; content:\"W0rld!\"; "
|
||||
"sid:2; rev:1;)");
|
||||
s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any ("
|
||||
"msg:\"TEMPLATE Test Rule\"; "
|
||||
"template_rust_buffer; content:\"W0rld!\"; "
|
||||
"sid:2; rev:1;)");
|
||||
FAIL_IF_NULL(s);
|
||||
|
||||
SigGroupBuild(de_ctx);
|
||||
DetectEngineThreadCtxInit(&tv, (void *)de_ctx, (void *)&det_ctx);
|
||||
|
||||
AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_TEMPLATE_RUST,
|
||||
STREAM_TOSERVER, request, sizeof(request));
|
||||
AppLayerParserParse(
|
||||
NULL, alp_tctx, &f, ALPROTO_TEMPLATE_RUST, STREAM_TOSERVER, request, sizeof(request));
|
||||
|
||||
/* Check that we have app-layer state. */
|
||||
FAIL_IF_NULL(f.alstate);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#ifndef __DETECT_TEMPLATE_RUST_BUFFER_H__
|
||||
#define __DETECT_TEMPLATE_RUST_BUFFER_H__
|
||||
|
||||
|
||||
void DetectTemplateRustBufferRegister(void);
|
||||
|
||||
#endif /* __DETECT_TEMPLATE_RUST_BUFFER_H__ */
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
#include "rust.h"
|
||||
|
||||
typedef struct LogTemplateFileCtx_ {
|
||||
uint32_t flags;
|
||||
uint32_t flags;
|
||||
OutputJsonCtx *eve_ctx;
|
||||
} LogTemplateFileCtx;
|
||||
|
||||
|
|
@ -62,8 +62,8 @@ typedef struct LogTemplateLogThread_ {
|
|||
OutputJsonThreadCtx *ctx;
|
||||
} LogTemplateLogThread;
|
||||
|
||||
static int JsonTemplateLogger(ThreadVars *tv, void *thread_data,
|
||||
const Packet *p, Flow *f, void *state, void *tx, uint64_t tx_id)
|
||||
static int JsonTemplateLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f,
|
||||
void *state, void *tx, uint64_t tx_id)
|
||||
{
|
||||
SCLogNotice("JsonTemplateLogger");
|
||||
LogTemplateLogThread *thread = thread_data;
|
||||
|
|
@ -97,8 +97,7 @@ static void OutputTemplateLogDeInitCtxSub(OutputCtx *output_ctx)
|
|||
SCFree(output_ctx);
|
||||
}
|
||||
|
||||
static OutputInitResult OutputTemplateLogInitSub(ConfNode *conf,
|
||||
OutputCtx *parent_ctx)
|
||||
static OutputInitResult OutputTemplateLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
|
||||
{
|
||||
OutputInitResult result = { NULL, false };
|
||||
OutputJsonCtx *ajt = parent_ctx->data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue