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

bug: csv output of recommendation will result in wrong rows because of new lines #1627

Closed
mschwrdtnr opened this issue Sep 22, 2023 · 2 comments · Fixed by #1834
Closed

bug: csv output of recommendation will result in wrong rows because of new lines #1627

mschwrdtnr opened this issue Sep 22, 2023 · 2 comments · Fixed by #1834
Assignees
Labels
bug Something isn't working feature: output Issues that affect output and results
Milestone

Comments

@mschwrdtnr
Copy link

mschwrdtnr commented Sep 22, 2023

Description of the issue

I create the output as csv as follows:
Invoke-PSRule -Module 'PSRule.Rules.Azure' -InputPath .\*.json -Baseline 'Azure.All' -OutputFormat Csv -OutputPath .\export.csv

For some rules the recommendation includes a new line, e.g.

  • Azure.Resource.UseTags
  • Azure.AKS.PoolScaleSet
  • Azure.AKS.UseRBAC
  • Azure.AKS.PoolScaleSet

This behavior results in malformed csv, see code below:

"Azure.Resource.UseTags","aks-workerpool-xxxx-vmss","Microsoft.Compute/virtualMachineScaleSets","Pass","Processed","Azure resources should be tagged using a standard convention.","Consider tagging resources using a standard convention. Identify mandatory and optional tags then tag all resources and resource groups using this standard.
Also consider using Azure Policy to enforce mandatory tags."
"Azure.AKS.UseRBAC","aks","Microsoft.ContainerService/managedClusters","Pass","Processed","Deploy AKS cluster with role-based access control (RBAC) enabled.","Azure AD integration with AKS provides granular access control for Kubernetes resources using RBAC.
RBAC is a deployment time configuration. Consider redeploying the AKS cluster with RBAC enabled."

This result in a malformed csv, see img below:

grafik

To Reproduce

Steps to reproduce the issue:

Run the following command `Invoke-PSRule -Module 'PSRule.Rules.Azure' -InputPath .\*.json -Baseline 'Azure.All' -OutputFormat Csv -OutputPath .\export.csv`

Expected behaviour

New lines should not result in a new line in csv.

Module in use and version:

  • Module: PSRule.Azure
  • Version: *v2.9.0'

Captured output from $PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.2.11
PSEdition                      Core
GitCommitId                    7.2.11
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context

@mschwrdtnr mschwrdtnr changed the title csv output will result in wrong rows csv output will result in wrong rows because of new lines Sep 22, 2023
@mschwrdtnr mschwrdtnr changed the title csv output will result in wrong rows because of new lines csv output of recommendation will result in wrong rows because of new lines Sep 22, 2023
@mschwrdtnr
Copy link
Author

mschwrdtnr commented Sep 22, 2023

Looks like a problem in the way the output for recommendation is written

_Builder.Append(ViewStrings.Recommendation);

@mschwrdtnr mschwrdtnr changed the title csv output of recommendation will result in wrong rows because of new lines bug: csv output of recommendation will result in wrong rows because of new lines Sep 22, 2023
@BernieWhite
Copy link
Member

Thanks for reporting the issue @mschwrdtnr.

@BernieWhite BernieWhite added bug Something isn't working feature: output Issues that affect output and results labels Oct 2, 2023
@BernieWhite BernieWhite added this to the v3.0.0 milestone Oct 2, 2023
BernieWhite added a commit to BernieWhite/PSRule that referenced this issue May 24, 2024
@BernieWhite BernieWhite self-assigned this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature: output Issues that affect output and results
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants