Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TtppObject may fail to parse valid object names #129

Closed
Saadi6 opened this issue Jul 11, 2022 · 2 comments · Fixed by #130
Closed

TtppObject may fail to parse valid object names #129

Saadi6 opened this issue Jul 11, 2022 · 2 comments · Fixed by #130
Assignees

Comments

@Saadi6
Copy link
Collaborator

Saadi6 commented Jul 11, 2022

Environment

Operating System: n/a
VenafiPS version: 4.4.0
PowerShell version: 5.1+
TPP version (if applicable): 21.4

Steps to reproduce

Create a team in TPP having a name with colon, for e.g. test::1. Fetching this team via Get-VenafiTeam will throw an error.
Get-VenafiTeam -All

Same can reproduced by creating a policy folder with colon characters in the name then using Get-TppObject to get this folder.

Expected behavior

This object should be fetched without throwing an error.

Actual behaviour

Although the object is fetched, following error is also thrown:

Split-Path: /Users/saad.humayun/Downloads/VenafiPS/VenafiPS/Classes/TppObject.ps1:17:22
Line |
  17 |          $this.Name = Split-Path -Path $this.Path -Leaf
     |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find a provider with the name '\VED\Identity\Test'. The name is not in the proper format. A provider name can only be
     | alphanumeric characters, or a PowerShell snap-in name that is followed by a single '\', followed by alphanumeric characters.

More Info

Split-Path function used by Tpp-Object does not allow all valid characters that can be used in the object names.

@Saadi6
Copy link
Collaborator Author

Saadi6 commented Jul 11, 2022

When the object is a Team, fetched via Get-VenafiTeam -All function, it appears to have all the properties present.
When the object is a Policy Folder or a Team fetched via Get-TppObject function, the name is missing and ParentPath is corrupted.

An error is thrown in both cases.

Get-TppObject -Path '\VED\Policy\Certificates\folder name::is valid'                        
Split-Path: /Users/saad.humayun/Downloads/VenafiPS/VenafiPS/Classes/TppObject.ps1:17:22
Line |
  17 |          $this.Name = Split-Path -Path $this.Path -Leaf
     |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find a provider with the name '\VED\Policy\Certificates\folder name'. The name is not in the proper format. A provider name
     | can only be alphanumeric characters, or a PowerShell snap-in name that is followed by a single '\', followed by alphanumeric
     | characters.


Name       : 
Path       : \VED\Policy\Certificates\folder name::is valid
TypeName   : Policy
Guid       : afa2b39c-bb1c-4e90-8d32-2532c7dfbf60
ParentPath : VEDPolicyCertificatesfolder name::is valid

Getting a Team by passing a known ID does not throw this error.
Get-VenafiTeam -ID 'prefixedUniversalId of test::01'

@gdbarron gdbarron self-assigned this Jul 11, 2022
@gdbarron
Copy link
Collaborator

gdbarron commented Jul 11, 2022

This is occurring because :: is a reserved character combination in PowerShell representing a Provider and Split-Path is interpreting it as such. In the module, Policy\Object paths are handled differently from Teams as the Team object is not a path comprised of parent and child name, it is just the name and the path is understood as \ved\identity.

We can look to change the way the object is determined from the entire path. With that said, I'm surprised to see a colon being used in a name as I've always seen that as against best practice.

gdbarron added a commit that referenced this issue Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants