Skip to content

Commit

Permalink
Fixed two issues with TableToMarkdown (#9834)
Browse files Browse the repository at this point in the history
Co-authored-by: hod-alpert <[email protected]>
  • Loading branch information
hod-alpert and hod-alpert authored Nov 8, 2020
1 parent b218ebe commit 8d55377
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Packs/Base/ReleaseNotes/1_3_33.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#### Scripts
##### CommonServerPowerShell
- Fixed a bug in **TableToMarkdown** where boolean values of *False* were not shown.
- Fixed parsing of nested lists in **TableToMarkdown**.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ Describe 'Check-UtilityFunctions' {
It "Check with a list of hashtables"{
$HashTableWithOneEntry | TableToMarkdown | Should -Be "| Index | Name`n| --- | ---`n| 0 | First element`n"
}
It "Check with False boolean that is not $null" {
@{test=$false} | TableToMarkdown | Should -Be "| test`n| ---`n| False`n"
}
It "Check with PSObject that nested list" {
$OneElementObject += New-Object PSObject -Property @{Index=1;Name=@('test1';'test2')}
$OneElementObject | TableToMarkdown | Should -Be "| Index | Name`n| --- | ---`n| 0 | First element`n| 1 | \[`"test1`",`"test2`"\]`n"
}

}
Context "Test stringEscapeMD" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ Function TableToMarkdown{
# Need to convert hashtables to ordered dicts so that the keys/values will be in the same order
$item = $item | ConvertTo-OrderedDict
}
elseif ($item -Is [PsCustomObject]){
$newItem = @{}
$item.PSObject.Properties | ForEach-Object { $newItem[$_.Name] = $_.Value }
$item = $newItem | ConvertTo-OrderedDict
}
$items += $item
}
}
Expand Down Expand Up @@ -527,7 +532,7 @@ End {
}
foreach ($raw_value in $raw_values)
{
if ($raw_value)
if ($null -ne $raw_value)
{
if ($raw_value -Is [System.Array] -Or $raw_value -Is [Collections.IDictionary] -Or $raw_value -Is [PSCustomObject])
{
Expand Down
2 changes: 1 addition & 1 deletion Packs/Base/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Base",
"description": "The base pack for Cortex XSOAR.",
"support": "xsoar",
"currentVersion": "1.3.32",
"currentVersion": "1.3.33",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 8d55377

Please sign in to comment.