Updated on 2024-07-23 GMT+08:00

Custom Rule Set

CodeArts Check supports custom rule sets. Each rule set must contain at least one rule.

A rule set can be configured with only one language.

Purchase the code security check enhancement package as required before using CodeArts Check. This package identifies code security risks and vulnerabilities more comprehensively for Java, C++, Go, and Python.

Customizing a Rule Set

  1. Go to the task page and click the Rule Sets tab.
  2. Click Create Rule Set. In the displayed dialog box, enter a rule set name and description, and select a language.

    (Optional) You can also copy an existing rule set by selecting it from the Replicated in drop-down list.

  3. Click OK.
  4. Select rule names, set rule levels as required, and click Save in the upper right corner.

    Customize a rule if the preset rules do not meet your requirements.

    The following uses a code security check enhancement package of a Java rule set as an example:

  5. Go to the View Task Details page, click Settings tab, and choose Rule Sets. On the displayed page, click in the row where Languages Included is located to re-obtain the code repository language, enable the target language, and select the configured custom rule set. For details, see Configuring a Rule Set.
  6. Click Start Check to run the check task based on the custom rule set.

Deleting a Custom Rule Set

Click in the row where the rule set is located and choose Delete Set.

  • Custom rule sets can be deleted only by the one who created them.
  • System rule sets and custom rule sets in use cannot be deleted.
  • To delete a rule set being used by a code check task, you can either delete the task or assign another rule set to the task.

Modifying a Custom Rule Set

  1. Click a rule set name and go to the rule set details page.
  2. Click Modify Basic Info.
  3. Modify the rule set name or description, and click OK.

    • The Language cannot be modified.
    • Preset rule sets cannot be modified.
    • Custom rule sets can be deleted only by the one who created them.

Customizing a Rule

  1. Click the Rules tab.
  2. Click Create Rule. Set parameters by referring to Table 1.

    Table 1 Rule parameters

    Parameter

    Description

    Rule Name

    Name of the custom rule. It can be customized. Example: SecH_test_01.

    The value contains only letters, digits, underscore (_), and must start with SecH_.

    Tool Rule Name

    The default value is the name of the rule source code file and cannot be changed.

    Tool

    Check tool used by your custom rule. Currently, only SecBrella is supported.

    Language

    Language checked by your custom rule. Currently, only Java is supported.

    Source Code

    Source code file of the rule.

    Create a .kirin file, create a domain-specific language (DSL) for rules, run the local plug-in to generate a SecH_Rule name_Random number.json file, and upload the JSON file.

    Severity

    The severity of code issues detected by this rule. The value can be Critical, Major, Minor, or Suggestion.

    Tag

    (Optional) Set a tag for the rule to distinguish the scenario where the rule is used.

    NOTE:

    Use commas (,) to separate multiple tags.

    Description

    Description of the rule. The content can contain code in Markdown. Max. 10,000 characters.

    Compliant Example

    Compliant code example. (Optional) The content contains code in Markdown. Max. 10,000 characters.

    Noncompliant Example

    Noncompliant code example. (Optional) The content contains code in Markdown. Max. 10,000 characters.

    Fix Suggestions

    Suggestions on rectifying issues. (Optional) The content can contain code in Markdown. Max. 10,000 characters.

  3. Click Create Rule.