Skip to content

Commit

Permalink
psPAS 6.2 (#529)
Browse files Browse the repository at this point in the history
* UPDATE Get-PASSession

Changes the way module scope information is stored and provided into the local scope of a user.
- Individual Script scope variables become properties of a single script scope object.
- additional information is available to the user
  - authentication time
  - session length
  - last command and result data

Update includes module wide changes to adopt new functionality.

* ✅➕UPDATE Get-PASSession

Update ensures any null values are reported, as well as output not being a reference to the module scope variables
Adds `Get-SessionClone` which creates deserialized clones of module scope variables

* 🚸⚗️Automatically Invoke PSM Connections

RDP and PSMGW connections will be automatically opened when issuing `New-PASPSMSession` connection request.
Adds code to output an especially formed html page to provide ability to initiate PSMGW connections, sending a POST request containing the PSMGWRequest to the PSMGWURL.

* ⏪ UPDATE Get-SessionClone

Undoing some code that deserialized the content of the output key values as it stopped some module functionality from working as expected.

* UPDATE New-PASSession

Adds logic around getting the logged on user name.
Current logged on user details are not able to be queried in recent versions of privilege cloud.
If the username is not able to be retrieved, the username from the used credential object is used instead. For other scenarios where the credential object cannot be used, the username is returned as a null value.

* UPDATE Get-PASSession

Adds `LastError` & `LastErrorTime` to output reported by `Get-PASSession`.
Whenever an error is encountered executing a psPAS command, it will be stored in the script scope object for easy retrieval and review in case correct parsing of the error is not possible or the error is reported clearly in the console.

* Update *-PASGroup* Commands

Standardises commands to accept numerical `GroupID` via the `ID` parameter.
Where parameter name has been changed from `GroupID` to `ID`, an alias for `GroupID` has been added to prevent breaking changes

* Update psPAS.CyberArk.Vault.PSM.Formats.ps1xml

Adds `Start` & `End` to standard table view output
Formats `Start` & `End` as standard datetime instead of unixtime

* Update CHANGELOG.md

* Create 2024-02-20-pspas-release-6-2.md

* Update CHANGELOG.md

version bump

* Update appveyor.yml

version bump
  • Loading branch information
pspete authored Feb 20, 2024
1 parent daa3f04 commit 20a9312
Show file tree
Hide file tree
Showing 368 changed files with 4,050 additions and 1,785 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@
### Added
- N/A

## **6.2.68**

### Added
- N/A

### Updated
- `Get-PASSession`
- makes additional information available to users running the command
- authentication time
- session length
- last command and result data
- last error details
- `New-PASPSMSession`
- RDP and PSMGW connections will be automatically opened when issuing connection request.
- `New-PASSession`
- Adds logic around getting the logged on user name for either self-hosted or privilege cloud deployments
- PSM Session Data Formats
- Adds `Start` & `End` to standard table view output
- Formats `Start` & `End` as standard datetime instead of unixtime.

### Fixed
- `Add-PASGroupMember`,`Remove-PASGroup`,`Set-PASGroup`
- Standardises name of `ID` parameter.
- Adds `GroupID` alias to `ID` parameter.

## **6.1.62**

### Added
- N/A

### Updated
- `Get-PASPSMRecording`
- Removes `Offset` Parameter
Expand Down
28 changes: 19 additions & 9 deletions Tests/Add-PASAccount.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -115,7 +125,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
'remoteMachines' = 'someMachine'
'accessRestrictedToRemoteMachines' = $false
}
$Script:ExternalVersion = '0.0'
$psPASSession.ExternalVersion = '0.0'

}

Expand All @@ -133,7 +143,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/WebServices/PIMServices.svc/Account"
$URI -eq "$($Script:psPASSession.BaseURI)/WebServices/PIMServices.svc/Account"

} -Times 1 -Exactly -Scope It

Expand All @@ -145,7 +155,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/api/Accounts"
$URI -eq "$($Script:psPASSession.BaseURI)/api/Accounts"

} -Times 1 -Exactly -Scope It

Expand Down Expand Up @@ -237,9 +247,9 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

It 'throws error if version requirement not met' {

$Script:ExternalVersion = '1.0'
$psPASSession.ExternalVersion = '1.0'
{ $InputObjV10 | Add-PASAccount } | Should -Throw
$Script:ExternalVersion = '0.0'
$psPASSession.ExternalVersion = '0.0'

}

Expand Down Expand Up @@ -269,7 +279,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
'automaticManagementEnabled' = $true
'remoteMachines' = 'someMachine'
}
$Script:ExternalVersion = '0.0'
$psPASSession.ExternalVersion = '0.0'

}

Expand Down
18 changes: 14 additions & 4 deletions Tests/Add-PASAccountACL.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -84,7 +94,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/WebServices/PIMServices.svc/Account/ServerA.domain.com|root|UNIXSSH/PrivilegedCommands/"
$URI -eq "$($Script:psPASSession.BaseURI)/WebServices/PIMServices.svc/Account/ServerA.domain.com|root|UNIXSSH/PrivilegedCommands/"

} -Times 1 -Exactly -Scope It

Expand Down
24 changes: 17 additions & 7 deletions Tests/Add-PASAccountGroupMember.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -80,7 +90,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/API/AccountGroups/88_8/Members"
$URI -eq "$($Script:psPASSession.BaseURI)/API/AccountGroups/88_8/Members"

} -Times 1 -Exactly -Scope It

Expand Down Expand Up @@ -111,10 +121,10 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

It 'throws error if version requirement not met' {
$Script:ExternalVersion = '1.0'
$Script:ExternalVersion = '1.0'
$psPASSession.ExternalVersion = '1.0'
$psPASSession.ExternalVersion = '1.0'
{ $InputObj | Add-PASAccountGroupMember } | Should -Throw
$Script:ExternalVersion = '0.0'
$psPASSession.ExternalVersion = '0.0'
}

}
Expand Down
22 changes: 16 additions & 6 deletions Tests/Add-PASAllowedReferrer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -54,7 +64,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/api/Configuration/AccessRestriction/AllowedReferrers"
$URI -eq "$($Script:psPASSession.BaseURI)/api/Configuration/AccessRestriction/AllowedReferrers"

} -Times 1 -Exactly -Scope It

Expand All @@ -77,9 +87,9 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

It 'throws error if version requirement not met' {
$Script:ExternalVersion = '1.0'
$psPASSession.ExternalVersion = '1.0'
{ Add-PASAllowedReferrer -referrerURL 'SomeURLValue' } | Should -Throw
$Script:ExternalVersion = '0.0'
$psPASSession.ExternalVersion = '0.0'
}

}
Expand Down
18 changes: 14 additions & 4 deletions Tests/Add-PASApplication.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -87,7 +97,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/WebServices/PIMServices.svc/Applications"
$URI -eq "$($Script:psPASSession.BaseURI)/WebServices/PIMServices.svc/Applications"

} -Times 1 -Exactly -Scope It

Expand Down
18 changes: 14 additions & 4 deletions Tests/Add-PASApplicationAuthenticationMethod.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -79,7 +89,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/WebServices/PIMServices.svc/Applications/SomeApplication/Authentications/"
$URI -eq "$($Script:psPASSession.BaseURI)/WebServices/PIMServices.svc/Applications/SomeApplication/Authentications/"

} -Times 1 -Exactly -Scope It

Expand Down
22 changes: 16 additions & 6 deletions Tests/Add-PASAuthenticationMethod.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -54,7 +64,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/api/Configuration/AuthenticationMethods"
$URI -eq "$($Script:psPASSession.BaseURI)/api/Configuration/AuthenticationMethods"

} -Times 1 -Exactly -Scope It

Expand All @@ -75,9 +85,9 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

It 'throws error if version requirement not met' {
$Script:ExternalVersion = '1.0'
$psPASSession.ExternalVersion = '1.0'
{ Add-PASAuthenticationMethod -id SomeID } | Should -Throw
$Script:ExternalVersion = '0.0'
$psPASSession.ExternalVersion = '0.0'
}

}
Expand Down
24 changes: 17 additions & 7 deletions Tests/Add-PASDirectory.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

$Script:RequestBody = $null
$Script:BaseURI = 'https://SomeURL/SomeApp'
$Script:ExternalVersion = '0.0'
$Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$psPASSession = [ordered]@{
BaseURI = 'https://SomeURL/SomeApp'
User = $null
ExternalVersion = [System.Version]'0.0'
WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
StartTime = $null
ElapsedTime = $null
LastCommand = $null
LastCommandTime = $null
LastCommandResults = $null
}

New-Variable -Name psPASSession -Value $psPASSession -Scope Script -Force

}

Expand Down Expand Up @@ -66,7 +76,7 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {

Assert-MockCalled Invoke-PASRestMethod -ParameterFilter {

$URI -eq "$($Script:BaseURI)/api/Configuration/LDAP/Directories"
$URI -eq "$($Script:psPASSession.BaseURI)/api/Configuration/LDAP/Directories"

} -Times 1 -Exactly -Scope It

Expand Down Expand Up @@ -97,10 +107,10 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') {
}

It 'throws error if version requirement not met' {
$Script:ExternalVersion = '1.0'
$Script:ExternalVersion = '1.0'
$psPASSession.ExternalVersion = '1.0'
$psPASSession.ExternalVersion = '1.0'
{ $InputObj | Add-PASDirectory } | Should -Throw
$Script:ExternalVersion = '0.0'
$psPASSession.ExternalVersion = '0.0'
}

}
Expand Down
Loading

0 comments on commit 20a9312

Please sign in to comment.