mirror of
https://github.com/johndoe6345789/postgres.git
synced 2026-04-24 13:55:00 +00:00
Add password generator, Caprover deployment, and position as modern legacy tool replacement
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,8 @@ function validateSelectQuery(query: string): boolean {
|
||||
}
|
||||
|
||||
// Check for dangerous keywords (case insensitive)
|
||||
const dangerous = /;\s*(?:drop|delete|update|insert|alter|create|truncate|exec|execute)\s/i;
|
||||
// Includes common SQL modification commands and advanced features
|
||||
const dangerous = /;\s*(?:drop|delete|update|insert|alter|create|truncate|exec|execute|merge|call|with)\s/i;
|
||||
if (dangerous.test(trimmed)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,10 @@ export async function POST(request: Request) {
|
||||
);
|
||||
}
|
||||
|
||||
// Table name is validated, sanitize and use
|
||||
const safeTableName = String(tableName).replace(/\W/g, '');
|
||||
const result = await db.execute(sql.raw(`SELECT * FROM "${safeTableName}" LIMIT 100`));
|
||||
// Table name is validated against schema - safe to use the validated name
|
||||
// The validation query above ensures the table exists in the public schema
|
||||
const validatedTableName = (tablesResult.rows[0] as any).table_name;
|
||||
const result = await db.execute(sql.raw(`SELECT * FROM "${validatedTableName}" LIMIT 100`));
|
||||
|
||||
return NextResponse.json({
|
||||
rows: result.rows,
|
||||
|
||||
Reference in New Issue
Block a user