Hide Pl/Sql source code

To hide PlSql source code you can use both:
  • dynamic obfuscation
  • the wrap utility
You might have to wrap some of yours PlSql objects just to provide the security of your code.
Once wrapped, your code can’t be displayed from the static data dictionary views [ *_SOURCE ].
You can wrap the following types of PlSql objects
  • Package specification
  • Package body
  • Type specification
  • Type body
  • Function
  • Procedure
However there are some utilities that you can use to read wrapped code, so it is not considered an high-security method to protect your code.
Some limitations are
  • wrapped files are not downward compatible between releases
  • you can’t use this technique with triggers
Some guidelines are
  • if you want to wrap a package or a type , wrap only the body and not the specification
  • once you have wrapped a file, you can’t turn back, be sure you have finished editing the file before wrapping it
  • always check your wrapped file before distributing
The PLSQL wrapper utility takes a single SQL file and produces an equivalent text file in which the PLSQL source text of each wrappable PLSQL unit is wrapped.
The utility is an executable file run from the OS command line, below we can see an example of this command
wrap iname=input_file [ oname=output_file ]
The input_file is the name of the file that contains the PLSQL code, the output_file is the name of the file that will be created.
The default file extention for the input file is .sql, the default name of the output file is input_file.plb.
The output_file can be run as a script in SQL* Plus.
DBMS_DDL
There are two subprograms that produce wrapped output:
  • DBMS_DDL.WRAP
  • DBMS_DDL.CREATE_WRAPPED
DBMS_DDL.WRAP
This functions takes as input a CREATE OR REPLACE statement that specifies creation of a package body, function, ecc. and returns a CREATE OR REPLACE statement where the plsql code has been obfuscated
DBMS_DDL.CREATE_WRAPPED
This function does the same operation of the function explained before, but it also execute the generated statement.
(Study Guide for 1Z0-144: Oracle Database 11g: Program with PL/SQL: Oracle Certification Prep Paperback) by Matthew Morris

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *