Configuring Rule Sets
This section explains about Rule Sets and describes the procedure for
creating and editing Rule Sets. It discusses the following topics:
What Are Rule Sets?
A Rule Set is of a set of parameters that the Globalyzer scanner uses
to detect internationalization errors and generate error reports.
The rules are divided into two categories: Detection Rules and
Filter Rules.
Detection Rules
Detection Rules specify internationalization
error conditions that the Globalyzer source code scanner will detect and
report to you. Some rules such as the rules that are used to detect string
literals embedded in your source code are fixed and can only be altered
by the Globalyzer server administrator. Most detection categories are
accessible to Globalyzer users for altering, adding to and deleting. Those
categories of rules are described here.
Locale Sensitive Methods
The Locale Sensitive Methods category includes
rules used to detect method calls, functions, and constructors in your
source that are potentially unsafe within certain locales and for certain
character encodings. These rules can be individually selected or deselected
but can't be altered. This category is available only for Java, C++, C#
and VB. An example of such a rule is Java's lang.String.ToLowerCase()
method. This signature draws upon the rules of the default locale to convert
a string to lower case. The rules of the default locale would not be correct
for languages in all locales, some of which do not have a lower-case mode
to their alphabets.
Note: When Globalyzer scans code for locale-sensitve methods,
the HTML Summary Report generated by Globalyzer includes links for all
detected locale-sensitive methods. The link takes you to information about
how to refactor or replace the detected method to make your code function
properly across all locales and character encodings.
Image References
Another detection category is the Image References
category. The user can add to, delete from, and alter this category of
rules . This category is used to detect image file paths in source code.
During the internationalization process, image files need to be localized
and placed in locale-specific directories. All paths to those image files
in the source code must then be altered to retrieve the localized image
at run time from the locale-specific directory corresponding to the user's
locale.
Source File Extensions
A very basic detection category is the Source File
Extensions category. This category of rules can be also be added
to, deleted from and altered by the user. As the name suggests, this category
simply tells Globalyzer which source files to scan if you point it at
an entire directory of source files.
General Patterns
Users can alter, add to and delete from the General
Patterns category, which can include any regular expression
that the user wants the scanner to look for during the scan. This might
include patterns used to enforce coding standards or anything at all --
not necessarily internationalization-related patterns.
Ignored HTML Tags
Finally, for HTML projects only, users will see the Ignored
HTML Tags category. This category requires special
explanation and has a section dedicated
to it. Please read this section if you intend to customize this Rule Set
category.
Filter Rules
Filter Rules specify conditions that the scanner
will overlook. For instance, by default, Globalyzer detects embedded strings.
Embedded string detection is a fixed part of each Rule Set that you create
(you cannot edit the embedded string rules). However, some strings embedded
in your code are not intended for display to an end user and hence, should
not be included in Globalyzer's reports listing strings that need to be
externalized for translation.
String Literal Filters
Embedded strings that shouldn't be externalized may be programmatic elements
or debug messages printed to the console. Globalyzer provides several
ways to filter such strings from your errors reports. The first way is
to specify a pattern, which if Globalyzer detects within a string
literal, will cause Globalyzer to ignore that string. This mechanism is
called String Literal Filters.
String Method Filters
The second mechanism for filtering strings is called String
Method Filters. Your code likely contains many method or functions
that are passed string arguments. When you are sure that any string passed
into function X is never displayed to the user, you can specify
that function name within the String Method Filters list and
whenever Globalyzer sees that a string literal is passed as an argument
to any of the methods, functions, or constructors in this list, it will
ignore those strings.
For example, the Java method:
javax.servlet.http.HTTPServletRequest.getParameter(String
s)
takes a string argument, but this string would never appear as text
visible to an end user. Therefore, if you add this method (method name
only) to the list of Method Filter Rules, Globalyzer will ignore any
string literal passed in.
String Line Filters
A final mechanism for filtering strings is called String
Line Filters. In the case where there are strings that will never be
displayed to the user and reside in lines of code that share a specific string
pattern, you can add that pattern to the String Line Filters list.
Whenever Globalyzer detects string literals in a line of code that also contains
one of the patterns in this list, it will ignore those strings.
For example, suppose you have several strings defined that are used only in
conditionally compiled debug code:
String szName = "Name"; // Debug
String szStart = "Start";// Debug
String szEnd = "End"; // Debug
String szTime = "Time"; // Debug
Since these are all common words, it would be difficult to eliminate them from
the embedded string report using String Literal Filters. However, since each
line of code
also contains the comment Debug, we can add that shared pattern to the
String Line Filters list. Now, when Globalyzer scans for string literals, it
will find a matching pattern in the String Line Filters list for these four
lines, and thus filter the four string literals from the embedded string report.
Logging In to the Server
Rule Sets must be configured on the Globalyzer server, using a browser.
The first step is to log in to your account on the server. Click here
for detailed login instructions.
Creating New Rule Sets
To create a new Rule Set:
- Log in to the server, as described previously.
- From your home page, select Create Rule Set. The Create
a New I18N Rule Set page appears.

- Enter a name for the new Rule Set.
- From the Select Source Type list, pick the type of
source code that you wish to scan. The choices are: C#, C++, HTML, JavaScript,
Perl, Java, Visual Basic, and VBScript.
- Click the Submit button.
- In the case of C++, an additional page appears for you to choose the context
for the C/C++.

There a five supported C++ programming language contexts:
ANSI UTF-8
ANSI UTF-16
Windows Generic
Windows MBCS
Windows Unicode
The context determines the default set of Unsafe Methods for the Rule Set. Click
here for details.
Click the Submit button.
- The Configure I18N Rule Set page appears.

This page allows you to edit the default settings for four Detection
Rules and three Filter Rules. Click on a link below for detailed information
about configuring each type of rule:
Detection Rules
Configure Source File Extensions
Choose from a list of file extensions to determine what types of files
will be scanned within a chosen project directory.
Configure Locale Sensitive (Unsafe) Methods
Choose from a list of default unsafe methods to be identified in the
code scan.
Configure Ignored HTML Tags
Choose from and add to a list of tags that are ignored by the HTML scanner
when searching for text embedded between matching tags.
Configure Image References
Choose from and add to a list of default image references to identify
in the code scan.
Configure General Pattern Matches
Choose from and add to a list of pattern matches to include in the code
scan.
Filter Rules
Configure Literal String Filters
Choose from and add to a list of default strings to filter out of the
code scan.
Configure String Method Filters
Choose from and add to a list of methods to filter out of the code scan.
Configure String Line Filters
Choose from and add to a list of default patterns to filter code lines out
of embedded string code scan.
Editing Rule Sets
To edit an existing Rule Set:
- Log in to the server, as described previously.
- From your home page, select View My Rule Sets. The
All My Rule Sets page appears.
- In the All My Rule Sets page, click the Edit button
next to the Rule Set you wish to edit. For example:

The Configure I18N Rule Set page appears. This page allows you to edit
the current settings for four Detection Rules and three Filter Rules.
Click on a link below for detailed information about configuring each
type of rule:
Detection Rules
Configure Source File Extensions
Choose from a list of file extensions to determine what types of files
will be scanned within a chosen project directory.
Configure Locale Sensitive (Unsafe) Methods
Choose from a list of default unsafe methods to be identified in the
code scan.
Configure Image References
Choose from and add to a list of default image references to identify
in the code scan.
Configure General Pattern Matches
Choose from and add to a list of pattern matches to include in the code
scan.
Filter Rules
Configure Literal String Filters
Choose from and add to a list of default strings to filter out of the
code scan.
Configure String Method Filters
Choose from and add to a list of methods to filter out of the code scan.
Configure String Line Filters
Choose from and add to a list of default patterns to filter code lines out
of embedded string code scan.
Creating a Project File for a Rule Set
After you log into the Globalyzer Client, and before you start scanning with a
new Rule Set, you'll want to create a Project file to store the name of your new Rule Set,
along with all your scan configuration settings.
This allows you to easily store and retrieve scan configurations prior to running or
rerunning a particular source code scan.
To see that name of the Project file that is currently loaded, look at the
Project field in the Project Settings panel in the lower left corner
of the main Globalyzer window.
Initially, before a Project file has been created, the "defaultProject"
is the current Project.

To create a new Project:
Select File=>New Project... from the Main menu.
Click here for
information on the New Project dialog. Once created, the Project Settings
panel will update the current Project to the one you've created. For example,
if you named your Project "Example_java", you would see:

With the creation of a new Project, you're ready to select a
Rule Set for your scan and make any other scan configuration changes via the
Project Properties dialog box. Note that
the scan configuration changes that you make will automatically update
the current Project file. That's why it's important to create new Project files
prior to making changes to the Project Properites dialog box.
Selecting a Rule Set to Use with a Scan
Before you perform a source code scan, you must be sure the correct
Rule Set is selected in the Globalyzer client's Project Properties dialog
box.
Tip: The currently selected Rule Set is shown in the Current
Globalyzer Project Settings panel in the lower left corner of the main
Globalyzer window.
To change the current Rule Set, open the Project Properties dialog
by doing one of the following:
Click the Edit button in the Current Globalyzer Project Settings
panel.
Select Edit=>Project Properties from the Main menu.
Select the Project Properties button
in the Button Bar.
In the Project Properties dialog, click the Scanning Tab, and
then the Rules Tab. Any Rule Sets you defined on the server appear
on the drop-down list. Select the Rule Set you wish to use.

Click here
for information on setting other scan
configurations in the Project Properties dialog box.
Copying Rule Sets
To copy an existing Rule Set:
- Log in to the server, as described previously.
- From your home page, select View My Rule Sets. The
All My Rule Sets page appears.
- In the All My Rule Sets page, click the Save As button
next to the Rule Set you wish to copy. For example:

- Give the new Rule Set a name in the Copy Rule Set page, and click the Save button.

Deleting Rule Sets
To delete an existing Rule Set:
- Log in to the server, as described previously.
- From your home page, select View My Rule Sets. The
All My Rule Sets page appears.
- In the All My Rule Sets page, click the Delete button
next to the Rule Set you wish to edit. For example:

- In the Delete Rule Set page, click the Delete button to confirm the operation.

User's Guide Contents
|