In this section:
The Key Performance Indicator (KPI) slice calculates a score based on weights assigned to code analysis rules in your development project. The weights are defined in a profile that can be customized to meet your development goals. When the slice is invoked, it counts the number of rule violations for each file in the project. For each rule, the slice multiplies the violation count by the specified rule weight in the profile. If a rule does not have a defined weight in the profile, the count for that rule is not gathered. The sum of the weighted counts is divided by the logical lines of code (METRIC.NOLLOCIF) to yield a KPI score. This artifact ships with the Security Compliance Pack, which includes configurations for calculating KPIs associated with security compliance standards.
The KPI slice is installed with the Security Compliance Pack. After installing the Security Compliance Pack, you will need to deploy the slice using Extension Designer.
If you are upgrading from the standalone instance of the KPI slice, uninstall the previous version of the artifact, including models and profiles, prior to installing the latest version. If you altered the default profile shipped with the previous version or created custom profiles, export the profile(s) and add the following attributes (also see Exporting and Importing Profiles):
If you change the default values, we recommend setting the metric ID prefix to METRIC.KPI.<profile name without spaces>
. Use a concise name for the metric (maximum 30 characters).
Several KPI profiles are added when the Security Compliance Pack is installed. Each profile contains weights for the Parasoft rules that check a set of security compliance guidelines. You can use the default weights or review each rule and apply your own weights.
To change the weight:
You can also add rules that are not in the profile to include in the calculation. Refer to Working with Model Profiles for additional information.
The KPI slice is a long running slice. It should only be computed when invoked by a third-party, ideally as part of a nightly job.
filterId | The filter id for the project that the calculations will be performed on. |
---|---|
profile | Profile name with the rules and weights to use for the calculations. |
buildId | The build id for which the calculations will be performed on. If no build id is provided, this parameter defaults to the latest build. |
You could run the following command to invoke the slice and run the calculation:
curl "http://localhost:8314/api/v1/services/5dcc38b803c7380f707268b9/slices/bd858e5f.965978?filterId=2&buildId=docs-2019-11-13&profile=CWE%20Security%20Impact%20-%20Java" |
If successful, you will receive a response such as the following:
{ "success": { "message": "Calculation has started for filter 'jtest' using profile 'CWE Security Impact - Java'. Check debug output for any errors during calculation.", "title": "KPI" } } |
After computation has completed and the KPI metric has been reported back to DTP, you can add a Metrics widget to your DTP dashboard and choose a metric associated with your security compliance guidelines from the Metric drop-down menu. The value in the drop-down menu comes from the Metric Name field in the profile (see Configuration). Refer to Adding Widgets for additional information about adding widgets to DTP dashboards.
The widget will display the metric according to your specifications.
Click on the widget to open the Single Metric Overview Report.
Click on a link in the report to view the data in the Metrics Explorer.