pgpro_wrap — obfuscate PL/pgSQL code
pgpro_wrap [ -V | --version ] [ -? | --help ]
pgpro_wrap is the command-line utility that obfuscates the PL/pgSQL code to prevent unauthorized modifications of stored procedures and functions.
pgpro_wrap requires the OpenSSL and zlib libraries.
pgpro_wrap accepts a single input source file in
UTF-8 encoding, obfuscates its contents, and returns an output file with the
.wrap suffix. As a result, the PL/pgSQL
code cannot be viewed or edited directly using client tools such as
pgAdmin and remains obfuscated
in the pg_proc
system catalog.
However, output files can be executed normally without any additional steps.
To obfuscate a PL/pgSQL source file, specify the filename:
./pgpro_wrap file_name
The utility creates an output file named
in the current
directory. If this file already exists, pgpro_wrap
exits with an error to prevent accidental overwriting.
file_name.wrap
Once the file is obfuscated, you can load it into the database server or include it in an extension. The server automatically unwraps the code during function creation or script execution.
pgpro_wrap accepts the following command-line arguments:
-V--versionPrint the pgpro_wrap version and exit.
-?--helpShow help about pgpro_wrap and exit.
Be aware that the obfuscated PL/pgSQL code is displayed in plain text in the following system components:
server log files
pg_proaudit logs
statistics collected by pg_stat_statements and pgpro_stats
data provided by auto_explain
Therefore, pgpro_wrap should not be considered as a complete security solution, as the PL/pgSQL code can be viewed through these diagnostic tools.