General

Warning Processors Shipped With CodeSonar

CodeSonar ships with Python source code for several warning processors. You can install these processors on your hub, or use them as examples in constructing your own warning processors.

This section contains full details of the processors, including installation and customization instructions.

All warning processor scripts are provided as examples of what might be done using warning processors. No guarantee of suitability or support for any specific use is implied or intended.



Location

The warning processors shipped with CodeSonar are all in subdirectories of $CSONAR/py/processors/.

A sample batch file (for running a warning processor on a Windows system) and wrapper script (for other systems) are provided in $CSONAR/py/processors/wrapper.bat and $CSONAR/py/processors/wrapper.sh, respectively.

We do not recomend modifying the files in $CSONAR/py/processors/, because they will be replaced when you upgrade CodeSonar. Instead, copy them to a subdirectory of your hub directory as described in the Installation section below.

Processor Details

assign2author

When the assign2author warning processor is invoked on a warning, the warning is assigned to the person who last updated the file in which the warning was issued (unless that person does not have a hub user account), as determined from version control information. Once the analysis finishes, each user who has been assigned one or more new warnings is sent an email message summarizing their new assignments, and a designated monitor is sent an email message summarizing all new assignments.

Location $CSONAR/py/processors/assign2author/
Customization Follow the instructions in assign2author/variables.py to specify appropriate values for the variables defined in that file.

The warning processor works out of the box with the Subversion and git version control systems. If you are using another version control system, follow the instructions in assign2author/custom_get_info.py to implement a custom module and integrate it with this warning processor.

Installing Follow the instructions in assign2author/main.py.
Recommended Mode Automatic only
Notes Detailed installation instructions are provided in assign2author/main.py.

The display script for this warning processor calls display.hide_checkbox() to hide itself from the Change Warnings form.

autoset

The autoset warning processor has a list of (condition, action) pairs, where a condition is a Boolean expression describing one or more properties of a warning and an action is an operation that can be applied to a warning. When the autoset warning processor is invoked on a warning, each conditioni in turn is evaluated and the corresponding actioni executed if conditioni is satisfied.

Location $CSONAR/py/processors/autoset/
Customization Edit the RULES list in autoset/settings.py to contain the (condition, action) pairs you want to use.
Installing Follow the instructions in autoset/main.py.
Recommended Mode Automatic
Notes File settings.py defines a number of useful helper functions to use in specifying conditions and actions.

autoset2

An extended version of the autoset warning processor: when the analysis finishes, it sends notification email messages to all users who were assigned warnings by the processor.

Location $CSONAR/py/processors/autoset2/
Customization Edit autoset2/settings.py to specify the (condition, action) pairs and other general configuration information for the warning processor, following the instructions in that file.

Edit autoset2/email_settings.py to configure email settings for the warning processor, following the instructions in that file.

Installing Follow the instructions in autoset2/main.py.
Recommended Mode Automatic only
Notes File settings.py defines a number of useful helper functions to use in specifying conditions and actions.

The display script for this warning processor calls display.hide_checkbox() to hide itself from the Change Warnings form.

bugzilla

The bugzilla warning processor creates a bug report concerning one or more CodeSonar warnings and submits it to a Bugzilla database. The change history for the warning is updated with a link to the new Bugzilla item, and the Bugzilla item will contain a link to each CodeSonar warning involved.

Location $CSONAR/py/processors/bugzilla/
Customization Edit bugzilla/settings.py to configure the warning processor, following the instructions in that file.
Recommended Mode Interactive only
Installing Follow the instructions in bugzilla/main.py.
Notes File bugzilla/display.py contains the display script for this warning processor. It inspects a warning's comment history to see if there is a record of a previous submission to Bugzilla. If so, it provides a link to the relevant Bugzilla entry. Otherwise, it displays a checkbox allowing the user to apply the processor.

conditions

The conditions warning processor can only be applied in Change Multiple Warnings mode. It allows the user to interactively specify a set of conditions and a set of warning property updates, then apply the updates to those selected warnings that satisfy the conditions.

Location $CSONAR/py/processors/conditions/
Customization None required: the conditions are specified interactively when the warning processor is invoked.
Recommended Mode Interactive
Installing Follow the instructions in conditions/main.py.
Notes The display script (in conditions/main.py) hides the processor from view.

email

The email warning processor creates an email message concerning one or more CodeSonar warnings and sends it to an email address specified by the user. The user can also specify additional content for the body of the message.

Location $CSONAR/py/processors/email/
Customization Edit email/settings.py to set SMTP_SERVER to the location of your SMTP server.
Recommended Mode Interactive
Installing Follow the instructions in email/main.py.
Notes The From: line of the email message will be populated from the account details of the user who invoked the warning processor. File email/display.py contains the display script for this warning processor.

jira_cloud

The jira_cloud warning processor implements the Jira Cloud Integration for CodeSonar.

Location $CSONAR/py/processors/jira_cloud/
Customization See the detailed instructions in Jira Cloud Integration for CodeSonar.
Recommended Mode Manual only
Installing See the detailed instructions in Jira Cloud Integration for CodeSonar.
Notes File jira_cloud/warning_processor_init.py contains the display script for this warning processor. It inspects a warning's comment history to see if there is a record of a previous submission to Jira. If so, it updates the existing Jira ticket with information from the current warning, otherwise it creates a new ticket based on the current warning.

notify

The notify warning processor keeps a log of all new warnings in an analysis. When the analysis finishes, it sends out an email message that lists all the new warnings.

Location $CSONAR/py/processors/notify/
Customization  Edit notify/settings.py to to configure email settings for the warning processor, following the instructions in that file.
Recommended Mode Automatic only
Installing Follow the instructions in notify/main.py.
Notes The display script for this warning processor calls display.hide_checkbox() to hide itself from the Change Warnings form.

Installing

To install one of these warning processors on a hub, follow the detailed instructions provided in the corresponding main.py file.

The process will generally be something like the following.

  1. If the hub directory does not have a processors subdirectory, create it.
    cd hubdir
    mkdir processors
  2. Copy the warning processor directory into a subdirectory of processors.
    cp -r $CSONAR/py/processors/processor_dir processors/
  3. Customize the warning processor code as directed.
  4. Copy the warning processor executable from processors/processor_dir/ to processors/.
    Windows:
    cp processors/processor_dir/exec_name.bat processors/
    Other Systems :
    cp processors/processor_dir/exec_name.sh processors/
  5. Open the warning processor executable for editing; follow the instructions in the file to customize it.
  6. Open the Manage Warning Processors page in the Web GUI and scroll to the Add New Warning Processor section.
  7. Enter a suitable label for the warning processor in the Label field, and the warning processor executable name (exec_name.sh or exec_name.bat) in the Processor Executable field.
  8. Click the Install button.

Other Warning Processor Sections

The following sections contain further information about warning processors.

How Warning Processors Work Describes the components and behavior of a warning processor.
Warning Processor Input and Output Describes the formats and semantics of warning processor inputs and outputs.
Authoring Warning Processors Outlines the requirements for creating a CodeSonar warning processor.
Authoring Python Warning Processors Explains how to use the csonar_utils Python package to create custom warning processors.
csonar_utils API documentation Describes the key components of the csonar_utils Python package.