Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DTPDEVEL and version 2024.2

...

Table of Contents
maxLevel23

Why Recommend Violations to Fix?

One of the first decisions that a developer has to make when assessing a violation is whether to fix the violation or suppress it. Although most violations detected may be true positives, there also may be instances in which suppressing a violation is the sensible thing to do, such as when the violation is a false positive or the team has decided to not fix certain kinds of violations.  

...

Developers can use the DTP recommendation as an assistant in assessing and triaging violations.

Getting Recommendations

In order to get recommendations, a model must first be trained. Training requires violations that have been classified as Fix or Suppress in the Actions field of the Prioritization tab (see Assigning Actions to Violations). 

...

It is recommended to retrain the model from time to time as you continue to fix and suppress more violations.

Using the Machine Learning Wizard to Train the Model

The wizard guides you through the following process:

  1. Classifying violations: Classifying violations refers to setting a value for the Action field in the Prioritization tab (see Assigning Actions to Violations). The machine learning functionality requires at least 20 violations to be classified as Fix or Suppress to build a recommendation model.
  2. Training the model: DTP will analyze classified violations and build a recommendation model based on several data points. This may take several minutes if a large number of violations (for example, 1000+) have been classified. The resulting model is assigned a health score. If the model has an unacceptable health score, the wizard will prompt you to review and classify additional violations.

Anchor
ClassifyingViolations
ClassifyingViolations
Classifying Violations

  1. Click the machine learning icon and choose Recommend Violations to Fix to launch the wizard.
  2. If this is your first time launching the wizard or if the existing model is not sufficient to recommend actions, you will be prompted to train the model. Click Next. 

  3. You will need to classify at least 20 violations to build a recommendation model. Choose Classify violations and click Next.
  4. DTP will analyze the existing builds in the filter and prompt you to build the model based on violations that have already been classified or to classify violations manually. 
  5. Choose one of the following options and click Confirm:
    • Enable Classify violations based on history and choose either All, 6 months, or 12 months from the Build history menu. DTP will search for violations that have already been fixed or suppressed and set the Action field to "Fix" or "Suppress" accordingly. See Expected Classification Outcomes for additional information.
    • Enable Classify violations manually and DTP will present 20 violations from the current build for you to review and classify. See Assigning Actions to Violations for instructions on how to manually classify violations.
  6. When an adequate number of violations have been classified, you will be prompted to return to the main page of the wizard so that you can train the model (see Training the Model).

Expected Classification Outcomes

If Classify violations based on history is enabled, DTP will classify violations in the database that have been fixed or suppressed, resulting in one of the following outcomes:

  • If an adequate number of violations have been classified, you will be prompted to return to the main page of the wizard so that you can train the model (see Training the Model).
  • If no violations from your history have been fixed or suppressed, then DTP will not be able to automatically assign actions. You will be prompted to return to the main page of the wizard and restart the classification process. Choose Classify violations manually when prompted. DTP will present 20 violations from the current build for you to review and classify. See Assigning Actions to Violations for instructions on how to manually classify violations.
  •  DTP requires a balanced ratio of Fix and Suppress violations. If too many violations have been identified and classified as either Fix or Suppress, you will be prompted to manually classify additional violations until a more balanced ratio is achieved. See Assigning Actions to Violations for instructions on how to manually classify violations.

Anchor
TrainingTheModel
TrainingTheModel
Training the Model

  1. If the wizard is not already open, click the machine learning icon and choose Recommend Violations to Fix to launch it.
  2. Choose Train model and click Next.
  3. If you have already classified at least 20 violations, you will be prompted to execute training based on those classifications (if you have not already classified at least 20 violations, see Classifying Violations). Enable Execute training and click Next
  4. Choose a training mode when prompted. See About Training Modes for additional information about which option to choose.
  5. Click Confirm when prompted to begin training the recommendation model on how to classify violations. This may take several minutes if a large number of violations (for example, 1000+) have been classified.
  6. When the model is trained, you will be prompted to recommend actions (see Recommending Violations to FixPredictingActions).

A healthy recommendation model is essential for DTP to make reliable recommendations. If the classification process results in a Poor or Moderate model, then you should continue classifying violations until the model health improves. See About Model Health for additional information. If you used the Fast or Normal mode to train the model and are unsatisfied with the quality of the model, retrain the model and choose either the Deep or Deepest training mode option. 

About Training Modes

DTP uses the following algorithms to train the model:

...

The Deep and Deepest training use all classified violations available to train the model. As a result, these options have the potential to produce the best possible model. Allow several more minutes for the training process to complete, however, if your project contains a very large set of classified violations.

Anchor
PredictingActions
PredictingActions
Recommending Violations to Fix

You can get recommendations on violations to fix from two places:

Anchor
PrioritizationTab
PrioritizationTab
From the Prioritization Tab

You can also get DTP to recommend violations to fix by clicking Get Recommendations on the Prioritization tab.

...

If you have trained the model, the recommendation will be added to the Recommendations section. If one or more prerequisite conditions have not been met, there will be an info icon to the left of the Recommendations label that you can hover over for details.

Anchor
MachineLearningWizard
MachineLearningWizard
Using the Machine Learning Wizard

  1. If the wizard is not already open, click the machine learning icon and choose Recommend Violations to Fix to launch it.
  2. Enable Recommend violations to fix and click Next. 

    • If Recommend violations to fix is not available, you will need to classify more violations. See Classifying Violations.
    • If you would like to increase the recommendation health score, you will need to train the model more. See Training the Model.
  3. Click Confirm when prompted. DTP will use the machine learning model to make recommendations about how to classify static analysis violations for the current build in the filter. The Recommended Action field in the Prioritization tab will be updated. See Viewing Recommendations for more information about viewing recommendations. A recommendations results summary screen will also appear.
     
  4. Review the actions recommended for the violations. You can either assign the recommendations to the violations (see Assigning Actions to Violations) or ignore the recommendations. See Viewing Recommendations for more information about viewing recommendations.

Viewing Recommendations

You can view the violations to fix recommendations in two places: in the search results table and on the Prioritization tab.

...

In the Prioritization tab, look in the Recommendations section.

About Model Health

The health of the model that DTP uses depends on the number of violations you process and the quality of the data you provide. DTP requires at least 20 violations to be classified, but classifying more violations will improve the model health. If you have not provided enough data, DTP will not be able to use the model to make a recommendation.

The model informing DTP recommendations also depends on the accuracy and consistency of the data you provide. DTP uses advanced algorithms to analyze the data associated with each violation, but it can only make quality recommendations based on quality inputs. If there is an imbalance in the number of fixed violations versus the number of suppressed violations (or imbalance in the number of violations with action set to Fix versus the number of violations with action set to Suppress), DTP may indicate that it cannot properly train a model. In this case, you should assign an equal number Fix and Suppress actions to facilitate model health. 

Providing Machine Learning Feedback to Parasoft

You can help Parasoft improve the system by using the API to get Machine Learning data and sending the data to your Parasoft representative. Sensitive information, such as username and project name, is obfuscated in the response.  Save the output from the following API endpoints are available to retrieve the Machine Learning data:

/classificationResultSets

This endpoint returns static analysis violations used to train the model and recommendation results.

Authentication

Pass your username and password as when sending the request. See Example.

...

URL 

http:<HOST>:<PORT>/grs/api/v1.7/ml/staticAnalysis/classificationResultsSets

Method

GET

Parameters

The following table describes the parameters available for this endpoint.

...

No Format
curl -X GET -u username:password "http://dtp.mycompany.com:8443/grs/api/v1.7/ml/staticAnalysis/classificationResultSets?sortOrder=desc&limit=10" > myResultSets.json

/violationActionHistory

This endpoint returns actions assigned to the violations used to train the model.

URL

http:<HOST>:<PORT>/grs/api/v1.7/ml/staticAnalysis/violationActionHistory

Method

GET

Parameters

None.

Example

No Format
curl -X GET -u username:password "http://dtp.mycompany.com:8443/grs/api/v1.7/ml/staticAnalysis/violationActionHistory" > myViolationActionHistory.json