Fortify Source Code Analyzer User's Guide: August 2008
Fortify Source Code Analyzer User's Guide: August 2008
User’s Guide
Version 5.2
August 2008
Copyright © 2003-2008 Fortify® Software, Inc.August 29, 2008 4:49 pm
All Rights Reserved. Printed in the United States of America.
Fortify Software, Inc. ("Fortify") and its licensors retain all ownership rights to this document (the "Document"). Use of
the Document is governed by applicable copyright law. Fortify may revise this Document from time to time without
notice.
THIS DOCUMENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN NO EVENT SHALL FORTIFY BE
LIABLE FOR INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY KIND ARISING FROM
ANY ERROR IN THIS DOCUMENT, INCLUDING WITHOUT LIMITATION ANY LOSS OR INTERRUPTION OF
BUSINESS, PROFITS, USE OR DATA. FORTIFY RESERVES THE RIGHT TO MODIFY OR REMOVE ANY OF THE
FEATURES OR COMPONENTS DESCRIBED IN THIS DOCUMENT FROM THE FINAL PRODUCT, WITHOUT
NOTICE.
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Using the Log File to Debug Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Translation Failed Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
JSP Translation Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
ASPX Translation Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
C/C++ Precompiled Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Reporting Bugs and Requesting Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Appendix A: Managing Per Use Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
If you have questions or comments about any part of this guide, contact Fortify at:
Technical Support
650.358.5679
Corporate Headquarters
Suite 400
650.358.5600
Web Site
http://www.fortify.com
Rules are organized according to the analyzer that uses them, resulting in rules that are specific to
the data flow, control flow, semantic, structural, and configuration analyzers. The high-level rule
types are further divided to reflect the category of the issue or type of information represented by the
rule.
For information on the various types of rules and their respective uses, see the Secure Coding
Rulepack Reference.
The following table lists and describes each Fortify source code analyzer.
Analyzer Description
Data Flow The data flow analyzer detects potential vulnerabilities that involve
tainted data (user-controlled input) put to potentially dangerous use.
The data flow analyzer uses global, inter-procedural taint propagation
analysis to detect the flow of data between a source (site of user input)
and a sink (dangerous function call or operation). For example, the
data flow analyzer detects whether a user-controlled input string of
unbounded length is being copied into a statically-sized buffer, and
detects whether a user controlled string is being used to construct SQL
query text.
Control Flow The control flow analyzer detects potentially dangerous sequences of
operations. By analyzing control flow paths in a program, the control
flow analyzer determines whether a set of operations are executed in a
certain order. For example, the control flow analyzer detects time of
check/time of use issues and uninitialized variables, and checks
whether utilities, such as XML readers, are configured properly before
being used.
Note: You can run the scan in silent mode, which suppresses the prompt and automatically deducts
lines, by using the command line option, -auth-silent, or by setting the
com.fortify.sca.PPSilent property to true.
Memory Considerations
By default, Fortify SCA uses up to 600 MB of memory. If this is not sufficient to analyze a particular
code base, you might have to provide more memory in the scan phase. This can be done by passing
the -Xmx option to the sourceanalyzer command.
For example, to make 1000 MB available to Fortify SCA, include the option -Xmx1000M.
You can also use the SCA_VM_OPTS environment variable to set the memory allocation.
Note: Do not allocate more memory for Fortify SCA than the machine has available, because this
will degrade performance. As a guideline, assuming that no other memory-intensive processes are
running, do not allocate more than 2/3 of the available physical memory.
Translation Phase
The basic command line syntax for performing the first analysis phase, translating the files, is:
At the end of translation, you can use -show-build-warnings to list all warnings and errors that
were encountered during the translation process:
sourceanalyzer -auth-query
For translated projects, display the total number of lines required to analyze the project using the
-show-loc option. Fortify SCA counts lines of code (LOC) in a project that are executable, and
excludes lines such as comments and blank lines. The command to display the number of lines is:
Analysis Phase
This topic describes the syntax for the analysis phase: scanning the intermediate files created during
the translation and creating the analysis results file. The phase consists of one invocation of
sourceanalyzer. You specify the build ID and include the -scan directive and any required analysis
or output options.
Note: By default, Fortify SCA includes the source code in the FPR.
The basic command line syntax for the analysis phase is:
The command line syntax to silently analyze a project for Fortify SCA with a per use license is:
This runs the scan without the prompt to deduct the lines. For more information about the command
line options, see “Command Line Interface” on page 39.
Note: You can re-scan a set of translated files. This allows you to scan the same project with
different rules, updated rulepacks, and/or scan settings without using additional scan lines.
With Java code, Fortify SCA can either emulate the compiler, which may be convenient for build
integration, or accept source files directly, which is more convenient for command line scans.
Note: For a description of all the options you can use with the sourceanalyzer command, see
“Command Line Interface” on page 39.
where:
<translation options>
-cp <classpath>
specifies the classpath to be used for the Java source code. A classpath is a list of build directories
and jar files. The format is the same as expected by javac (colon or semicolon-separated list of
paths). You can use Fortify SCA file specifiers.
-cp "build/classes:lib/*.jar"
Note: If you do not specify the classpath with this option, the CLASSPATH environment variable is
used.
For more information, see “Java/J2EE Options” on page 41. For information about file specifiers,
see “Specifying Files” on page 45.
To translate all .java files in the src directory using all jar files in the lib directory as a classpath:
To translate and compile the MyCode.java file while using the javac compiler:
ant -Dbuild.compiler=com.fortify.dev.ant.SCACompiler
-Dsourceanalyzer.buildid=MyBuild
-lib <install_dir>/Core/lib/sourceanalyzer.jar
The -lib option is only available in Ant version 1.6 or higher. In older versions you must set the
CLASSPATH environment variable or copy sourceanalyzer.jar to Ant's lib directory.
Alternatively, with Ant 1.6 or newer, the following shorthand can be used to run Ant with the compiler
adapter:
ant -Dbuild.compiler=com.fortify.dev.ant.SCACompiler
-Dsourceanalyzer.buildid=MyBuild
-lib <install_directory>/Core/lib/sourceanalyzer.jar
-Dsourceanalyzer.maxHeap=1000M
If your JSP files use any tag libraries, such as JSTL, ensure that the libraries’ jar files are in the
WEB-INF/lib directory. Otherwise, the JSP compiler will not resolve the tag libraries and could
produce incorrect results.
By default, Fortify SCA uses a version of the Jasper JSP compiler to compile JSP files into Java files
during the translation phase. However, if your web application is developed specifically for an
application server, you must use the JSP compiler for that application server when performing the
translation.
To support this, Fortify SCA provides the following command line options:
For example:
• servlet tags
• servlet-mapping tags
• filter tags
• filter-mapping tags
• error-page tags
These tags are used to determine how the servlets and filers defined in the .java and .jsp files
are connected.
If a struts servlet is detected, Fortify SCA extracts the configuration file to process the following top-
level tags:
• form-beans
• global forwards
• action mappings
Call Graph
Using data from the XML and struts configuration files, Fortify SCA builds a call graph to track
potential taint from servlet to servlet and to struts actions. For information about what is extracted
from the configuration files, see “XML Configuration Files” on page 11.
Java Warnings
You may see the following warnings for Java:
These warnings are typically caused by missing resources. For example, some of the .jar and
class files required to build the application have not been specified. To resolve the warnings, make
sure that you have included all of the required files that your application uses.
J2EE Warnings
You may see the following warnings for J2EE applications:
Could not locate the root (WEB-INF) of the web application. Please build
your web application and try again. Failed to parse the following jsp
files:
This warning displays because your Web application is not deployed in the standard WAR directory
format or does not contain the full set of required libraries. To resolve the warning, ensure that your
web application is in an exploded WAR directory format with the correct WEB-INF/lib and WEB-
INF/classes directories containing all of the .jar and .class files required for your application.
You should also verify that you have all of the TLD files for all of the tags that you have and the
corresponding .jar files with their tag implementations.
Using FindBugs
FindBugs (http://findbugs.sourceforge.net) is a static analysis tool that detects quality issues in Java
code. You can run FindBugs with Fortify SCA and the results will be integrated into the analysis
results file. Unlike Fortify SCA, which runs on Java source files, FindBugs runs on Java bytecode.
To demonstrate how to run FindBugs automatically with Fortify SCA, compile the sample code,
Warning.java, as follows:
The following example demonstrates the command line syntax for Visual Studio .NET:
This performs the translation phase on all files built by Visual Studio. Be sure to do a clean or a
rebuild so that all files are included. You can then perform the analysis phase, as in the following
example:
Prepare your application for analysis using one of the following methods:
• Perform a complete rebuild of your project with the "debug" configuration enabled, using either
the Visual Studio IDE plug-in for Audit Workbench or the command line. Compiling your project
with debug enabled provides information that Fortify SCA uses for presenting the results.
• Obtain all of the third party .dll files, project output .dll files, and corresponding .pbd files
for your projects. Note that Fortify SCA ignores any .dll file passed as an input argument if the
corresponding .pdb file does not exist in the same folder. It is therefore imperative that you
include all of the .pdb files for all your project .dll files.
Note: .pdb files are not required for third party libraries.
Run Fortify SCA to analyze the .NET application from the command line as follows:
To facilitate the .aspx compilation phase, Fortify Software provides a simple tool that compiles all
of the .aspx files in your project. The tool is located in the Fortify installation directory at:
\Tools\fortify_aspnet_compiler\fortify_aspnet_compiler.exe
.NET Warnings
You may see the following warnings for .NET:
Cannot locate class... in the given search path and the Microsoft .NET
Framework libraries.
These warnings are typically caused by missing resources. For example, some of the .DLL files
required to build the application have not been specified. To resolve the warnings, make sure that
you have included all of the required files that your application uses. If you still see a warning and
the classes it lists are empty interfaces with no members, you can ignore the warning. If the interface
is not empty, contact Technical Support.
ASP.NET Warnings
You may see the following warnings for ASP.NET applications:
This warning displays because your Web application is not deployed correctly or does not contain
the full set of required libraries, or it uses the Global Access Cache (GAC). If your application is a
.NET version 1.1 application, you may also have access issues from Microsoft IIS. Verify that you
can access the application from a browser without authentication or access errors. If your web
application uses the GAC, you must add the .DLL files to the project separately to ensure a
successful scan. Fortify SCA does not load .DLL files from the GAC.
where:
• <compiler> is the name of the compiler you want to use during a project build scan, such as
gcc or cl.
• <compiler options> are options passed to the compiler that are typically used to compile
the file.
Fortify SCA runs the make command. When make invokes any command that Fortify SCA
determines is a compiler, the command is processed by Fortify SCA. Note that the makefile is not
modified.
For information about informing Fortify SCA about specially-named compilers, see the
com.fortify.sca.compilers.* property in “Using Properties to Control Runtime Options” on
page 55.
This method of build integration is not limited to make. Any build command that executes a compiler
process can be used with this system; just replace the 'make' section of the above command with
the command used to run a build.
Note: The Fortify touchless build adapter does not function correctly if:
• The build script invokes the compiler with an absolute path or if the build script overrides the
executable search path.
• The build script does not create a new process to run the compiler. Many Java build tools,
including Ant, operate this way.
CC=gcc
CXX=g++
AR=ar
The step can be as simple as prepending these tool references in the makefile with Fortify SCA and
the appropriate options:
Option Description
Monitor Enables the monitoring. Build Monitor intercepts and translate the next
build on the machine.
Scan Scans the code that was monitored during the build.
Set Results Folder Controls where Fortify SCA outputs the results.
Stay on Top Keeps the Fortify Build Monitor window on top of other windows.
Minimize to Tray Shows the Fortify Build Monitor as an icon in the task bar.
Show Messages Shows or hides the messages in the lower area of the window.
Messages include Scan Messages, Errors, and Monitor Driver
information. You can click Detailed Messages at the bottom of the
window.
Option Description
• Allocate memory: Increase or decrease the amount of memory allocated to Fortify SCA
• Secure Coding Rulepacks and custom rulepacks: Change which rulepacks Fortify SCA
uses to analyze the source code
• User: Only monitor builds run by the current user
To change the scan options:
Monitoring Builds
For C/C++ projects and solutions on Windows, Fortify SCA includes the Fortify Build Monitor, which
is a graphical user interface tool that automates analysis during builds.
1. Select Start - Program Files - Fortify Software - Fortify SCA - Build Monitor.
Note: To view the results, open the FPR file in Audit Workbench or using the Secure Coding
Package for Microsoft Visual Studio.
1. Using Microsoft Visual Studio, open and build the qwik-smtpd project located in the
Tutorial/C/source directory.
2. Select Start - Program Files - Fortify Software - Fortify SCA - Build Monitor.
3. Click Monitor.
4. Minimize the window.
5. In Microsoft Visual Studio, rebuild the project.
Note: Since nothing in the project changed, you must use the rebuild option.
6. Check that build has finished successfully.
7. Return to the Fortify Build Monitor window and click Build Done.
8. Specify the location of the build output.
9. Click Scan.
Fortify SCA saves an FPR file in the folder you specified.
Note: To view the results, open the FPR file in Audit Workbench or using the Secure Coding
This performs the translation phase on all files built by Visual Studio. Be sure to do a clean or a
rebuild so that all files are included.
This performs the translation phase on all files built by the Visual Studio. Be sure to do a clean or a
rebuild so that all files are included, as described in your Visual Studio documentation.
where:
For a description of all the options you can use with the sourceanalyzer command, see
“Command Line Interface” on page 39.
<dirname> All files found under the named directory or any subdirectories
<dirname>/**/ Any file named Example.js found under the named directory
Example.js or any subdirectories
<dirname>/*.js Any file with the extension .js found in the named directory
<dirname>/**/*.js Any file with the extension .js found under the named
directory or any subdirectories
<dirname>/**/* All files found under the named directory or any subdirectories
(same as <dirname>)
Configuration Considerations
This section covers the following topics:
<!--include virtual=”/myweb/foo.inc”>
Specify the physical location of the myweb application by passing the following property value:
For example, if the IIS virtual root /myweb is located at C:\webapps\myweb-folder, then your
property value should be:
-Dcom.fortify.sca.ASPVirtualRoots=c:\webapps\myweb-folder
If you add this line to the fortify-sca.properties file, you must escape the \ character, as follows:
com.fortify.sca.ASPVirtualRoots=c:\\webapps\\myweb-folder
The following example demonstrates how to translate all T-SQL files under the sources directory:
The following example demonstrates how to translate all CFML files under the
C:\MySite directory:
• Supported Technologies
• Preparing COBOL Source Files for Translation
• COBOL Command Line Syntax
• Auditing a COBOL Scan
Supported Technologies
Fortify SCA supports IBM Enterprise COBOL for IBM z/OS and is compatible with the following
systems:
• CICS
• IMS
• DB/2 embedded SQL
• IBM WebSphere MQ
The basic syntax for scanning a translated free-format COBOL program is:
Fortify SCA does not currently support custom rules for COBOL applications.
• Troubleshooting
• Reporting Bugs and Requesting Enhancements
Troubleshooting
This section contains the following troubleshooting topics:
to
com.fortify.sca.cpfe.options=-w --remove_unneeded_entities --
suppress_vtbl
Re-run the build to print the errors encountered by the translator. If the output indicates an
incompatibility between your compiler and the Fortify translator, send your output to Fortify Technical
Support for further investigation.
If the JSP parser encounters problems when Fortify SCA is converting JSP files to Java files for
analysis, you will see a message similar to the following:
Failed to translate the following jsps into analysis model. Please see the
log file for any errors from the jsp parser and the user manual for hints
on fixing those
<List of JSP file names>
• The web application is not laid out in a proper deployable WAR directory format
• You are missing some JAR files or classes required for the application
• Some tag libraries or their definitions (TLD) are missing from your application
To obtain more information about the problem, perform the following steps:
For more information about scanning J2EE applications, see “Translating J2EE Applications” on
page 10.
• If you are using .NET 2.0 or later and Visual Studio 2005, using the Microsoft aspnet_compile
compiler
• If you are using .NET 1.1 and Visual Studio 2003, trying to fetch ASPX files one at a time from
the web site
The compilation step can fail if:
• You have access or authentication problems with accessing the web application
• You are missing some required DLLs
In either case, you will see a message similar to the following:
Failed to translate the following aspx files into analysis model. Please
see the log file for any errors from the aspx precompiler and the user
manual for hints on fixing those.
<List of ASPX file names>
If you are using the plug-in, enable plug-in debugging and examine the plug-in log file for any errors
generated by the ASPX precompiler.
If you are using the command line tool, fortify_aspnet_compiler, you should see the error
messages on the console.
If you still cannot determine the cause of the problem, try to access some of the failed ASPX files
from your browser and see what kind of errors display. If you see messages such as cannot
locate assembly, ensure that you have the missing DLLs and rerun Fortify SCA.
If you can access the failed ASPX files from the browser, but Fortify SCA still fails to scan it, contact
Fortify Technical Support for additional help.
For more information about scanning ASP.NET applications, see “Translating ASP.NET 1.1 (Visual
Studio Version 2003) Projects” on page 16.
If you use the precompiled header feature of your compiler, make sure your source code compiles
cleanly by disabling precompiled headers and doing a full build.
Fortify SCA deducts lines for each project you analyze. When you run out of lines, you must get
additional lines before you can scan another project. Transferring lines and creating a request file for
transfers requires the following:
The Per User Portal administrator configures the user accounts and provides the Fortify SCA Per
Use edition license key. When the administrator sets up an account, the default password is
automatically emailed to you.
Transferring Lines
This section explains how to transfer lines from the Per Use Portal account to Fortify SCA. The
following is required to transfer lines:
After the transfer, the per use account shows the lines allocated. The local client shows the lines as
available.
To request lines:
After the response file is created, the account shows the lines as allocated. However the lines are
not available on Fortify SCA until after the response file is downloaded and installed.
• Output Options
• Analysis Options
• ColdFusion Option
• Java/J2EE Options
• .NET Options
• Build Integration Options
• Runtime Options
• Line Transfer Options
• Other Options
If you are using the ANT sourceanalyzer task, a subset of command line options is available. For
information about these options and their syntax, see “sourceanalyzer Task Options” on page 49.
Output Options
The following table describes the output options.
-append Appends results to the file specified with -f. If this option is
not specified, Fortify SCA overwrites the file. To use this
option, the output file format must be .fpr or .fvdl. For
information on the -format output option, see the
description in this table.
-build-label <label> The label of the project being scanned. The label is not used
by Fortify SCA but is included in the analysis results.
-build-project <project> The name of the project being scanned. The name is not
used by Fortify SCA but is included in the analysis results.
-build-version <version> The version of the project being scanned. The version is not
used by Fortify SCA but is included in the analysis results.
-f <file> The file to which results are written. If you do not specify an
output file, the output is written to the terminal.
-format <format> Controls the output format. Valid options are fpr, fvdl,
text, and auto. The default is auto, which selects the
output format based on the file extension.
Note: If you are using result certification, you must specify
the fpr format. See the Audit Workbench User’s Guide for
information on result certification.
Analysis Options
The following table describes the analysis options.
-filter <file_name> Specifies a results filter file. For information about filter files,
see “Creating a Filter File” on page 53.
-findbugs Enables FindBugs analysis for Java code. The Java class
directories must have been specified with the -java-
build-dir option, described in “Java/J2EE Options” on
page 41.
-no-default-rules Specifies not to load rules from the default rulepacks. Fortify
SCA processes the rulepacks for description elements and
language libraries, but no rules are processed.
-quick Scans the project in Quick Scan Mode, using the fortify-
sca-quickscan.properties file. By default, this scan
searches for high-confidence, high-severity issues. For
more information about Quick Scan Mode, see the Audit
Workbench User’s Guide.
-source-archive Use with Fortify Team Server, renders source files into a
<archive_file.zip> separate archive rather than including them in the FPR file.
ColdFusion Option
The following table describes the ColdFusion option.
Java/J2EE Options
The following table describes the Java/J2EE options.
-cp <classpath>, Specifies the classpath to use for analyzing Java source
-classpath <classpath> code. The format is same as javac: a colon or semicolon-
separated list of paths. You can use Fortify SCA file
specifiers.
Note: If you do not specify the classpath with this option, the
CLASSPATH environment variable is used.
-source <version> Indicates which version of the JDK the Java code is written
for. Valid values for version are 1.3, 1.4, 1.5, and 1.6.
The default is 1.4.
.NET Options
The following table describes the .NET options.
-vsversion <version> Specifies Visual Studio version. Valid values for version
are 7.1 for Visual Studio Version 2003 and 8.0 for Visual
Studio Version 2005, and the default value is 7.1.
-b <build_id> Specifies the build ID. The build ID is used to track which
files are compiled and combined to be part of a build and
later to scan those files.
-bin <binary> Used with -scan to specify a subset of source files to scan.
Only the source files that were linked in the named binary at
build time are included in the scan. Can be used multiple
times to specify the inclusion of multiple binaries in the scan.
Directives
The following directives can be used to list information about translation steps that have been taken.
Only one directive can be used at a time and cannot be used in conjunction with normal translation
or analysis steps.
Table 10:
Directives Description
-show-binaries Displays all objects that were created but not used
in the production of any other binaries. If fully
integrated into the build, it lists all of the binaries
produced.
Directives Description
-show-build-tree Displays all files used to create binary and all files
used to create those files in a tree layout. If the -
bin binary option is not present, the tree is
displayed for each binary.
Note: This option can generate an extensive
amount of information.
-show-files Lists the files in the specified build ID. When the -
bin option is present, displays only the source files
that went into the binary.
Runtime Options
The following table describes the runtime options.
-64 Runs Fortify SCA under the 64-bit JRE. If no 64-bit JRE is
available, Fortify SCA fails.
-logfile <file_name> Specifies the log file that is produced by Fortify SCA.
Option Description
Other Options
The following table describes other options.
-encoding Specifies the source file encoding type. This option is the
<encoding_name> same as the javac encoding option.
Specifying Files
File specifiers are expressions that allow you to easily pass a long list of files to Fortify SCA using
wildcard characters. Fortify SCA recognizes two types of wildcard characters: '*' matches part of a
<dirname> All files found under the named directory or any subdirectories
<dirname>/*.java Any file with the extension .java found in the named
directory
<dirname>/**/*.java Any file with the extension .java found under the named
directory or any subdirectories
<dirname>/**/* All files found under the named directory or any subdirectories
(same as dirname)
Note: Windows and many Unix shells automatically try to expand arguments containing the '*'
character, so file-specifier expressions should be quoted. Also, on Windows, the backslash
character (\) may be used as the directory separator instead of the forward slash (/).
This section describes how to use the sourceanalyzer Ant task and provides an example of a
sample build file with a self-contained analysis target.rs. It contains the following topics:
The first step to using the sourceanalyzer task is to include a typedef in the build.xml file as
follows:
<typedef name="sourceanalyzer"
classname="com.fortify.dev.ant.SourceanalyzerTask"/>
Note: Only Ant 1.6 and higher supports top-level typedef of the sourceanalyzer task. For Ant 1.5
and lower, include the typedef in the target where the sourceanalyzer task is used.
Once this typedef is included, targets can be defined that invoke the sourceanalyzer task to
perform translation and analysis operations exactly as if running sourceanalyzer from the
command line. The sourceanalyzer task syntax is similar to that of the command line interface,
but Ant fileset and path primitives can be leveraged.
The following is an example of a snippet from an Ant build.xml file which provides a target users
can call to generate Fortify SCA results for the project. This snippet assumes that the targets clean
and compile and the path jsp.classpath are defined elsewhere in the file. It also uses verbose
and log to create a separate Fortify SCA log file for the build.
<available classname="com.fortify.dev.ant.SourceanalyzerTask"
property="fortify.present"/>
<property name="sourceanalyzer.buildid" value="mybuild"/>
<!-- For debugging in a separate Fortify SCA log file -->
<property name="fortify.debug" value="false" />
<property name="fortify.verbose" value="false" />
<mkdir dir="${code.build}/log" />
<mkdir dir="${code.build}/audit" />
<tstamp/>
<target name="fortify" if="fortify.present">
<typedef name="sourceanalyzer"
classname="com.fortify.dev.ant.SourceanalyzerTask"/>
<!-- call clean to ensure that all source files are recompiled -->
<antcall target="clean"/>
</antcall>
<!-- capture all configuration files in WEB-INF directory -->
<echo>sourceanalyzer ${web-inf}</echo>
<sourceanalyzer buildid="${sourceanalyzer.buildid}">
<fileset dir="${web-inf}">
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</sourceanalyzer>
<!-- translate all jsp files-->
<echo>sourceanalyzer ${basedir} jsp</echo>
<sourceanalyzer buildid="${sourceanalyzer.buildid}">
<fileset dir="${basedir}">
<include name="**/*.jsp"/>
</fileset>
<classpath refid="jsp.classpath"/>
</sourceanalyzer>
<!-- run analysis -->
<echo>sourceanalyzer scan</echo>
<sourceanalyzer buildid="${sourceanalyzer.buildid}"
scan="true"
resultsfile="issues.fpr"
/ >
</target>
Ant properties
Any Ant property that begins with com.fortify is relayed to the sourceanalyzer task via -D.
For example, setting the com.fortify.sca.ProjectRoot property results in -
Dcom.fortify.sca.ProjectRoot=<value> being passed to the sourceanalyzer task. This
is also used for the SCACompiler adapter. These properties can be set either in the build file, using
the <property> task for example, or on the Ant command line using the -D<property=<value>
syntax.
When using the SCACompiler adapter via the build.compiler setting, the
sourceanalyzer.build Ant property is equivalent to the buildID attribute of the
sourceanalyzer task, and the sourceanalyzer.maxHeap is equivalent to maxHeap. You can
use either the command line or your build script to set these properties.
The bootclasspath, classpath, extdirs, and options may also be specified as nested
elements, as with the Ant javac task. Source files can be specified via nested <fileset> elements.
classpath Path Specifies the classpath to be used for Java source code.
extdirs Path Similar to the javac extdirs option. Any jar files found
in these directories are included implicitly on the
classpath.
sourcepath Path Specifies the location of source files which will not be
included in the scan but will be used for resolution.
The filter file is specified by the -filter analysis option, followed by the <filter file.txt>
name.
Note: Fortify Software recommends that you use this feature only if you are an advanced user. Do
not use this feature during standard audits because auditors should be able to see and evaluate all
issues found by Fortify SCA.
A filter file is a flat text file that can be created with any text editor. The file functions as a blacklist,
such that only the filter items you do not want are specified one per line. The following filter types
can be entered on a line:
• Category
• Instance ID
• Rule ID
The filters are applied at different times in the analysis process, according to the type of filter.
Category and rule ID filters are applied during the initialization phase before any scans have taken
place, whereas an instance ID filter is applied after the analysis phase.
For example, the following output is a result from a scan of the EightBall.java, located in the
/Samples/basic/eightball directory in your Fortify installation directory.
From the command line, navigate to the eightball directory and execute the following commands
to build, scan, and analyze the eightball sample.
You can create a file to test the filtered output by copying the above text into a file. Make sure you
substitute the #### placeholders with actual instance and rule IDs. You can obtain this information
using Audit Workbench.
EightBall.java(4)
• Properties specified on the command line have the highest precedence and can be specified
during any scan.
• Properties specified in the fortify-sca-quickscan.properties file are processed
second, but only when the -quick option is used to operate in Quick Scan mode. If Quick Scan
is not invoked, this file is ignored.
• Properties specified in the local fortify.properties file are processed third. Change
values in this file on a scan-by-scan basis to fine-tune your installation.
• Properties specified in the global fortify-sca.properties file are processed last. You
should edit this file if you want to change the property values on a more permanent basis for all
scans.
Fortify SCA also relies on some properties that have internally-defined default values.
The following table lists properties that can be defined. The default values are listed. If you want to
use Quick Scan Mode, or want to tune your application, you can make the changes as described in
Table 18: Tuning Performance Properties.
Property Name
com.fortify.sca.AbortedScanOverwritesOutput
com.fortify.sca.Appserver
com.fortify.sca.Appserver.Home
com.fortify.sca.Appserver.Version
Property Name
com.fortify.sca.fileextensions.*
(none) Controls how Fortify SCA handles files with given extensions.
See fortify-sca.properties for examples.
com.fortify.sca.FPRDisableSrcHtml
(none) If true, disables source code rendering into the FPR file.
com.fortify.sca.NoDefaultRules
(none) If true, rules from the default rulepacks are not loaded. Fortify
SCA processes the rulepacks for description elements and
language libraries, but no rules are processed.
com.fortify.sca.NoDefaultIssueRules
com.fortify.sca.DisableDefaultRuleTypes
(none) Disables the specified type of rule in the default rulepacks; where
type is the XML tag minus the suffix “Rule”. For example, use
DataflowSource for DataflowSourceRule elements. You can also
specify specific sections of characterization rules, such as
Characterization:Controlflow, Characterization:Issue, and
Characterization:Generic. Type is case-insensitive.
Use a colon delimited list to specify multiple types of rules.
com.fortify.sca.NoDefaultSinkRules
com.fortify.sca.NoDefaultSourceRules
com.fortify.sca.ProjectRoot
com.fortify.sca.DefaultFileTypes
com.fortify.sca.compilers.*
Property Name
com.fortify.sca.FVDLDisableProgramData
com.fortify.sca.FVDLDisableSnippets
false If true, code snippets are not included in the analysis results
(FVDL output).
com.fortify.sca.LogFile
${com.fortify.sca.Pro The default location for the Fortify SCA log file.
jectRoot}/log/sca.log
com.fortify.sca.LogMaxSize
(none) When this property is set, it enables log rotation for the Fortify
SCA log. The value is the number bytes that can be written to the
log file before it is rotated. Must be used with
com.fortify.sca.LogMaxFiles.
com.fortify.sca.LogMaxFiles
(none) The number of log files to include in the log file rotation set. When
all files are filled, the first file in the rotation is overwritten. The
value must be at least 1. Must be used with
com.fortify.sca.LogMaxSize.
com.fortify.sca.Debug
false Produces a debug log file. This log file is for Technical Support
purposes.
com.fortify.sca.PPSSilent
false Prompts the user with the number of lines the scan requires to
analyze the source code. Set to true to suppress the prompt and
automatically deduct the lines.
Note: If the scan requires more lines than are available, the scan
fails with an error indicating how many additional lines are
required.
com.fortify.sca.UnicodeInputFile
(none) When set to true, this property indicates that the input file is UTF-
8 based and begins with a byte-order mark (BOM). Typically, you
should only set this property if you see a lexical error at Line 1,
Column 1, indicating that the BOM is present.
com.fortify.rules.SkipRulePacks
Property Name
com.fortify.sca.limiters.MaxChainDepth
5 Controls the maximum call depth through which the data flow
analyzer tracks tainted data. Increasing this value increases the
coverage of data flow analysis, and results in longer analysis
times. This property can be changed if you are using Quick Scan
Mode: see the following table for the suggested value to use.
Note: In this case, call depth refers to the maximum call depth on
a data flow path between a taint source and sink, rather than call
depth from the program entry point, such as main().
com.fortify.sca.limiters.MaxFieldDepth
com.fortify.sca.limiters.MaxPaths
com.fortify.sca.limiters.MaxIndirectResolutionsForCall
The following table describes the properties that can be used to tune default scanning performance.
They have different defaults for Quick Scan mode, which can be adjusted by editing the fortify-
sca-quickscan.properties file. If you want to use the recommended tuning parameters, you
do not need to edit this file; however, you may find that you want to experiment with other settings to
fine-tune your specific application.
Remember that properties in this file are processed only if you specify the -quick option on the
command line when invoking your scan.
Property Name
Values Description
com.fortify.sca.FilterSet
Default value is not set. When set to targeted, this property runs rules only for the
targeted filter set. Running only a subset of the defined rules
Quick Scan value: Targeted. allows the Fortify SCA scan to complete more quickly. This
causes SCA to run only those rules that can cause issues
identified in the named filter set, as defined by the default
project template for your application. For more information
about project templates, see the Audit Workbench User’s
Guide.
com.fortify.sca.FPRDisableSrcHtml
Default value: False. When set to true, this property prevents the generation of
marked-up source files required for Fortify Team Server. If you
Quick Scan value: True. plan to upload FPRs that are generated as a result of a quick
scan, you must set this property to false.
com.fortify.sca.limiters.ConstraintPredicateSize
Default value: 50000. Skips calculations defined as very complex in the buffer
analyzer to improve scanning time.
Quick Scan value: 10000.
com.fortify.sca.limiters.BufferConfidenceInconclusiveOnTimeout
Default value: true. Skips calculations defined as very complex in the buffer
analyzer to improve scanning time.
Quick Scan value: false.
com.fortify.sca.limiters.MaxChainDepth
Default value: 5. Controls the maximum call depth through which the data flow
analyzer tracks tainted data. Increasing this value increases
Quick Scan value: 4. the coverage of data flow analysis, and results in longer
analysis times.
Note: In this case, call depth refers to the maximum call depth
on a data flow path between a taint source and sink, rather
than call depth from the program entry point, such as
main().
com.fortify.sca.limiters.MaxTaintDefForVar
Default value: 1000. This property sets the complexity limit for data flow precision
backoff. Data flow incrementally decreases precision of
Quick Scan value: 500. analysis for functions that exceed this complexity metric for a
given precision level.
com.fortify.sca.limiters.MaxTaintDefForVarAbort
Default value: 4000. This property sets a hard limit for function complexity. If
complexity of a function exceeds this limit at the lowest
Quick Scan value: 1000. precision level, the analyzer will not analyze that function.
Property Name
Values Description
com.fortify.sca.DisableGlobals
Default value: false. This property prevents the tracking of tainted data through
global variables to allow faster scanning.
Quick Scan value: false.
com.fortify.sca.CtrlflowSkipJSPs
Default value: false. This property skips control flow analysis of JSPs in your
project.
Quick Scan value: false.
com.fortify.sca.NullPtrMaxFunctionTime
Default value: 300000. This property sets a time limit, in milliseconds, for Null Pointer
analysis for a single function. The default is five minutes.
Quick Scan value: 30000. Setting it to a shorter limit decreases overall scanning time.
com.fortify.sca.CtrlflowMaxFunctionTime
Default value: 600000. This property sets a time limit, in milliseconds, for control flow
analysis for a single function. The default is 10 minutes.
Quick Scan value: 30000.
com.fortify.sca.TrackPaths
By default, this property is not This property disables path tracking for control flow analysis.
set. Path tracking provides more detailed reporting for issues, but
requires more scanning time. You can disable this for JSP
Quick Scan value: NoJSP. only by setting it to NoJSP, or for all functions by setting it to
None.