util-enum.h \
util-error.h \
util-exception-policy.h \
+ util-exception-policy-types.h \
util-file-decompression.h \
util-file.h \
util-file-swf-decompression.h \
--- /dev/null
+/* Copyright (C) 2024 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
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+/**
+ * \file
+ */
+
+#ifndef UTIL_EXCEPTION_POLICY_TYPES_H
+#define UTIL_EXCEPTION_POLICY_TYPES_H
+
+enum ExceptionPolicy {
+ EXCEPTION_POLICY_NOT_SET = 0,
+ EXCEPTION_POLICY_AUTO,
+ EXCEPTION_POLICY_PASS_PACKET,
+ EXCEPTION_POLICY_PASS_FLOW,
+ EXCEPTION_POLICY_BYPASS_FLOW,
+ EXCEPTION_POLICY_DROP_PACKET,
+ EXCEPTION_POLICY_DROP_FLOW,
+ EXCEPTION_POLICY_REJECT,
+};
+
+#define EXCEPTION_POLICY_MAX EXCEPTION_POLICY_REJECT + 1
+
+/* Max length = possible exception policy scenarios + counter names
+ * + exception policy type. E.g.:
+ * "tcp.reassembly_exception_policy.drop_packet" + 1 */
+#define EXCEPTION_POLICY_COUNTER_MAX_LEN 44
+
+typedef struct ExceptionPolicyCounters_ {
+ /* Follows enum order */
+ uint16_t eps_id[EXCEPTION_POLICY_MAX];
+} ExceptionPolicyCounters;
+
+typedef struct ExceptionPolicyStatsSetts_ {
+ char eps_name[EXCEPTION_POLICY_MAX][EXCEPTION_POLICY_COUNTER_MAX_LEN];
+ bool valid_settings_ids[EXCEPTION_POLICY_MAX];
+ bool valid_settings_ips[EXCEPTION_POLICY_MAX];
+} ExceptionPolicyStatsSetts;
+
+#endif
-/* Copyright (C) 2022-2023 Open Information Security Foundation
+/* Copyright (C) 2022-2024 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
/** true if exception policy was defined in config */
static bool g_eps_have_exception_policy = false;
-static const char *ExceptionPolicyEnumToString(enum ExceptionPolicy policy)
+const char *ExceptionPolicyEnumToString(enum ExceptionPolicy policy, bool is_json)
{
switch (policy) {
case EXCEPTION_POLICY_NOT_SET:
case EXCEPTION_POLICY_BYPASS_FLOW:
return "bypass";
case EXCEPTION_POLICY_DROP_FLOW:
- return "drop-flow";
+ return is_json ? "drop_flow" : "drop-flow";
case EXCEPTION_POLICY_DROP_PACKET:
- return "drop-packet";
+ return is_json ? "drop_packet" : "drop-packet";
case EXCEPTION_POLICY_PASS_PACKET:
- return "pass-packet";
+ return is_json ? "pass_packet" : "pass-packet";
case EXCEPTION_POLICY_PASS_FLOW:
- return "pass-flow";
+ return is_json ? "pass_flow" : "pass-flow";
}
// TODO we shouldn't reach this, but if we do, better not to leave this as simply null...
return "not set";
}
g_eps_have_exception_policy = true;
- SCLogInfo("master exception-policy set to: %s", ExceptionPolicyEnumToString(policy));
+ SCLogInfo("master exception-policy set to: %s", ExceptionPolicyEnumToString(policy, false));
return policy;
}
p = PickPacketAction(option, p);
}
SCLogConfig("%s: %s (defined via 'exception-policy' master switch)", option,
- ExceptionPolicyEnumToString(p));
+ ExceptionPolicyEnumToString(p, false));
return p;
} else if (EngineModeIsIPS() && !midstream) {
p = EXCEPTION_POLICY_DROP_FLOW;
}
SCLogConfig("%s: %s (defined via 'built-in default' for %s-mode)", option,
- ExceptionPolicyEnumToString(p), EngineModeIsIPS() ? "IPS" : "IDS");
+ ExceptionPolicyEnumToString(p, false), EngineModeIsIPS() ? "IPS" : "IDS");
return p;
}
if (!support_flow) {
policy = PickPacketAction(option, policy);
}
- SCLogConfig("%s: %s", option, ExceptionPolicyEnumToString(policy));
+ SCLogConfig("%s: %s", option, ExceptionPolicyEnumToString(policy, false));
}
} else {
policy = ExceptionPolicyGetDefault(option, support_flow, false);
-/* Copyright (C) 2022-2023 Open Information Security Foundation
+/* Copyright (C) 2022-2024 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
#define SURICATA_UTIL_EXCEPTION_POLICY_H
#include "decode.h"
+#include "util-exception-policy-types.h"
-enum ExceptionPolicy {
- EXCEPTION_POLICY_NOT_SET = 0,
- EXCEPTION_POLICY_AUTO,
- EXCEPTION_POLICY_PASS_PACKET,
- EXCEPTION_POLICY_PASS_FLOW,
- EXCEPTION_POLICY_BYPASS_FLOW,
- EXCEPTION_POLICY_DROP_PACKET,
- EXCEPTION_POLICY_DROP_FLOW,
- EXCEPTION_POLICY_REJECT,
-};
-
+const char *ExceptionPolicyEnumToString(enum ExceptionPolicy policy, bool is_json);
void SetMasterExceptionPolicy(void);
void ExceptionPolicyApply(
Packet *p, enum ExceptionPolicy policy, enum PacketDropReason drop_reason);