Skip to content

feat: enable security_warnings in plpgsql_check - #86

Merged
AndrewJackson2020 merged 1 commit into
mainfrom
plpgsql_check_security_warnings
Nov 14, 2026
Merged

AndrewJackson2020 merged 1 commit into
mainfrom
plpgsql_check_security_warnings

Conversation

@AndrewJackson2020

@AndrewJackson2020 AndrewJackson2020 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

This PR sets security_warnings=>TRUE during the invocation of plpgsql_check_function_tb in the regression test. This setting allows us to pick up many (but not all) SQL injection vulnerabilites. There are none in this repo currently that need to be fixed as EXECUTE/dynamic SQL is never even used. Nonetheless this is a good check to role out across the board. If there was an issue the regression.diffs would look something like the below.

https://github.com/okbob/plpgsql_check/blob/b190a63547237b595a1fd0ae2071cf3d60061523/README.md?plain=1#L157

diff -U3 /Users/aj/Repos/mono/external/repos/supabase/vault/main/test/expected/test.out /Users/aj/Repos/mono/external/repos/supabase/vault/main/results/test.out
--- /Users/aj/Repos/mono/external/repos/supabase/vault/main/test/expected/test.out	2026-11-13 12:01:39.496649596 -0600
+++ /Users/aj/Repos/mono/external/repos/supabase/vault/main/results/test.out	2026-11-13 12:14:27.289888115 -0600
@@ -153,9 +153,10 @@
     OFFSET 0
 ) ss
 ORDER BY (pcf).functionid::regprocedure::text, (pcf).lineno;
-                  functionid                   | lineno | statement | sqlstate |            message            | detail | hint |     level     | position | query | context
------------------------------------------------+--------+-----------+----------+-------------------------------+--------+------+---------------+----------+-------+---------
- vault.create_secret(text,text,text,uuid)      |        |           | 00000    | unused parameter "new_key_id" |        |      | warning extra |          |       |
- vault.update_secret(uuid,text,text,text,uuid) |        |           | 00000    | unused parameter "new_key_id" |        |      | warning extra |          |       |
-(2 rows)
+                     functionid                     | lineno | statement | sqlstate |               message               |                       detail                        |                                 hint                                  |     level     | position |                             query                              | context
+----------------------------------------------------+--------+-----------+----------+-------------------------------------+-----------------------------------------------------+-----------------------------------------------------------------------+---------------+----------+----------------------------------------------------------------+---------
+ vault.create_secret(text,text,text,uuid)           |        |           | 00000    | unused parameter "new_key_id"       |                                                     |                                                                       | warning extra |          |                                                                |
+ vault.update_secret(uuid,text,text,text,uuid,text) |     17 | EXECUTE   | 00000    | text type variable is not sanitized | The EXECUTE expression is SQL injection vulnerable. | Use quote_ident, quote_literal or format function to secure variable. | security      |       46 | format('UPDATE vault.secrets SET %s = $1 ;', description_cal ) |
+ vault.update_secret(uuid,text,text,text,uuid,text) |        |           | 00000    | unused parameter "new_key_id"       |                                                     |                                                                       | warning extra |          |                                                                |
+(3 rows)

@AndrewJackson2020
AndrewJackson2020 marked this pull request as ready for review November 13, 2026 18:16
@AndrewJackson2020
AndrewJackson2020 requested a review from a team as a code owner November 13, 2026 18:16
@AndrewJackson2020
AndrewJackson2020 merged commit ac10cdc into main Nov 14, 2026
24 of 25 checks passed
@AndrewJackson2020
AndrewJackson2020 deleted the plpgsql_check_security_warnings branch November 14, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants