Oracle Forms support
Oracle Forms keeps its PL/SQL inside binary modules (.fmb, .mmb, .pll, .olb), out of reach of static analyzers.
To analyze it with ZPA, first extract the code and the metadata of the modules into plain files with
ZPA Forms Extractor, then analyze those files.
Extract the modules
ZPA Forms Extractor runs on a machine with Oracle Forms Builder installed, because it reads the modules through Oracle's
Forms API (JDAPI). Download it from the releases page and
follow the installation steps: it needs Java 8 or newer,
the frmjdapi.jar of your Forms installation and the native Forms libraries.
zpa-forms-extractor --input forms/ --output extracted/
Each module becomes a folder, for example extracted/orders.fmb/, with:
- one file per trigger, program unit, menu item and record group query, as compilable PL/SQL (
.tgg,.pks,.pkb,.pcd,.fun,.sql); - a
metadata.jsonfile describing the blocks, items, alerts, LOVs and parameters of the form, with the data type of each item and parameter.
ZPA 4.2.1 and older only read the legacy metadata format, without data types and parameters. For those versions, pass
--metadata-format legacy to the extractor; otherwise ZPA logs "Error reading the metadata file" and ignores it.
Analyze the extracted code
Analyze a module folder and pass its metadata.json as the Forms metadata.
-
ZPA CLI: its default extensions already include the extracted files.
zpa-cli --sources extracted/orders.fmb --forms-metadata extracted/orders.fmb/metadata.json -
SonarQube plugin: add the Forms extensions to the analyzed suffixes and set the metadata file:
sonar.sources=extracted/orders.fmbsonar.plsqlopen.file.suffixes=sql,pkg,pks,pkb,tgg,pcd,funsonar.zpa.forms.metadata=extracted/orders.fmb/metadata.json
ZPA reads one metadata file per analysis, so each form is checked against its own objects when analyzed separately.
What the metadata enables
Many Forms built-ins, such as GO_BLOCK, SET_ITEM_PROPERTY or SHOW_ALERT, receive the name of a block, item, alert
or LOV as a VARCHAR2. The Forms compiler doesn't check these names, so a typo only fails at runtime. With the
metadata, the InvalidReferenceToObject rule checks them against the objects that
exist in the form.
The data types let ZPA type host variables such as :EMPLOYEES.FIRST_NAME and :PARAMETER.P_ID from their items and
parameters, as it types PL/SQL variables, so rules that depend on types also understand code that uses them. :GLOBAL
variables are typed as VARCHAR2.
Without the metadata, the rules that need it are skipped. Providing it also tells ZPA that the code belongs to Forms modules, which turns off FunctionShouldBeDeterministic.
Metadata format
The metadata file lists the objects of the form. Each item can be a name or an object with its Forms data type (CHAR,
NUMBER, DATE, DATETIME, LONG…) and maximum length; each parameter is an object with a name and, optionally, a
data type:
{
"alerts": ["MY_ERROR", "MY_WARNING"],
"blocks": [
{
"name": "EMPLOYEES",
"items": [
{ "name": "EMPLOYEE_ID", "dataType": "NUMBER" },
{ "name": "FIRST_NAME", "dataType": "CHAR", "maxLength": 30 },
"PHOTO"
]
}
],
"lovs": ["LIST_OF_EMPLOYEES"],
"parameters": [{ "name": "P_ID", "dataType": "NUMBER" }]
}
The legacy format, the only one read by ZPA 4.2.1 and older, has only names: items as strings and no parameters. You
can also write this file by hand if you can't run the extractor.