1
1
---
2
+ description : This article contains notes on breaking changes in PSRule v3 to help you upgrade from a previous version.
2
3
author : BernieWhite
3
4
discussion : false
4
5
---
5
6
6
- # Deprecations
7
+ # Deprecations and breaking changes
7
8
8
- This article contains notes on features that are deprecated in PSRule v3.0.0 and later .
9
+ This article contains notes on breaking changes in PSRule v3 to help you upgrade from a previous version .
9
10
10
- ## Deprecations for v3
11
-
12
- ### Execution options
11
+ ## Execution options
13
12
14
13
PSRule provides a number of execution options that control logging of certain events.
15
14
In many cases these options turn a warning on or off.
@@ -45,7 +44,7 @@ The following execution options have been deprecated and will be removed from _v
45
44
You do not need to configure both options.
46
45
If you have the deprecated option configured, switch to the new option.
47
46
48
- ### Git Head input object
47
+ ## Git Head input object
49
48
50
49
Previously when the ` Input.Format ` option was set to ` File ` the ` .git/HEAD ` file was emitted as an input object.
51
50
The original purpose of this feature was to allow conventions to run once against the root of the repository.
@@ -56,7 +55,7 @@ From _v3_ the `.git/HEAD` file will no longer be emitted as an input object.
56
55
Consider adding or updating a convention that uses the ` -Initialize ` block to emit run initialization logic.
57
56
Yon can also use the ` -Initialize ` block to emit a custom object to the pipeline by using the ` $PSRule.ImportWithType ` method.
58
57
59
- ### Rule output object
58
+ ## Rule output object
60
59
61
60
Several properties of the rule object have been renamed to improve consistency with other objects.
62
61
Previously rules returned by ` Get-PSRule ` returned a rule object which included the following properties:
@@ -80,7 +79,7 @@ From _v3_ these properties will be removed.
80
79
These changes do not affect normal usage of PSRule.
81
80
Supporting scripts that directly use the old names may not work correctly until you update these names.
82
81
83
- ### Language block interface
82
+ ## Language block interface
84
83
85
84
Several properties of Baselines and Selectors have been renamed to improve consistency.
86
85
@@ -97,7 +96,7 @@ From _v3_ these properties will be removed.
97
96
These changes do not affect normal usage of PSRule.
98
97
Supporting scripts that directly use the old names may not work correctly until you update these names.
99
98
100
- ### Binding configuration in baselines
99
+ ## Binding configuration in baselines
101
100
102
101
Prior to v3, a baseline could configure a binding configuration to modify how objects are recognized by name, type, and scope.
103
102
This existed to support scenarios before a module configuration and language scopes where core to how PSRule operates.
@@ -108,9 +107,99 @@ This existed to support scenarios before a module configuration and language sco
108
107
109
108
Configuring binding configuration on a baseline is removed from PSRule v3.
110
109
111
- ### Binding hooks
110
+ ## Binding hooks
112
111
113
112
Prior to v3, a custom binding PowerShell script block could be used to perform custom binding inline.
114
113
This feature was hard to use and obsolete for most common use cases.
115
114
116
115
Alternatively, configure ` Binding.TargetName ` and ` Binding.TargetType ` options to use the built-in binder.
116
+
117
+
118
+ ## Unbound object names
119
+
120
+ When an object is processed by PSRule, it is assigned a name.
121
+ This name is used to identify the object in the output and to suppress the object from future processing.
122
+
123
+ Prior to _ v3.0.0_ , the name was generated using a SHA-1 hash of the object.
124
+ The SHA-1 algorithm is no longer considered secure and has been replaced with SHA-512.
125
+
126
+ From _ v3.0.0_ , if the name of an object can not be determined, the SHA-512 hash of the object will be used.
127
+ Any objects that have previously been suppressed with a name based on a SHA-1 hash will no longer be suppressed.
128
+
129
+ To resolve any issue caused by this change, you can:
130
+
131
+ 1 . Configure binding by setting the [ Binding.TargetName] [ 1 ] option to set an alternative property to use as the name. _ OR_
132
+ 2 . Update any existing keys set with the [ Suppression] [ 2 ] option to use the new SHA-512 hash.
133
+
134
+ [ 1 ] : https://aka.ms/ps-rule/options#bindingtargetname
135
+ [ 2 ] : https://aka.ms/ps-rule/options#suppression
136
+
137
+ ## Using PowerShell 7.4 or later
138
+
139
+ From _ v3.0.0_ , PSRule requires:
140
+
141
+ - Windows PowerShell 5.1 for running as a PowerShell module. _ OR_
142
+ - PowerShell 7.4 or later for development, building locally, or running as a PowerShell module.
143
+
144
+ Support for Windows PowerShell 5.1 is deprecated and will be removed in a future release of PSRule (v4).
145
+ We recommend upgrading to PowerShell 7.4 or later.
146
+
147
+ ## Changes to CLI commands
148
+
149
+ From _ v3.0.0_ , the CLI command names have been renamed to simplify usage.
150
+ The following changes have been made:
151
+
152
+ - To run rules, use ` run ` instead of ` analyze ` . i.e. ` ps-rule run ` .
153
+ - To restore modules for a workspace, use ` module restore ` instead of ` restore ` . i.e. ` ps-rule module restore ` .
154
+
155
+ The ` run ` command provides similar output to the ` Assert-PSRule ` cmdlet in PowerShell.
156
+
157
+ Previously the ` restore ` command installed modules based on the configuration of the [ Requires] [ 3 ] option.
158
+ From _ v3.0.0_ , the ` module restore ` command installs modules based on:
159
+
160
+ - The module lock file ` ps-rule.lock.json ` if set.
161
+ Use ` module ` [ CLI commands] [ 5 ] to manage the [ lock file] [ 6 ] . _ AND_
162
+ - Modules defined in the [ Include.Module] [ 4 ] option, if set.
163
+ Additionally the [ Requires] [ 3 ] option is used to constrain the version of modules installed.
164
+
165
+ [ 3 ] : concepts/PSRule/en-US/about_PSRule_Options.md#requires
166
+ [ 4 ] : concepts/PSRule/en-US/about_PSRule_Options.md#includemodule
167
+ [ 5 ] : concepts/cli/module.md
168
+ [ 6 ] : concepts/lockfile.md
169
+
170
+ ## Version and APIVersion accept stable
171
+
172
+ Prior to _ v3.0.0_ , some usage of ` version ` and ` apiVersion ` accepted pre-release versions by default.
173
+ For example:
174
+
175
+ ``` yaml
176
+ ---
177
+ # Synopsis: Any version example
178
+ apiVersion : github.com/microsoft/PSRule/v1
179
+ kind : Selector
180
+ metadata :
181
+ name : PreviousAnyVersionExample
182
+ spec :
183
+ if :
184
+ field : dateVersion
185
+ apiVersion : ' '
186
+ ` ` `
187
+
188
+ When ` apiVersion` is empty any version is accepted including pre-releases.
189
+
190
+ From _v3.0.0_ pre-release versions are not accepted by default.
191
+ Set the `includePrerelease` property to `true`.
192
+
193
+ ` ` ` yaml
194
+ ---
195
+ # Synopsis: Test comparison with apiVersion.
196
+ apiVersion: github.com/microsoft/PSRule/v1
197
+ kind: Selector
198
+ metadata:
199
+ name: AnyVersion
200
+ spec:
201
+ if:
202
+ field: dateVersion
203
+ apiVersion: ''
204
+ includePrerelease: true
205
+ ` ` `
0 commit comments