mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 18:09:55 +00:00
fix: format headers (#1383)
Signed-off-by: DRAGON <anantvijay3@gmail.com>
This commit is contained in:
@@ -96,6 +96,8 @@ func prettyPrintListFormat(ctx context.Context, targetPolicy string, policies []
|
||||
policyTable.SetHeader([]string{header})
|
||||
policyTable.SetHeaderLine(true)
|
||||
policyTable.SetRowLine(true)
|
||||
policyTable.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
policyTable.SetAutoFormatHeaders(false)
|
||||
policyTable.SetAlignment(tablewriter.ALIGN_CENTER)
|
||||
policyTable.SetUnicodeHVC(tablewriter.Regular, tablewriter.Regular, gchalk.Ansi256(238))
|
||||
data := v2.Matrix{}
|
||||
@@ -126,6 +128,8 @@ func prettyPrintControls(ctx context.Context, policies []string) {
|
||||
controlsTable.SetAutoWrapText(false)
|
||||
controlsTable.SetHeaderLine(true)
|
||||
controlsTable.SetRowLine(true)
|
||||
controlsTable.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
controlsTable.SetAutoFormatHeaders(false)
|
||||
controlsTable.SetUnicodeHVC(tablewriter.Regular, tablewriter.Regular, gchalk.Ansi256(238))
|
||||
|
||||
controlRows := generateControlRows(policies)
|
||||
|
||||
@@ -141,14 +141,14 @@ func getControlTableHeaders(short bool) []string {
|
||||
var headers []string
|
||||
if short {
|
||||
headers = make([]string, 1)
|
||||
headers[0] = "CONTROLS"
|
||||
headers[0] = "Controls"
|
||||
} else {
|
||||
headers = make([]string, _rowLen)
|
||||
headers[columnName] = "CONTROL NAME"
|
||||
headers[columnCounterFailed] = "FAILED RESOURCES"
|
||||
headers[columnCounterAll] = "ALL RESOURCES"
|
||||
headers[columnSeverity] = "SEVERITY"
|
||||
headers[columnComplianceScore] = "% COMPLIANCE-SCORE"
|
||||
headers[columnName] = "Control Name"
|
||||
headers[columnCounterFailed] = "Failed Resources"
|
||||
headers[columnCounterAll] = "All Resources"
|
||||
headers[columnSeverity] = "Severity"
|
||||
headers[columnComplianceScore] = "% Compliane-Score"
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
const (
|
||||
docsPrefix = "https://hub.armosec.io/docs"
|
||||
scanControlPrefix = "$ kubescape scan control"
|
||||
controlNameHeader = "CONTROL NAME"
|
||||
controlNameHeader = "Control Name"
|
||||
statusHeader = ""
|
||||
docsHeader = "DOCS"
|
||||
resourcesHeader = "RESOURCES"
|
||||
runHeader = "VIEW DETAILS"
|
||||
docsHeader = "Docs"
|
||||
resourcesHeader = "Resources"
|
||||
runHeader = "View Details"
|
||||
)
|
||||
|
||||
// initializes the table headers and column alignments based on the category type
|
||||
@@ -84,6 +84,8 @@ func getCategoryTableWriter(writer io.Writer, headers []string, columnAligments
|
||||
table := tablewriter.NewWriter(writer)
|
||||
table.SetHeader(headers)
|
||||
table.SetHeaderLine(true)
|
||||
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetAutoFormatHeaders(false)
|
||||
table.SetColumnAlignment(columnAligments)
|
||||
table.SetAutoWrapText(false)
|
||||
table.SetUnicodeHVC(tablewriter.Regular, tablewriter.Regular, gchalk.Ansi256(238))
|
||||
|
||||
@@ -21,13 +21,13 @@ func TestInitCategoryTableData(t *testing.T) {
|
||||
{
|
||||
name: "Test1",
|
||||
categoryType: TypeCounting,
|
||||
expectedHeaders: []string{"CONTROL NAME", "RESOURCES", "VIEW DETAILS"},
|
||||
expectedHeaders: []string{"Control Name", "Resources", "View Details"},
|
||||
expectedAlignments: []int{tablewriter.ALIGN_LEFT, tablewriter.ALIGN_CENTER, tablewriter.ALIGN_LEFT},
|
||||
},
|
||||
{
|
||||
name: "Test2",
|
||||
categoryType: TypeStatus,
|
||||
expectedHeaders: []string{"", "CONTROL NAME", "DOCS"},
|
||||
expectedHeaders: []string{"", "Control Name", "Docs"},
|
||||
expectedAlignments: []int{tablewriter.ALIGN_CENTER, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_CENTER},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ func (fp *FrameworkPrinter) PrintSummaryTable(writer io.Writer, summaryDetails *
|
||||
|
||||
summaryTable.SetAutoWrapText(false)
|
||||
summaryTable.SetHeaderLine(true)
|
||||
summaryTable.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
summaryTable.SetAutoFormatHeaders(false)
|
||||
summaryTable.SetColumnAlignment(GetColumnsAlignments())
|
||||
summaryTable.SetUnicodeHVC(tablewriter.Regular, tablewriter.Regular, gchalk.Ansi256(238))
|
||||
|
||||
|
||||
@@ -32,14 +32,14 @@ func GetControlTableHeaders(short bool) []string {
|
||||
var headers []string
|
||||
if short {
|
||||
headers = make([]string, 1)
|
||||
headers[0] = "CONTROLS"
|
||||
headers[0] = "Controls"
|
||||
} else {
|
||||
headers = make([]string, _summaryRowLen)
|
||||
headers[summaryColumnName] = "CONTROL NAME"
|
||||
headers[summaryColumnCounterFailed] = "FAILED RESOURCES"
|
||||
headers[summaryColumnCounterAll] = "ALL RESOURCES"
|
||||
headers[summaryColumnSeverity] = "SEVERITY"
|
||||
headers[summaryColumnComplianceScore] = "% COMPLIANCE-SCORE"
|
||||
headers[summaryColumnName] = "Control Name"
|
||||
headers[summaryColumnCounterFailed] = "Failed Resources"
|
||||
headers[summaryColumnCounterAll] = "All Resources"
|
||||
headers[summaryColumnSeverity] = "Severity"
|
||||
headers[summaryColumnComplianceScore] = "% Compliance-Score"
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func TestWorkloadScan_InitCategoryTableData(t *testing.T) {
|
||||
|
||||
expectedHeader := []string{"", "CONTROL NAME", "DOCS"}
|
||||
expectedHeader := []string{"", "Control Name", "Docs"}
|
||||
expectedAlign := []int{tablewriter.ALIGN_CENTER, tablewriter.ALIGN_LEFT, tablewriter.ALIGN_CENTER}
|
||||
|
||||
workloadPrinter := NewWorkloadPrinter()
|
||||
|
||||
@@ -15,6 +15,8 @@ func renderTable(writer io.Writer, headers []string, columnAlignments []int, row
|
||||
table := tablewriter.NewWriter(writer)
|
||||
table.SetHeader(headers)
|
||||
table.SetHeaderLine(true)
|
||||
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetAutoFormatHeaders(false)
|
||||
table.SetColumnAlignment(columnAlignments)
|
||||
table.SetUnicodeHVC(tablewriter.Regular, tablewriter.Regular, gchalk.Ansi256(238))
|
||||
|
||||
@@ -64,11 +66,11 @@ func generateRow(cve CVE) []string {
|
||||
|
||||
func getImageScanningHeaders() []string {
|
||||
headers := make([]string, 5)
|
||||
headers[imageColumnSeverity] = "SEVERITY"
|
||||
headers[imageColumnName] = "VULNERABILITY"
|
||||
headers[imageColumnComponent] = "COMPONENT"
|
||||
headers[imageColumnVersion] = "VERSION"
|
||||
headers[imageColumnFixedIn] = "FIXED IN"
|
||||
headers[imageColumnSeverity] = "Severity"
|
||||
headers[imageColumnName] = "Vulnerability"
|
||||
headers[imageColumnComponent] = "Component"
|
||||
headers[imageColumnVersion] = "Version"
|
||||
headers[imageColumnFixedIn] = "Fixed In"
|
||||
return headers
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ func TestGenerateRow(t *testing.T) {
|
||||
func TestGetImageScanningHeaders(t *testing.T) {
|
||||
headers := getImageScanningHeaders()
|
||||
|
||||
expectedHeaders := []string{"SEVERITY", "VULNERABILITY", "COMPONENT", "VERSION", "FIXED IN"}
|
||||
expectedHeaders := []string{"Severity", "Vulnerability", "Component", "Version", "Fixed In"}
|
||||
|
||||
for i := range headers {
|
||||
if headers[i] != expectedHeaders[i] {
|
||||
|
||||
@@ -51,6 +51,8 @@ func (prettyPrinter *PrettyPrinter) resourceTable(opaSessionObj *cautils.OPASess
|
||||
summaryTable.SetAutoMergeCells(true)
|
||||
summaryTable.SetHeaderLine(true)
|
||||
summaryTable.SetRowLine(true)
|
||||
summaryTable.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
summaryTable.SetAutoFormatHeaders(false)
|
||||
summaryTable.SetUnicodeHVC(tablewriter.Regular, tablewriter.Regular, gchalk.Ansi256(238))
|
||||
|
||||
resourceRows := [][]string{}
|
||||
|
||||
Reference in New Issue
Block a user