Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output alert applayer v16.1 #9869

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions scripts/setup-app-layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,43 +200,34 @@ def logger_patch_output_c(proto):
output = io.StringIO()
inlines = open(filename).readlines()
for i, line in enumerate(inlines):
if line.find("ALPROTO_TEMPLATE") > -1:
new_line = line.replace("TEMPLATE", proto.upper()).replace(
"template", proto.lower())
output.write(new_line)
if line.find("output-json-template.h") > -1:
output.write(line.replace("template", proto.lower()))
if line.find("/* Template JSON logger.") > -1:
output.write(inlines[i].replace("Template", proto))
output.write(inlines[i+1].replace("Template", proto))
output.write(inlines[i+2].replace("TEMPLATE", proto.upper()).replace(
"template", proto.lower()).replace("Template", proto))
output.write(inlines[i+3])
if line.find("rs_template_logger_log") > -1:
output.write(inlines[i].replace("TEMPLATE", proto.upper()).replace(
"template", proto.lower()))
if line.find("OutputTemplateLogInitSub(") > -1:
output.write(inlines[i].replace("Template", proto))
output.write(inlines[i+1])
output.write(inlines[i+2].replace("TEMPLATE", proto.upper()))
output.write(inlines[i+3])
output.write(inlines[i+4])
output.write(line)
open(filename, "w").write(output.getvalue())

def logger_copy_templates(proto):
lower = proto.lower()

pairs = (
("src/output-json-template.h",
"src/output-json-%s.h" % (lower)),
("src/output-json-template.c",
"src/output-json-%s.c" % (lower)),
("rust/src/applayertemplate/logger.rs",
"rust/src/applayer%s/logger.rs" % (lower)),
)

common_copy_templates(proto, pairs)

def logger_patch_makefile_am(protoname):
filename = "src/Makefile.am"
print("Patching %s." % (filename))
output = io.StringIO()
with open(filename) as infile:
for line in infile:
if line.lstrip().startswith("output-json-template."):
output.write(line.replace("template", protoname.lower()))
output.write(line)
open(filename, "w").write(output.getvalue())


def detect_copy_templates(proto, buffername):
lower = proto.lower()
Expand Down Expand Up @@ -398,7 +389,6 @@ def main():
raise SetupError("no app-layer parser exists for %s" % (proto))
logger_copy_templates(proto)
patch_rust_applayer_mod_rs(proto)
logger_patch_makefile_am(proto)
logger_patch_output_c(proto)
logger_patch_suricata_yaml_in(proto)

Expand Down
24 changes: 0 additions & 24 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ noinst_HEADERS = \
output.h \
output-json-alert.h \
output-json-anomaly.h \
output-json-bittorrent-dht.h \
output-json-dcerpc.h \
output-json-dhcp.h \
output-json-dnp3.h \
Expand All @@ -410,27 +409,16 @@ noinst_HEADERS = \
output-json-frame.h \
output-json-ftp.h \
output-json.h \
output-json-http2.h \
output-json-http.h \
output-json-ike.h \
output-json-krb5.h \
output-json-metadata.h \
output-json-modbus.h \
output-json-quic.h \
output-json-mqtt.h \
output-json-netflow.h \
output-json-nfs.h \
output-json-pgsql.h \
output-json-rdp.h \
output-json-rfb.h \
output-json-sip.h \
output-json-smb.h \
output-json-smtp.h \
output-json-snmp.h \
output-json-ssh.h \
output-json-stats.h \
output-json-template.h \
output-json-tftp.h \
output-json-tls.h \
output-eve-syslog.h \
output-lua.h \
Expand Down Expand Up @@ -1009,7 +997,6 @@ libsuricata_c_a_SOURCES = \
output-flow.c \
output-json-alert.c \
output-json-anomaly.c \
output-json-bittorrent-dht.c \
output-json.c \
output-json-common.c \
output-json-dcerpc.c \
Expand All @@ -1023,27 +1010,16 @@ libsuricata_c_a_SOURCES = \
output-json-flow.c \
output-json-frame.c \
output-json-ftp.c \
output-json-http2.c \
output-json-http.c \
output-json-ike.c \
output-json-krb5.c \
output-json-metadata.c \
output-json-modbus.c \
output-json-quic.c \
output-json-mqtt.c \
output-json-netflow.c \
output-json-nfs.c \
output-json-pgsql.c \
output-json-rdp.c \
output-json-rfb.c \
output-json-sip.c \
output-json-smb.c \
output-json-smtp.c \
output-json-snmp.c \
output-json-ssh.c \
output-json-stats.c \
output-json-template.c \
output-json-tftp.c \
output-json-tls.c \
output-eve-syslog.c \
output-eve-null.c \
Expand Down
1 change: 0 additions & 1 deletion src/app-layer-register.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ AppProto AppLayerRegisterProtocolDetection(const struct AppLayerParser *p, int e
AppLayerProtoDetectRegisterProtocol(alproto, p->name);

if (p->ProbeTS == NULL && p->ProbeTC == NULL) {
BUG_ON(p->default_port != NULL);
return alproto;
}

Expand Down
5 changes: 0 additions & 5 deletions src/output-json-alert.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,15 @@
#include "output-json-dns.h"
#include "output-json-http.h"
#include "output-json-tls.h"
#include "output-json-ssh.h"
#include "rust.h"
#include "output-json-smtp.h"
#include "output-json-email-common.h"
#include "output-json-nfs.h"
#include "output-json-smb.h"
#include "output-json-flow.h"
#include "output-json-sip.h"
#include "output-json-rfb.h"
#include "output-json-mqtt.h"
#include "output-json-ike.h"
#include "output-json-modbus.h"
#include "output-json-frame.h"
#include "output-json-quic.h"

#include "util-byte.h"
#include "util-privs.h"
Expand Down
163 changes: 0 additions & 163 deletions src/output-json-bittorrent-dht.c

This file was deleted.

27 changes: 0 additions & 27 deletions src/output-json-bittorrent-dht.h

This file was deleted.

4 changes: 2 additions & 2 deletions src/output-json-dnp3.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static void JsonDNP3LogObjects(JsonBuilder *js, DNP3ObjectList *objects)
}
}

void JsonDNP3LogRequest(JsonBuilder *js, DNP3Transaction *dnp3tx)
static void JsonDNP3LogRequest(JsonBuilder *js, DNP3Transaction *dnp3tx)
{
JB_SET_STRING(js, "type", "request");

Expand Down Expand Up @@ -171,7 +171,7 @@ void JsonDNP3LogRequest(JsonBuilder *js, DNP3Transaction *dnp3tx)
jb_close(js);
}

void JsonDNP3LogResponse(JsonBuilder *js, DNP3Transaction *dnp3tx)
static void JsonDNP3LogResponse(JsonBuilder *js, DNP3Transaction *dnp3tx)
{
if (dnp3tx->ah.function_code == DNP3_APP_FC_UNSOLICITED_RESP) {
JB_SET_STRING(js, "type", "unsolicited_response");
Expand Down
3 changes: 0 additions & 3 deletions src/output-json-dnp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

#include "app-layer-dnp3.h"

void JsonDNP3LogRequest(JsonBuilder *js, DNP3Transaction *);
void JsonDNP3LogResponse(JsonBuilder *js, DNP3Transaction *);

void JsonDNP3LogRegister(void);
bool AlertJsonDnp3(void *vtx, JsonBuilder *js);

Expand Down
Loading
Loading