potatoqualitee / tentools

💙 tenable.sc / nessus / acas powershell module
BSD 3-Clause "New" or "Revised" License
38 stars 7 forks source link

Fixes for saving files in correct name and format based on type. #104

Open chrisbensch opened 2 years ago

chrisbensch commented 2 years ago

Thank you for the feedback. I had considered putting the Type information somewhere else, but the ConvertFrom-TNRestResponse.ps1 is where this data is stripped off the object. No matter what I've done, after data has been piped through this it's gone forever. I'm not sure why it gets stripped off when it's clearly there, but the output of this is always missing the 'type' property. I'll keep trying.

Thanks!

On Tue, Nov 30, 2021 at 3:09 PM Chrissy LeMaire @.***> wrote:

@.**** requested changes on this pull request.

Thanks so much for the PR! Just need one change.

In public/ConvertFrom-TNRestResponse.ps1 https://github.com/potatoqualitee/tentools/pull/104#discussion_r759372120 :

@@ -156,7 +156,7 @@ if ('Id' -in $keys) { $null = $order.Add("Id") }

  • if ($Type) {
  • if ('Type') {

This will always return $true. You can test it from your command line

if ('Type') { write-warning hello } WARNING: hello

Instead, change it back to $Type and perhaps pass a -Type elsewhere, likely in Save-TNReportResult.

In public/Save-TNReportResult.ps1 https://github.com/potatoqualitee/tentools/pull/104#discussion_r759372639 :

@@ -44,7 +44,7 @@ function Save-TNReportResult { Stop-PSFFunction -EnableException:$EnableException -Message "Only tenable.sc supported" -Continue } foreach ($file in $InputObject) {

  • $filename = Join-Path -Path $Path -ChildPath "$($file.Name.Split([IO.Path]::GetInvalidFileNameChars()) -join '')-$($file.Id)-reportresults.zip"
  • $filename = Join-Path -Path $Path -ChildPath "$($file.Name.Split([IO.Path]::GetInvalidFileNameChars()) -join '')-$($file.Id)-reportresults.$($file.Type)"

Perfect!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/potatoqualitee/tentools/pull/104#pullrequestreview-819159416, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHYPPDPU6D3GZJZK74I3HTUOTSLTANCNFSM5JCANWPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

chrisbensch commented 2 years ago

I'm not sure if email is the right way to go about this, but I tried the following:

if ('Type' -in $keys) { $null = $order.Add("Type")

This works and saves the files correctly and it seems as it would work with not always being $true, unless I'm really offbase.

On Tue, Nov 30, 2021 at 3:41 PM Chris Bensch @.***> wrote:

Thank you for the feedback. I had considered putting the Type information somewhere else, but the ConvertFrom-TNRestResponse.ps1 is where this data is stripped off the object. No matter what I've done, after data has been piped through this it's gone forever. I'm not sure why it gets stripped off when it's clearly there, but the output of this is always missing the 'type' property. I'll keep trying.

Thanks!

On Tue, Nov 30, 2021 at 3:09 PM Chrissy LeMaire @.***> wrote:

@.**** requested changes on this pull request.

Thanks so much for the PR! Just need one change.

In public/ConvertFrom-TNRestResponse.ps1 https://github.com/potatoqualitee/tentools/pull/104#discussion_r759372120 :

@@ -156,7 +156,7 @@ if ('Id' -in $keys) { $null = $order.Add("Id") }

  • if ($Type) {
  • if ('Type') {

This will always return $true. You can test it from your command line

if ('Type') { write-warning hello } WARNING: hello

Instead, change it back to $Type and perhaps pass a -Type elsewhere, likely in Save-TNReportResult.

In public/Save-TNReportResult.ps1 https://github.com/potatoqualitee/tentools/pull/104#discussion_r759372639 :

@@ -44,7 +44,7 @@ function Save-TNReportResult { Stop-PSFFunction -EnableException:$EnableException -Message "Only tenable.sc supported" -Continue } foreach ($file in $InputObject) {

  • $filename = Join-Path -Path $Path -ChildPath "$($file.Name.Split([IO.Path]::GetInvalidFileNameChars()) -join '')-$($file.Id)-reportresults.zip"
  • $filename = Join-Path -Path $Path -ChildPath "$($file.Name.Split([IO.Path]::GetInvalidFileNameChars()) -join '')-$($file.Id)-reportresults.$($file.Type)"

Perfect!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/potatoqualitee/tentools/pull/104#pullrequestreview-819159416, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHYPPDPU6D3GZJZK74I3HTUOTSLTANCNFSM5JCANWPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

chrisbensch commented 2 years ago

I think I was able to solve the $true issue, but I will need you to validate it works as expected.

potatoqualitee commented 2 years ago

hey chris, sorry for the delay. my shoulder is all messed up, so i'll likely be able to take a look on Monday, i'll be in touch then!

potatoqualitee commented 2 years ago

this looks great! does it work for you? (the tests dont work bc of a limitation with my repo secrets)

chrisbensch commented 2 years ago

Yes, these work for me. I tested them officially today and it's good to go!

On Tue, Dec 7, 2021 at 3:22 PM Chrissy LeMaire @.***> wrote:

this looks great! does it work for you? (the tests dont work bc of a limitation with my repo secrets)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/potatoqualitee/tentools/pull/104#issuecomment-988027036, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHYPPEIV72QDW6UZHOHOSTUPYRERANCNFSM5JCANWPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.