soteria-security / 365Inspect

A PowerShell script that automates the security assessment of Microsoft 365 environments.
https://soteria.io/solutions/soteria-inspect/
MIT License
577 stars 109 forks source link

CSV and XML Problems with various columns #47

Closed asterictnl-lvdw closed 2 years ago

asterictnl-lvdw commented 2 years ago

Describe the bug When you export to a CSV or XML, because of the column limit the Finding, AffectedObjects, Remediation and References property will bug the whole CSV file.

To Reproduce Steps to reproduce the behavior:

  1. Execute normally
  2. View the .CSV file for the results

Expected behavior A clean CSV file where you eventually could convert to colums by selecting the , delimiter.

Desktop (please complete the following information):

Additional context To make it work properly you can comment out the Finding, AffectedObjects, Remediation and References Add-Member scripts at both XML and CSV to get a clean .CSV file.

ThoughtContagion commented 2 years ago

We believe the issue is a result of failing to define a delimiter character in the script. Delimiting on a comma character may result in unwanted behavior as some of the affected objects results return comma separated lists. We will work on a better method of exporting to the various formats.

asterictnl-lvdw commented 2 years ago

For now is the workaround to disable the following lines:

$result | Add-Member -MemberType NoteProperty -name Finding -Value $finding.Description -ErrorAction SilentlyContinue
$result | Add-Member -MemberType NoteProperty -name AffectedObjects -Value $("$($finding.AffectedObjects)" | Out-String).Trim() -ErrorAction SilentlyContinue
$result | Add-Member -MemberType NoteProperty -name Remediation -Value $finding.Remediation -ErrorAction SilentlyContinue
$result | Add-Member -MemberType NoteProperty -name References -Value $($refs | Out-String)  -ErrorAction SilentlyContinue

Those lines might have problems with the delimitation and or the objects exceeding more than 255 characters per column.

asterictnl-lvdw commented 2 years ago

Looks good. Will test it out with the private version and report back the results.

~Leonardo