Skip to content

Commit

Permalink
template app-layer: disable if not in config file (default)
Browse files Browse the repository at this point in the history
Unlike other app-layer protocols which are enabled by default,
disable this one by default as it likely shouldn't be enabled
in production use of Suricata.
  • Loading branch information
jasonish authored and victorjulien committed Oct 20, 2015
1 parent 38c2107 commit 9697a09
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/app-layer-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "suricata-common.h"
#include "stream.h"
#include "conf.h"

#include "util-unittest.h"

Expand Down Expand Up @@ -428,6 +429,12 @@ void RegisterTemplateParsers(void)
{
char *proto_name = "template";

/* TEMPLATE_START_REMOVE */
if (ConfGetNode("app-layer.protocols.template") == NULL) {
return;
}
/* TEMPLATE_END_REMOVE */

/* Check if Template TCP detection is enabled. If it does not exist in
* the configuration file then it will be enabled by default. */
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
Expand Down Expand Up @@ -481,16 +488,17 @@ void RegisterTemplateParsers(void)
STREAM_TOSERVER, TemplateParseRequest);

/* Register response parser for parsing frames from server to client. */
AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_TEMPLATE, STREAM_TOCLIENT,
TemplateParseResponse);
AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_TEMPLATE,
STREAM_TOCLIENT, TemplateParseResponse);

/* Register a function to be called by the application layer
* when a transaction is to be freed. */
AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_TEMPLATE,
TemplateStateTxFree);

/* Register a function to return the current transaction count. */
AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_TEMPLATE, TemplateGetTxCnt);
AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_TEMPLATE,
TemplateGetTxCnt);

/* Transaction handling. */
AppLayerParserRegisterGetStateProgressCompletionStatus(IPPROTO_TCP,
Expand Down
5 changes: 5 additions & 0 deletions src/detect-template-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "suricata-common.h"
#include "conf.h"
#include "detect.h"
#include "app-layer-template.h"

Expand All @@ -29,6 +30,10 @@ static void DetectTemplateBufferRegisterTests(void);

void DetectTemplateBufferRegister(void)
{
if (ConfGetNode("app-layer.protocols.template") == NULL) {
return;
}

sigmatch_table[DETECT_AL_TEMPLATE_BUFFER].name = "template_buffer";
sigmatch_table[DETECT_AL_TEMPLATE_BUFFER].desc =
"Template content modififier to match on the template buffers";
Expand Down
4 changes: 4 additions & 0 deletions src/output-json-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ static TmEcode JsonTemplateLogThreadDeinit(ThreadVars *t, void *data)

void TmModuleJsonTemplateLogRegister(void)
{
if (ConfGetNode("app-layer.protocols.template") == NULL) {
return;
}

tmm_modules[TMM_JSONTEMPLATELOG].name = "JsonTemplateLog";
tmm_modules[TMM_JSONTEMPLATELOG].ThreadInit = JsonTemplateLogThreadInit;
tmm_modules[TMM_JSONTEMPLATELOG].ThreadDeinit = JsonTemplateLogThreadDeinit;
Expand Down

0 comments on commit 9697a09

Please sign in to comment.