Main Content

Check CWE (-cwe)

Check for weaknesses in your code that are enumerated in CWE

Since R2023a

Description

This option affects Bug Finder only.

Specify whether to check for common weaknesses enumerated in CWE. Each value of the option corresponds to a subset of the coding standard to check.

Set Option

User interface (desktop products only): In your project configuration, the option is on the Coding Standards & Code Metrics node. See Dependencies for other options that you must also enable.

User interface (Polyspace Platform, desktop products only): This option does not exist in the project configuration. Activate checkers by using the options Use custom checkers file and Checkers activation file (-checkers-activation-file).

Command line and options file: Use the option -cwe. See Command-Line Information.

Why Use This Option

Use this option to specify the subset of common weaknesses to check in your code.

After analysis, the Results List pane lists the coding standard violations. On the Source pane, for every coding standard violation, Polyspace® assigns a symbol to the keyword or identifier relevant to the violation.

Settings

Default: all

all

Check for violations of all CWE rules supported by Polyspace.

See section CWE Rules of the Common Weakness Enumeration (CWE) category.

For some of the rules in this set, Polyspace covers only partially the weakness that a rule illustrates and might not report a violation of that rule for all instances of that weakness in your code.

To check only for rules that Polyspace covers exactly, use option all-exact-checkers instead.

cwe-658-659

Check for violations of a subset of rules for weaknesses that are specific to C (CWE-658) and C++ (CWE-659) software.

See section CWE Rules Specific to C and C++ (CWE 658 and CWE 659) of the Common Weakness Enumeration (CWE) category.

all-exact-checkers

Check for violations of a subset of rules for weaknesses that Polyspace covers exactly. For a list of the rules enabled by this option, see List of CWE Rules Enabled with Option all-exact-checkers.

from-file

Specify an XML file where you configure a custom selection of checkers for this coding standard. To create a configuration file, click , then select the rules and recommendations you want to check for this coding standard from the right pane of the Checkers selection window. Save the file.

To use or update an existing configuration file, in the Checkers selection window, enter the full path to the file in the field provided or click Browse.

If you set the option to from-file, enable Set checkers by file (-checkers-selection-file).

Command-Line Information

Use the option -cwe in the command line to check for common weaknesses enumerated by CWE.

Parameter: -cwe
Value: all | cwe-658-659 | all-exact-checkers | from-file
Example (Bug Finder): polyspace-bug-finder -lang c -sources file_name -cwe all
Example (Bug Finder Server): polyspace-bug-finder-server -lang c -sources file_name -cwe all

Alternatively, enable all or specific CWE rules by using a checkers activation XML file. See Checkers activation file (-checkers-activation-file).

Version History

Introduced in R2023a