JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries
C#
Java

Code Coloring and Interaction

Source code in the CodeSonar source listing and warning report pages is enriched with syntax highlighting and extensive interaction functionality. This section describes these enrichments.

Code coloring and interaction are available for analyzed tier 1 (C, C++ and tier 2 (Java, C#) code only.
They are not available for:



Code Coloring

Code appears in warning reports and in source listings. In both these cases, CodeSonar uses coloring to reflect program syntax, information about warnings, and other important features.

C and C++ Source Coloring

if (x>0){ return x; } C/C++ language keywords are displayed in bold text.
MACRONAME Macro names are colored wherever they are used. Click the macro name to expand the macro definition, as described below.
/* comments */ All comment text (including comment delimiters) is greyed out and italicized.
# preprocessed away Any part of the file that was left out of compilation by a preprocessor directive such as #ifdef is greyed out and italicized.
int unreachable_func(void){return 1;} Functions that have been identified as unreachable from the REACHABILITY_ROOTS are greyed out. If no REACHABILITY_ROOTS are specified, all functions are considered to be reachable.

This information is also available through the GUI highlight legend.

Java Source Coloring

if (x>0){ return x; } Java language keywords are displayed in bold text.
// comments All comment text (including comment delimiters) is greyed out and italicized.

C# Source Coloring

if (x>0){ return x; } C# language keywords are displayed in bold text.
// comments All comment text (including comment delimiters) is greyed out and italicized.

Interaction and Navigation

The source code presented in the following page types is highly interactive.

Element Interaction
All tokens Hover over any token to highlight all occurrences of that token in the source. This feature covers:
  • variable, parameter, type, and field names
  • reserved words
  • numeric and character constants
  • tokens within string constants
  • tokens in code comments
  • labels
  • tokens in either tab of the information window.

Click the token to display a menu of options. (The menus for identifiers have additional options: see below.)

screenshot fragment: identifier menu

Stay highlighted Makes the token highlighting 'sticky'. If tokens with different names are highlighted, each will be given a different color.To remove sticky highlighting from a token, click any instance of that token and deselect Stay highlighted.
Jump(Go) to next occurrence Navigate to the next occurrence of the name in the code. If neither option is provided, there are no further occurrences.
Jump(Go) to previous occurrence Navigate to the previous occurrence of the name in the code. If neither option is provided, there are no previous occurrences.
For both Jump(Go) to next occurrence and Jump(Go) to previous occurrence, "Jump" indicates that you will be navigating to a new location within the current page; "Go" that you will be navigating into a different source listing page.
Identifier Hover over any procedure, variable, macro, or type name in the listing to view its definition and cross-referencing information in a information window.

Click the identifier to open a menu of options.

screenshot fragment: identifier menu

The menu provides the options provided for all tokens, plus additional contents as described in the following table.

Go to definition

Navigate to the definition location. There are three navigation options:

  • current tab Navigate in the current tab.
  • new tab Navigate in a new tab.
  • [anywhere else on the menu item] Navigate in the code tab of the information window.
If this list item is not present, the definition is not available.
Lock information window Lock the contents of the information window with the current token occurrence as the subject.
File names Click any file name to navigate to the corresponding source listing.
Line numbers
warning report Click any line number to navigate to the corresponding line in the corresponding source listing.
Macros [C/C++ only] To expand a macro definition, click the macro name and select Expand macro definition from the menu that opens. Click the [hide] link in the top right corner of the expansion box to close it, or click the macro name a second time and deselect Expand macro definition.

Annotated screenshot fragment: popping up a macro definition.

Tainted Values [C/C++ only] Tainted values, and operations and function calls that introduce or transfer taint, are highlighted using a scheme that supports discrimination between different kinds of taint. You can customize the highlighting scheme in the highlight legend: by default, tainted values are underlined in red.
  • Hover over any identifier with taint highlighting to view the taint kind associated with the identifier.
  • For any tainted subject, the info tab of the information window will indicate that taint is present and provide links for exploring the origin of the taint.

Tainted value highlighting is available when configuration file parameter TAINT_HIGHLIGHTING is set to Yes (this is the factory setting).

Information Window

The information window provides detailed information about individual code elements.

It opens the first time you hover over a suitable token name, as detailed below. Once it is open, its contents will update each time you hover over one of these elements.

Screenshot fragment: information window

The information window is available in the following page types.

Page Types Elements That Interact With Information Window
Tainted Value
Warning Report
Any function, variable, macro, or type name in the source excerpt.
Source Listing
Side By Side Source Listing
Any function, variable, macro, or type name in the listing.
Analysis: Warnings Tab
Warning Cluster
Warning Search Results
Any function, variable, macro, or type name in the Line Content column of the warning table.
Explore Callers Any function name in the displayed call graph.
Search Callers Any function name in the result table.

Once placed, the information window will remain in a fixed position relative to your browser window: it will not move when you scroll through the page. It will remain in this position until you resize or move it, or navigate away from the page. You can leave the information window as a floating window, or drag it against one side of your browser tab to 'dock' it.

locking the information window

info tab

The info tab displays a collection of cross-referencing information about a code element and its role in the analyzed software:

(For Java and C# code, this functionality is only available for elements defined in user code. Information about elements defined in the respective language runtimes is not shown.)

info tab of the information window

code tab

The code tab displays a code fragment scrolled to the definition of the code element.
(For Java and C# code, this functionality is available for definitions in user code only. Definitions in the respective language runtimes are not shown.)

def tab of the information window

The source code in the code tab has the same interaction and navigation functionality as described above, with two exceptions.

Highlight Legend

The highlight legend is available in the standard header of Source Listing, Warning Report, and Tainted Value pages.

To view the highlight legend:

  1. Click the Highlight Legend button icon (located to the right of the Visible Warnings selector).
  2. Select show highlight legend from the menu that pops up.

The highlight legend will be displayed at the bottom of the browser window.

screenshot fragment: highlight legend

The legend is divided into three parts.

General Describes the syntax coloring applied to the code, along with the background coloring scheme applied to code excerpts in Warning Reports.
User Describes the sequence of colors that will be used for user-requested token highlighting.
Taint
[C/C++ only]
The Taint section has a line for each taint kind present in the code currently displayed on the page, plus a style selector.

This section is interactive, unlike the General and User sections:

  • To change the color associated with a particular taint kind, click its color sample to open a color selector, then choose a new color.
  • To change the style used to indicate tainted values, select a new value from the style menu.
  • To disable display for a specific taint kind, deselect its checkbox. To re-enable display, select its checkbox.
Changes take effect immediately, and are 'sticky' (but not visible to other users).
 

To report problems with this documentation, please visit https://support.codesecure.com/.