Skip to content

Commit 1710540

Browse files
committed
refactor: expand map_dialect_to_rust_int fn
to its natural habitat
1 parent c610261 commit 1710540

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

aikido_zen/vulnerabilities/sql_injection/map_dialect_to_rust_int.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

aikido_zen/vulnerabilities/sql_injection/zen_internal_ffi.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import ctypes
66
import threading
77
from .get_lib_path import get_binary_path
8-
from .map_dialect_to_rust_int import map_dialect_to_rust_int
98
from ...helpers.encode_safely import encode_safely
109

1110

@@ -21,6 +20,15 @@ def __call__(cls, *args, **kwargs):
2120

2221

2322
class ZenInternal(metaclass=__Singleton):
23+
# Reference : [rust lib]/src/sql_injection/helpers/select_dialect_based_on_enum.rs
24+
SQL_DIALECTS = {
25+
"generic": 0,
26+
"clickhouse": 3,
27+
"mysql": 8,
28+
"postgres": 9,
29+
"sqlite": 12,
30+
}
31+
2432
def __init__(self):
2533
self._lib = ctypes.CDLL(get_binary_path())
2634
self._lib.detect_sql_injection.argtypes = [
@@ -39,7 +47,7 @@ def detect_sql_injection(self, query, user_input, dialect):
3947
userinput_buffer = (ctypes.c_uint8 * len(userinput_bytes)).from_buffer_copy(
4048
userinput_bytes
4149
)
42-
dialect_int = map_dialect_to_rust_int(dialect)
50+
dialect_int = self.SQL_DIALECTS[dialect]
4351
return self._lib.detect_sql_injection(
4452
query_buffer,
4553
len(query_bytes),

0 commit comments

Comments
 (0)