This commit is contained in:
Benjamin Toby
2024-11-18 10:59:12 +01:00
parent 5d56d41624
commit ebb6141ec5
4 changed files with 19 additions and 35 deletions
@@ -94,6 +94,23 @@ async function runQuery({
.replace(/ {2,}/g, " ")
.trim();
/**
* Input Validation
*
* @description Input Validation
*/
if (
readOnly &&
(formattedQuery.match(
/^alter|^delete|information_schema|databases|^create/i
) ||
!formattedQuery.match(/^select|^\( ?select/i))
) {
throw new Error("Wrong Input!");
}
console.log("formattedQuery =>", formattedQuery);
if (local) {
const rawResults = await LOCAL_DB_HANDLER(
formattedQuery,