mirror of https://github.com/OISF/suricata
suricatasc: Snug the processing of different commands
Since all of the commands were following the same procedure, namely, split the input extract the arguments, throw the error if required argument is missing else send the command over to suricata, put all of this in one compact function alongwith a dictionary for specifications for different commands, the name of the argument, the type and if it is required or not. Following fixups come with this commit: - Code becomes really cozy - Split errors on a few commands are well handled - No redundant code - More readability References redmine ticket #2793pull/3661/head
parent
57285b54d5
commit
bf37e3f5da
@ -0,0 +1,162 @@
|
||||
argsd = {
|
||||
"pcap-file": [
|
||||
{
|
||||
"name": "filename",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "output-dir",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "tenant",
|
||||
"type": int,
|
||||
"required": 0,
|
||||
},
|
||||
{
|
||||
"name": "continuous",
|
||||
"required": 0,
|
||||
},
|
||||
{
|
||||
"name": "delete-when-done",
|
||||
"required": 0,
|
||||
},
|
||||
],
|
||||
"pcap-file-continuous": [
|
||||
{
|
||||
"name": "filename",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "output-dir",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "tenant",
|
||||
"type": int,
|
||||
"required": 0,
|
||||
},
|
||||
{
|
||||
"name": "delete-when-done",
|
||||
"required": 0,
|
||||
},
|
||||
],
|
||||
"iface-stat": [
|
||||
{
|
||||
"name": "iface",
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"conf-get": [
|
||||
{
|
||||
"name": "variable",
|
||||
"required": 1,
|
||||
}
|
||||
],
|
||||
"unregister-tenant-handler": [
|
||||
{
|
||||
"name": "tenantid",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "htype",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "hargs",
|
||||
"type": int,
|
||||
"required": 0,
|
||||
},
|
||||
],
|
||||
"register-tenant-handler": [
|
||||
{
|
||||
"name": "tenantid",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "htype",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "hargs",
|
||||
"type": int,
|
||||
"required": 0,
|
||||
},
|
||||
],
|
||||
"unregister-tenant": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": int,
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"register-tenant": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": int,
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "filename",
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"reload-tenant": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": int,
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "filename",
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"add-hostbit": [
|
||||
{
|
||||
"name": "ipaddress",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "hostbit",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "expire",
|
||||
"type": int,
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"remove-hostbit": [
|
||||
{
|
||||
"name": "ipaddress",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "hostbit",
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"list-hostbit": [
|
||||
{
|
||||
"name": "ipaddress",
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"memcap-set": [
|
||||
{
|
||||
"name": "config",
|
||||
"required": 1,
|
||||
},
|
||||
{
|
||||
"name": "memcap",
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
"memcap-show": [
|
||||
{
|
||||
"name": "config",
|
||||
"required": 1,
|
||||
},
|
||||
],
|
||||
}
|
Loading…
Reference in New Issue