en-GB/about_PSRule_SuppressionGroups.help.txt
TOPIC
about_psrule_suppressiongroups SHORT DESCRIPTION Describes PSRule Suppression Groups including how to use and author them. LONG DESCRIPTION PSRule executes rules to validate an object from input. When an evaluating an object from input, PSRule can use suppression groups to suppress rules based on a Selector . Defining suppression groups Suppression groups can be defined with either YAML or JSON format, and can be included with a module or a standalone `.Rule.yaml` or `.Rule.jsonc` file. In either case, define a suppression group within a file ending with the `.Rule.yaml` or `.Rule.jsonc` extension. A suppression group can be defined side-by-side with other resources such as rules, baselines or module configurations. Suppression groups can also be defined within `.json` files. We recommend using `.jsonc` to view JSON with Comments in Visual Studio Code. Use the following template to define a suppression group: ```yaml SYNOPSIS: {{ SYNOPSIS }} apiVersion: github.com/microsoft/PSRule/v1 kind: SuppressionGroup metadata: name: '{{ Name }}' spec: rule: [] if: { } jsonc [ { // Synopsis: {{ Synopsis }} "apiVersion": "github.com/microsoft/PSRule/v1", "kind": "SuppressionGroup", "metadata": { "name": "{{ Name }}" }, "spec": { "rule": [], "if": {} } } ] Within the `rule` array, one or more rule names can be used. If no rules are specified, suppression will occur for all rules. Within the `if` object, one or more conditions or logical operators can be used. When the `if` condition is `true` the object will be suppressed for the current rule. ## EXAMPLES ### Example SuppressionGroups.Rule.yaml yaml EXAMPLE SUPPRESSIONGROUPS.RULE.YAML --- SYNOPSIS: SUPPRESS WITH TARGET NAME apiVersion: github.com/microsoft/PSRule/v1 kind: SuppressionGroup metadata: name: SuppressWithTargetName spec: rule: - 'FromFile1' - 'FromFile2' if: name: '.' in: - 'TestObject1' - 'TestObject2' --- SYNOPSIS: SUPPRESS WITH TARGET TYPE apiVersion: github.com/microsoft/PSRule/v1 kind: SuppressionGroup metadata: name: SuppressWithTestType spec: rule: - 'FromFile3' - 'FromFile5' if: type: '.' equals: 'TestType' ### Example SuppressionGroups.Rule.jsonc jsonc // Example SuppressionGroups.Rule.jsonc [ { // Synopsis: Suppress with target name "apiVersion": "github.com/microsoft/PSRule/v1", "kind": "SuppressionGroup", "metadata": { "name": "SuppressWithTargetName" }, "spec": { "rule": [ "FromFile1", "FromFile2" ], "if": { "name": ".", "in": [ "TestObject1", "TestObject2" ] } } }, { // Synopsis: Suppress with target type "apiVersion": "github.com/microsoft/PSRule/v1", "kind": "SuppressionGroup", "metadata": { "name": "SuppressWithTestType" }, "spec": { "rule": [ "FromFile3", "FromFile5" ], "if": { "type": ".", "equals": "TestType" } } } ] ``` NOTE An online version of this document is available at https://microsoft.github.io/PSRule/v2/concepts/PSRule/en-US/about_PSRule_SuppressionGroups/. SEE ALSO - Invoke-PSRule KEYWORDS - SuppressionGroups - Selectors - PSRule |