mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
fix(db): refuse the column notation without parentheses and aclitem in plugin SQL
Postgres reads x.f as the call f(x) when x has no column f. The guard counted that spelling only after ")." or "].", so over a function in FROM that returns a single value, or a parameter, the allowlist was bypassed: "select g.obj_description from generate_series(...) g" returned the comments on every object of the database, and g.current_schemas, g.txid_status and $1.ts_token_type passed as well. A refused catalog function after a dot is now refused too, except the names in COLUMN_NAMES (money, name, oid, version, xid, xml), which take no argument or only convert it to their type, so t.name keeps working. PGPLUG-021 holds that list to pg_proc on the lane's server. The type aclitem names roles: '=r'::aclitem printed the cluster's first superuser and 'x=r/x'::aclitem told whether a role exists. It is refused in every spelling like the reg* types. The allowlist itself moves to assets/postgres/plugin-functions.txt, beside the catalog list it is checked against. As TypeScript it spelled 'like' and 'json_each', names of Postgres functions that the SQLite dialect gate reads as SQLite SQL.
This commit is contained in:
@@ -200,6 +200,12 @@ describe('plugin SQL guard', () => {
|
||||
["select currtid2('public.users', '(0,1)')", /"currtid2" may not be named/],
|
||||
["select gin_clean_pending_list('public.users_idx')", /"gin_clean_pending_list" may not be named/],
|
||||
["select to_regtype('int4')", /"to_regtype" may not be named/],
|
||||
// aclitem looks its roles up by name and names them in its output.
|
||||
["select '=r'::aclitem", /"aclitem" may not be named/],
|
||||
["select cast('x=r/x' as aclitem)", /"aclitem" may not be named/],
|
||||
[`select array['=r']::"aclitem"[]`, /"aclitem" may not be named/],
|
||||
["select '{=r}'::_aclitem", /"_aclitem" may not be named/],
|
||||
['CREATE TABLE grants (a aclitem)', /"aclitem" may not be named/],
|
||||
// A base type is built from C functions, which only a superuser may do.
|
||||
['CREATE TYPE fake (INPUT = int4in, OUTPUT = int4out, INTERNALLENGTH = 1000)', /composite, enum or range/],
|
||||
// The protocol ends a statement's text at a NUL, in a string as anywhere else.
|
||||
|
||||
Reference in New Issue
Block a user