pspete / psPAS

PowerShell module for CyberArk Privileged Access Security REST API
https://pspas.pspete.dev
MIT License
295 stars 91 forks source link

Set-PASSafe -NumberOfDaysRetention parameter does not accept zero #493

Closed bldevcode closed 12 months ago

bldevcode commented 12 months ago

Describe the issue Set-PASSafe -NumberOfDaysRetention parameter does not accept zero as a value, while Add-PASSafe -NumberOfDaysRetention does. In swagger it is possible to set an existing safe to NumberOfDaysRetention.

To Reproduce Steps to reproduce the behavior:

  1. Add-PASSafe -SafeName MySafe -NumberOfDaysRetention 0 <-- successful
  2. Set-PASSafe -SafeName MySafe -NumberOfDaysRetention 1 <-- successful
  3. Set-PASSafe -SafeName MySafe -NumberOfDaysRetention 0 <-- this will result in an error

Expected behavior Zero should be accepted for Set-PASSafe -NumberOfDaysRetention parameter

Screenshots & Console Output If applicable, add screenshots and/or console output to help explain your problem.


PS C:\Scripts\PAM> Add-PASSafe -SafeName MySafe -NumberOfDaysRetention 0

SafeName ManagingCPM NumberOfDaysRetention NumberOfVersionsRetention Description
-------- ----------- --------------------- ------------------------- -----------
MySafe               0

PS C:\Scripts\PAM> Set-PASSafe -SafeName MySafe -NumberOfDaysRetention 1

SafeName ManagingCPM NumberOfDaysRetention NumberOfVersionsRetention Description
-------- ----------- --------------------- ------------------------- -----------
MySafe               1

PS C:\Scripts\PAM> Set-PASSafe -SafeName MySafe -NumberOfDaysRetention 0
Set-PASSafe : Cannot validate argument on parameter 'NumberOfDaysRetention'. The 0 argument is less than the minimum allowed range of 1. Supply an argument that is greater than or equal to 1 and then try the command again.

Your Environment Include relevant details about your environment

Additional context In Add-PASSafe:

                [parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true,
            ParameterSetName = 'Gen1-NumberOfDaysRetention'
        )]
        [parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true,
            ParameterSetName = 'NumberOfDaysRetention'
        )]
        [ValidateRange(0, 3650)]
        [int]$NumberOfDaysRetention,

While in Set-PASSafe:

                [Parameter(
            Mandatory = $true,
            ValueFromPipelinebyPropertyName = $true,
            ParameterSetName = 'Gen2-NumberOfDaysRetention'
        )]
        [parameter(
            Mandatory = $false,
            ValueFromPipelinebyPropertyName = $true,
            ParameterSetName = 'Gen1-NumberOfDaysRetention'
        )]
        [ValidateRange(1, 3650)]
        [int]$NumberOfDaysRetention,
pspete commented 12 months ago

Good spot. Add-PASSafe was updated after #450 Set-PASSafe was missed.