How to export rules severity, pillar and pillar subcategory #1986
-
In order to classify rules, I'd like to build an excel file in which I can classify rules by WAF pillar or severity..CSV does not include this columns and I can't find a way to do it using powershell :( . Any hint or is it a new feature request ? :) TIA |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
The list of columns in the built-in CSV output method is not configurable. There is a issue over here to make this more customizable microsoft/PSRule#1165. For results, you could call Invoke-PSRule -f . -Format File -Outcome Fail | Select-Object RuleName, @{ Name = "Severity"; Expression = { $_.Info.Annotations.severity }}, @{ Name = "Pillar"; Expression = { $_.Info.Annotations.pillar }} | ConvertTo-Csv | Set-Content -Path out.csv For exporting the pillar and severity data for merging in you could use Get-PSRule -Module PSRule.Rules.Azure | Select-Object RuleName, @{ Name = "Severity"; Expression = { $_.Info.Annotations.severity }}, @{ Name = "Pillar"; Expression = { $_.Info.Annotations.pillar }} I hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Hi @BernieWhite, i created a small powershell script which adds Pillar, Severity and Category to the csv export. Is there any way i can contribute it in this project? |
Beta Was this translation helpful? Give feedback.
-
I have found an alternate approach to get this done. Here are the steps: Step 1: As @BernieWhite mentioned run the below command to create a master reference sheet. This sheet carries the Azure Rule name, Severity and the WAF Pillar. Save this CSV as excel and this is your baseline for WAF assessment. Step 2: Run the following command to get the analysis report. ** Here you can declare the $path variable with your preferable location where the JSON is living. Save the CSV as a excel file to help in further Step 3. Step 3: Run a excel vlookup on the excel from step 2 with excel from step 1 as a reference (use the Azure Rule Name as a reference). Excel will do the rest and you get an amazing report covering all that you need. I am attaching screenshot from my demo azure lab environment so you see the fields. Once again this is not a 100% automated solution , but does the job :) |
Beta Was this translation helpful? Give feedback.
The list of columns in the built-in CSV output method is not configurable. There is a issue over here to make this more customizable microsoft/PSRule#1165.
For results, you could call
Invoke-PSRule
andSelect-Object
to expose the specific columns you are looking for.For exporting the pillar and severity data for merging in you could use
Get-PSRule
to export details for each rule: