Skip to content

Commit 9416ec4

Browse files
committed
fix: sanitized variables from apis to prevent sql injection
1 parent 33ef2e6 commit 9416ec4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/API/Manager.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ public function retrieve($request)
147147
$group = $response['group'];
148148
$module = $response['module'];
149149

150+
// Ottieni la lista dei campi di database dalla tabella con nome $table, e escludi da $select quelli non inclusi
151+
if (!empty($table)) {
152+
$database = database();
153+
$columns = $database->fetchArray('SHOW COLUMNS FROM `'.$table.'`');
154+
$column_names = array_column($columns, 'Field');
155+
$select = array_intersect($select, $column_names);
156+
}
157+
150158
if (!empty($response['where'])) {
151159
$where = array_merge($where, $response['where']);
152160
}

0 commit comments

Comments
 (0)