From 5b921c9a983b3f2588c0e151c28b26e45cf95f87 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Mon, 13 May 2024 22:49:34 +0500 Subject: feat: check if the message has sql injection --- src/utils/string.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/utils/string.cpp') diff --git a/src/utils/string.cpp b/src/utils/string.cpp index 9727f3f..b8ba269 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -1,5 +1,6 @@ #include "string.hpp" +#include #include #include #include @@ -48,6 +49,20 @@ namespace bot { return str; } + + bool string_contains_sql_injection(const std::string &input) { + std::string forbidden_strings[] = {";", "--", "'", "\"", + "/*", "*/", "xp_", "exec", + "sp_", "insert", "select", "delete"}; + + for (const auto &str : forbidden_strings) { + if (input.find(str) != std::string::npos) { + return true; + } + } + + return false; + } } } } -- cgit v1.2.3