Skip to content

Commit

Permalink
fix: configaudit summary data not presented (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan committed Jun 28, 2022
1 parent ba3add6 commit 2fc1c5d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 49 deletions.
3 changes: 0 additions & 3 deletions src/configauditreports/checks-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ interface Props {
const severityOrder = new Map([
["CRITICAL", 0],
["HIGH", 1],
["danger", 2],
["MEDIUM", 3],
["warning", 4],
["LOW", 5],
["UNKNOWN", 6],
])

const BySeverity = (v1: Check, v2: Check) => {
Expand Down
17 changes: 13 additions & 4 deletions src/configauditreports/details.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
.ConfigAuditReportDetails {
.summary {
.Badge {

&.theme-danger {
&.theme-critical {
color: white;
background-color: #cc1814;
}

&.theme-warning {
&.theme-high {
color: white;
background-color: #ffa500;
}

&.theme-pass {
&.theme-medium {
color: white;
background-color: #f0c20c;
}

&.theme-low {
color: white;
background-color: #096ab0;
}

&.theme-negligible {
color: white;
background-color: #00b09b;
}
Expand Down
42 changes: 24 additions & 18 deletions src/configauditreports/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ export class ClusterConfigAuditReportDetails extends React.Component<ClusterConf
object={report}
hideFields={["uid", "resourceVersion", "selfLink"]}/>}
<DrawerItem name="Summary" className="summary" labelsOnly>
<Badge className="Badge theme-danger"
label={summary.dangerCount}
tooltip="Danger"/>
<Badge className="Badge theme-warning"
label={summary.warningCount}
tooltip="Warning"/>
<Badge className="Badge theme-pass"
label={summary.passCount}
tooltip="Pass"/>
<Badge className="Badge theme-critical"
label={report.report.summary.criticalCount}
tooltip="Critical"/>
<Badge className="Badge theme-high"
label={report.report.summary.highCount}
tooltip="High"/>
<Badge className="Badge theme-medium"
label={report.report.summary.mediumCount}
tooltip="Medium"/>
<Badge className="Badge theme-low"
label={report.report.summary.lowCount}
tooltip="Low"/>
</DrawerItem>
<ChecksList checks={checks}/>
</div>
Expand Down Expand Up @@ -77,15 +80,18 @@ export class ConfigAuditReportDetails extends React.Component<ConfigAuditReportD
object={report}
hideFields={["uid", "resourceVersion", "selfLink"]}/>}
<DrawerItem name="Summary" className="summary" labelsOnly>
<Badge className="Badge theme-danger"
label={summary.dangerCount}
tooltip="Danger"/>
<Badge className="Badge theme-warning"
label={summary.warningCount}
tooltip="Warning"/>
<Badge className="Badge theme-pass"
label={summary.passCount}
tooltip="Pass"/>
<Badge className="Badge theme-critical"
label={report.report.summary.criticalCount}
tooltip="Critical"/>
<Badge className="Badge theme-high"
label={report.report.summary.highCount}
tooltip="High"/>
<Badge className="Badge theme-medium"
label={report.report.summary.mediumCount}
tooltip="Medium"/>
<Badge className="Badge theme-low"
label={report.report.summary.lowCount}
tooltip="Low"/>
</DrawerItem>
<ChecksList checks={checks}/>
</div>
Expand Down
49 changes: 28 additions & 21 deletions src/configauditreports/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const {
enum sortBy {
name = "name",
namespace = "namespace",
pass = "pass",
danger = "danger",
warning = "warning",
critical = "critical",
high = "high",
medium = "medium",
low = "low",
scanner = "scanner"
}

Expand All @@ -28,9 +29,10 @@ export class ClusterConfigAuditReportPage extends React.Component<{ extension: R
className="ConfigAuditReports" store={clusterStore}
sortingCallbacks={{
[sortBy.name]: (report: ClusterConfigAuditReport) => report.getName(),
[sortBy.danger]: (report: ClusterConfigAuditReport) => report.report.summary.dangerCount,
[sortBy.warning]: (report: ClusterConfigAuditReport) => report.report.summary.warningCount,
[sortBy.pass]: (report: ClusterConfigAuditReport) => report.report.summary.passCount,
[sortBy.critical]: (report: ClusterConfigAuditReport) => report.report.summary.criticalCount,
[sortBy.high]: (report: ClusterConfigAuditReport) => report.report.summary.highCount,
[sortBy.medium]: (report: ClusterConfigAuditReport) => report.report.summary.mediumCount,
[sortBy.low]: (report: ClusterConfigAuditReport) => report.report.summary.lowCount,
[sortBy.scanner]: (report: ClusterConfigAuditReport) => report.report.scanner.name + " " + report.report.scanner.version,
}}
searchFilters={[
Expand All @@ -39,17 +41,19 @@ export class ClusterConfigAuditReportPage extends React.Component<{ extension: R
renderHeaderTitle="ClusterConfigAuditReports"
renderTableHeader={[
{title: "Name", sortBy: sortBy.name},
{title: "Danger", sortBy: sortBy.danger},
{title: "Warning", sortBy: sortBy.warning},
{title: "Pass", sortBy: sortBy.pass},
{title: "Critical", sortBy: sortBy.critical},
{title: "High", sortBy: sortBy.high},
{title: "Medium", sortBy: sortBy.medium},
{title: "Low", sortBy: sortBy.low},
{title: "Scanner", sortBy: sortBy.scanner},
]}
renderTableContents={(report: ClusterConfigAuditReport) => [
<Badge flat expandable={false} key="name" label={report.getName()}
tooltip={report.getName()}/>,
report.report.summary.dangerCount,
report.report.summary.warningCount,
report.report.summary.passCount,
report.report.summary.criticalCount,
report.report.summary.highCount,
report.report.summary.mediumCount,
report.report.summary.lowCount,
report.report.scanner.name + " " + report.report.scanner.version,
]}
/>
Expand All @@ -67,9 +71,10 @@ export class ConfigAuditReportPage extends React.Component<{ extension: Renderer
sortingCallbacks={{
[sortBy.name]: (report: ConfigAuditReport) => report.getName(),
[sortBy.namespace]: (report: ConfigAuditReport) => report.metadata.namespace,
[sortBy.danger]: (report: ConfigAuditReport) => report.report.summary.dangerCount,
[sortBy.warning]: (report: ConfigAuditReport) => report.report.summary.warningCount,
[sortBy.pass]: (report: ConfigAuditReport) => report.report.summary.passCount,
[sortBy.critical]: (report: ConfigAuditReport) => report.report.summary.criticalCount,
[sortBy.high]: (report: ConfigAuditReport) => report.report.summary.highCount,
[sortBy.medium]: (report: ConfigAuditReport) => report.report.summary.mediumCount,
[sortBy.low]: (report: ConfigAuditReport) => report.report.summary.lowCount,
[sortBy.scanner]: (report: ClusterConfigAuditReport) => report.report.scanner.name + " " + report.report.scanner.version,
}}
searchFilters={[
Expand All @@ -79,19 +84,21 @@ export class ConfigAuditReportPage extends React.Component<{ extension: Renderer
renderTableHeader={[
{title: "Name", sortBy: sortBy.name},
{title: "Namespace", sortBy: sortBy.namespace},
{title: "Danger", sortBy: sortBy.danger},
{title: "Warning", sortBy: sortBy.warning},
{title: "Pass", sortBy: sortBy.pass},
{title: "Critical", sortBy: sortBy.critical},
{title: "High", sortBy: sortBy.high},
{title: "Medium", sortBy: sortBy.medium},
{title: "Low", sortBy: sortBy.low},
{title: "Scanner", sortBy: sortBy.scanner},

]}
renderTableContents={(report: ConfigAuditReport) => [
<Badge flat expandable={false} key="name" label={report.getName()}
tooltip={report.getName()}/>,
report.metadata.namespace,
report.report.summary.dangerCount,
report.report.summary.warningCount,
report.report.summary.passCount,
report.report.summary.criticalCount,
report.report.summary.highCount,
report.report.summary.mediumCount,
report.report.summary.lowCount,
report.report.scanner.name + " " + report.report.scanner.version,
]}
/>
Expand Down
7 changes: 4 additions & 3 deletions src/configauditreports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import {Renderer} from "@k8slens/extensions";
import {Scanner} from "../trivy_operator/types";

export type Summary = {
passCount?: number;
dangerCount: number;
warningCount: number;
criticalCount: number;
highCount: number;
mediumCount: number;
lowCount: number;
}

export class Check {
Expand Down

0 comments on commit 2fc1c5d

Please sign in to comment.