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


Analysis Page and Warning Reports

CodeSonar provides HTML versions of analysis results and warning reports. This allows easy result browsing as well as a high degree of portability for warning reports.

Important Note: the CodeSonar Web GUI makes extensive use of JavaScript. Make sure JavaScript is enabled in your web browser.

In the previous step you built a project, ran the CodeSonar analysis and sent the analysis results to a hub. Now you can view the analysis report.

The analysis may still be under way when you open the analysis page. If this is the case, the page will not be fully populated and the Analysis State bar will not be full. Reload the page to see updated results. Once the analysis is completed, the Analysis State bar will be full and will contain the word Finished.

Analysis Page

You should see a page that looks (something) like this:

Screenshot: home page for HTML output of analysis results

This is the analysis page. By default, it will display the Warnings tab, which contains a table of all the warnings issued by the analysis. (The values in the ID column may differ from those shown here.)

  1. Click the shaded bar on the left side of the page.

    Screenshot: expanding the file explorer

    The bar will expand to display the File Explorer. If you select a file in the File Explorer, the contents of each Analysis page tab will update to show only the warnings (or files, or procedures) from that file. If you select a directory, the tabs will show the warnings (files, procedures) from the tree under that directory. This is particularly useful for large projects with many source files and directories. This project only has one file, so you don't need to keep the File Explorer open.

  2. Drag the right side of the File Explorer panel leftward to narrow it until it collapses again.

    You will see at a glance that the analysis of BasicProj.c produced several warnings, including two Null Pointer Dereference warnings.

Prioritizing Warnings

Each warning has an associated numerical Score. CodeSonar computes and reports this in order to suggest a review order for warnings: warnings with a higher Score value before warnings with a lower Score value.

  1. Inspect the table of warnings in the Analysis page. The first column of this table is Score. Note the following. Score will typically be a useful factor in determining your warning review order. However, it will not necessarily be the only factor. For example, your organization might specify that all warnings in component A should be reviewed before any warnings in component B, then use Score to set the review order within each component.

    We will review a "Null Pointer Dereference" warning first, even though it doesn't have the highest Score, because it provides a useful introduction to several Warning Report features.

  2. Click the table entry for the "Null Pointer Dereference" warning that occurs on line 17.

    This will open a new page.

Warning Report Page

In overview, the warning report page looks (something) like this:

Screenshot: overview of HTML warning report page

Warning Report Heading

The report heading specifies the warning class of the warning, and the location (file and line number) where the warning was issued. The location is a link: you can click it to navigate to the warning location in the source excerpt. Directly underneath the heading is a Jump to warning location ↓ link, which has the same destination.

Context-sensitive help links context-sensitive help icon are provided throughout the CodeSonar GUI.

  1. Click the context-sensitive help icon icon next to the Null Pointer Dereference heading.
    A new browser tab will open to display the manual page about the Null Pointer Dereference warning class. Every warning class has its own documentation page.
  2. Change back to the browser tab containing the warning report.

Detailed Warning Information

Click warning details in the report heading to see detailed information about the warning.

Screenshot fragment: warning information

Categories The warning is associated with warning mnemonic LANG.MEM.NPD, CWE identifiers CWE:476 and CWE:690, and SEI CERT C Coding Standard rule EXP34-C.
Each category name links to a documentation page: warning mnemonics are documented in this manual, CWE identifiers are documented at the CWE website, and CERT rules and recommendations are documented at the CERT website.
Warning ID Uniquely identifies the warning to the hub. The number before the dot is the Group ID for the warning group this warning belongs to. The number after the dot is the Instance ID and is unique to this warning instance.
Procedure The warning was issued in procedure main.
Explore Callers CodeSonar provides functionality for interactively exploring the possible execution paths to a warning location. To learn more, see GUI Reference: Explore Callers.
Modified The last time the warning report was modified. At the moment, this is just the time that the report was issued.

Source Code Excerpt

The warning report displays an annotated excerpt from the source file in which the warning was issued.

Screenshot fragment: code fragment containing path

excerpt header Gives the full path name of the source file and provides Show Events and Options menus.
excerpt The source excerpt is colored and annotated. In particular:
  • A warning description box is displayed at line 17 (the warning location).
  • A primary event annotation is displayed at line 16. Annotations for all primary events are displayed by default.
  • C language keywords are displayed in bold text, macro names have special MACRONAME coloring, and comments are greyed out.
  • Code that is executed in the case where the problem occurs has basic background highlighting. (Note that the variable declarations are not highlighted, because they are not associated with execution events at runtime.)
  • The assignment that causes the null dereference has red background highlighting .
warning description box An annotation at the warning location specifies the warning class and explains that the problem is that q is dereferenced at line 17, when its value is NULL.
primary event CodeSonar has determined that the code at line 16 is especially important – a primary event – because it is the origin of the NULL value for q. The annotation for Event 2 is therefore displayed by default. This is a data annotation and has a yellow background.

Viewing All Annotations

CodeSonar displays annotations for primary events by default. Sometimes you will want to see the remaining annotations as well.

  1. Click the Jump to warning location ↓ link or scroll down (if necessary) to view the warning description box.
  2. Click All events at the bottom of the warning description box.

This warning has one other annotation, noting that the rand() call at line 13 returns 1 in the execution being considered. The return value affects control flow through the program, so the event has a control flow annotation with a green background.

screenshot fragment: control flow event

You can also view all annotations by selecting All events from the Show Events menu at the top of the excerpt.

Conclusion

CodeSonar has concluded that if this path is followed, q must be a null pointer and so buf[0] = q[0] must be a null dereference. This is a feasible path, because there is no reason to assume the rand() call can't return 1.

This first warning was straightforward: q is set to NULL and then dereferenced whenever rand() returns 1. It's useful for illustrating the basics of CodeSonar but is an unlikely error for a programmer to make. Even if this bug did somehow find its way into a program it would quickly cause problems and easily be found using basic debugging methods.

Next

 

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