Skip to content

Commit df9cd90

Browse files
authored
Merge pull request #46 from okbob/1.7
1.7
2 parents aa18ef1 + 4e53098 commit df9cd90

31 files changed

+3614
-478
lines changed

META.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"name": "plpgsql_check",
33
"abstract": "Additional tools for plpgsql functions validation",
44
"description": "The plpgsql_check is PostgreSQL extension with functionality for direct or indirect extra validation of functions in plpgsql language. It verifies a validity of SQL identifiers used in plpgsql code. It try to identify a performance issues. Modern versions has integrated profiler. The table and function dependencies can be displayed",
5-
"version": "1.5.0",
5+
"version": "1.7.0",
66
"maintainer": "Pavel STEHULE <pavel.stehule@gmail.com>",
77
"license": "bsd",
88
"provides": {
99
"plpgsql_check": {
1010
"abstract": "Additional tools for plpgsql functions validation",
1111
"file": "sql/plpgsql_check_active.sql",
1212
"docfile": "README.md",
13-
"version": "1.5.0"
13+
"version": "1.7.0"
1414
}
1515
},
1616
"prereqs": {

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
MODULE_big = plpgsql_check
44
OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
5-
DATA = plpgsql_check--1.6.sql
5+
DATA = plpgsql_check--1.7.sql
66
EXTENSION = plpgsql_check
77

88
ifndef MAJORVERSION

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ google group.
2121
* detection of missing RETURN command in function
2222
* try to identify unwanted hidden casts, that can be performance issue like unused indexes
2323
* possibility to collect relations and functions used by function
24+
* possibility to check EXECUTE stmt agaist SQL injection vulnerability
2425

2526
I invite any ideas, patches, bugreports
2627

@@ -151,6 +152,9 @@ You can set level of warnings via function's parameters:
151152
declared type with type modificator, casting, implicit casts in where clause (can be
152153
reason why index is not used), ..
153154

155+
* `security_warnings boolean DEFAULT false` - security related checks like SQL injection
156+
vulnerability detection
157+
154158
## Triggers
155159

156160
When you want to check any trigger, you have to enter a relation that will be
@@ -183,6 +187,26 @@ Correct trigger checking (with specified relation)
183187
error:42703:3:assignment:record "new" has no field "c"
184188
(1 row)
185189

190+
For triggers with transitive tables you can set a `oldtable` or `newtable` parameters:
191+
192+
create or replace function footab_trig_func()
193+
returns trigger as $$
194+
declare x int;
195+
begin
196+
if false then
197+
-- should be ok;
198+
select count(*) from newtab into x;
199+
200+
-- should fail;
201+
select count(*) from newtab where d = 10 into x;
202+
end if;
203+
return null;
204+
end;
205+
$$ language plpgsql;
206+
207+
select * from plpgsql_check_function('footab_trig_func','footab', newtable := 'newtab');
208+
209+
186210
## Mass check
187211

188212
You can use the plpgsql_check_function for mass check functions and mass check

expected/plpgsql_check_active-10.out

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,28 @@ select * from plpgsql_check_function('f1()');
306306

307307
drop function f1();
308308
drop type _exception_type;
309+
create table footab(a int, b int, c int);
310+
create or replace function footab_trig_func()
311+
returns trigger as $$
312+
declare x int;
313+
begin
314+
if false then
315+
-- should be ok;
316+
select count(*) from newtab into x;
317+
318+
-- should fail;
319+
select count(*) from newtab where d = 10 into x;
320+
end if;
321+
return null;
322+
end;
323+
$$ language plpgsql;
324+
select * from plpgsql_check_function('footab_trig_func','footab', newtable := 'newtab');
325+
plpgsql_check_function
326+
-------------------------------------------------------
327+
error:42703:9:SQL statement:column "d" does not exist
328+
Query: select count(*) from newtab where d = 10
329+
-- ^
330+
(3 rows)
331+
332+
drop table footab;
333+
drop function footab_trig_func();

0 commit comments

Comments
 (0)