Skip to content

Commit c3fdb80

Browse files
committed
feat: hide licenses from imageScan if null
1 parent 8a453af commit c3fdb80

File tree

5 files changed

+98
-82
lines changed

5 files changed

+98
-82
lines changed

src/Shared/Components/Security/SecurityModal/SecurityModal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@ const SecurityModal: React.FC<SecurityModalPropsType> = ({
157157
modalState={state}
158158
setModalState={setState}
159159
categoriesConfig={{
160-
imageScan: !!data.imageScan,
161-
codeScan: !!data.codeScan,
162-
kubernetesManifest: !!data.kubernetesManifest,
160+
imageScan: !!data?.imageScan,
161+
imageScanLicenseRisks: !!data?.imageScan?.license,
162+
codeScan: !!data?.codeScan,
163+
kubernetesManifest: !!data?.kubernetesManifest,
163164
}}
164165
/>
165166
)}

src/Shared/Components/Security/SecurityModal/config/CodeScan.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ const getCompletedEmptyState = (
454454
detailViewData: DetailViewDataType,
455455
) => {
456456
/* NOTE: show empty state only when we don't have any data to show */
457-
if ((data[subCategory]?.list && !detailViewData) || detailViewData?.rows) {
457+
if ((data[subCategory]?.list?.length && !detailViewData) || detailViewData?.rows) {
458458
return null
459459
}
460460

src/Shared/Components/Security/SecurityModal/config/Sidebar.ts

Lines changed: 92 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6,82 +6,98 @@ import { CATEGORY_LABELS, SUB_CATEGORY_LABELS } from '../constants'
66
import { CATEGORIES, SUB_CATEGORIES, SidebarDataType, SidebarPropsType } from '../types'
77

88
export const getSidebarData = (categoriesConfig: SidebarPropsType['categoriesConfig']): SidebarDataType[] => {
9-
const { imageScan, codeScan, kubernetesManifest } = categoriesConfig
9+
const { imageScan, codeScan, kubernetesManifest, imageScanLicenseRisks } = categoriesConfig
1010

1111
return [
12-
imageScan && {
13-
label: CATEGORY_LABELS.IMAGE_SCAN,
14-
isExpanded: true,
15-
children: [
16-
{
17-
label: SUB_CATEGORY_LABELS.VULNERABILITIES,
18-
value: {
19-
category: CATEGORIES.IMAGE_SCAN,
20-
subCategory: SUB_CATEGORIES.VULNERABILITIES,
21-
},
22-
},
23-
{
24-
label: SUB_CATEGORY_LABELS.LICENSE,
25-
value: {
26-
category: CATEGORIES.IMAGE_SCAN,
27-
subCategory: SUB_CATEGORIES.LICENSE,
28-
},
29-
},
30-
],
31-
},
32-
codeScan && {
33-
label: CATEGORY_LABELS.CODE_SCAN,
34-
isExpanded: true,
35-
children: [
36-
{
37-
label: SUB_CATEGORY_LABELS.VULNERABILITIES,
38-
value: {
39-
category: CATEGORIES.CODE_SCAN,
40-
subCategory: SUB_CATEGORIES.VULNERABILITIES,
41-
},
42-
},
43-
{
44-
label: SUB_CATEGORY_LABELS.LICENSE,
45-
value: {
46-
category: CATEGORIES.CODE_SCAN,
47-
subCategory: SUB_CATEGORIES.LICENSE,
48-
},
49-
},
50-
{
51-
label: SUB_CATEGORY_LABELS.MISCONFIGURATIONS,
52-
value: {
53-
category: CATEGORIES.CODE_SCAN,
54-
subCategory: SUB_CATEGORIES.MISCONFIGURATIONS,
55-
},
56-
},
57-
{
58-
label: SUB_CATEGORY_LABELS.EXPOSED_SECRETS,
59-
value: {
60-
category: CATEGORIES.CODE_SCAN,
61-
subCategory: SUB_CATEGORIES.EXPOSED_SECRETS,
62-
},
63-
},
64-
],
65-
},
66-
kubernetesManifest && {
67-
label: CATEGORY_LABELS.KUBERNETES_MANIFEST,
68-
isExpanded: true,
69-
children: [
70-
{
71-
label: SUB_CATEGORY_LABELS.MISCONFIGURATIONS,
72-
value: {
73-
category: CATEGORIES.KUBERNETES_MANIFEST,
74-
subCategory: SUB_CATEGORIES.MISCONFIGURATIONS,
75-
},
76-
},
77-
{
78-
label: SUB_CATEGORY_LABELS.EXPOSED_SECRETS,
79-
value: {
80-
category: CATEGORIES.KUBERNETES_MANIFEST,
81-
subCategory: SUB_CATEGORIES.EXPOSED_SECRETS,
82-
},
83-
},
84-
],
85-
},
86-
].filter((data) => !!data)
12+
...(imageScan
13+
? [
14+
{
15+
label: CATEGORY_LABELS.IMAGE_SCAN,
16+
isExpanded: true,
17+
children: [
18+
{
19+
label: SUB_CATEGORY_LABELS.VULNERABILITIES,
20+
value: {
21+
category: CATEGORIES.IMAGE_SCAN,
22+
subCategory: SUB_CATEGORIES.VULNERABILITIES,
23+
},
24+
},
25+
...(imageScanLicenseRisks
26+
? [
27+
{
28+
label: SUB_CATEGORY_LABELS.LICENSE,
29+
value: {
30+
category: CATEGORIES.IMAGE_SCAN,
31+
subCategory: SUB_CATEGORIES.LICENSE,
32+
},
33+
},
34+
]
35+
: []),
36+
],
37+
},
38+
]
39+
: []),
40+
...(codeScan
41+
? [
42+
{
43+
label: CATEGORY_LABELS.CODE_SCAN,
44+
isExpanded: true,
45+
children: [
46+
{
47+
label: SUB_CATEGORY_LABELS.VULNERABILITIES,
48+
value: {
49+
category: CATEGORIES.CODE_SCAN,
50+
subCategory: SUB_CATEGORIES.VULNERABILITIES,
51+
},
52+
},
53+
{
54+
label: SUB_CATEGORY_LABELS.LICENSE,
55+
value: {
56+
category: CATEGORIES.CODE_SCAN,
57+
subCategory: SUB_CATEGORIES.LICENSE,
58+
},
59+
},
60+
{
61+
label: SUB_CATEGORY_LABELS.MISCONFIGURATIONS,
62+
value: {
63+
category: CATEGORIES.CODE_SCAN,
64+
subCategory: SUB_CATEGORIES.MISCONFIGURATIONS,
65+
},
66+
},
67+
{
68+
label: SUB_CATEGORY_LABELS.EXPOSED_SECRETS,
69+
value: {
70+
category: CATEGORIES.CODE_SCAN,
71+
subCategory: SUB_CATEGORIES.EXPOSED_SECRETS,
72+
},
73+
},
74+
],
75+
},
76+
]
77+
: []),
78+
...(kubernetesManifest
79+
? [
80+
{
81+
label: CATEGORY_LABELS.KUBERNETES_MANIFEST,
82+
isExpanded: true,
83+
children: [
84+
{
85+
label: SUB_CATEGORY_LABELS.MISCONFIGURATIONS,
86+
value: {
87+
category: CATEGORIES.KUBERNETES_MANIFEST,
88+
subCategory: SUB_CATEGORIES.MISCONFIGURATIONS,
89+
},
90+
},
91+
{
92+
label: SUB_CATEGORY_LABELS.EXPOSED_SECRETS,
93+
value: {
94+
category: CATEGORIES.KUBERNETES_MANIFEST,
95+
subCategory: SUB_CATEGORIES.EXPOSED_SECRETS,
96+
},
97+
},
98+
],
99+
},
100+
]
101+
: []),
102+
]
87103
}

src/Shared/Components/Security/SecurityModal/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export type SecurityModalStateType = {
108108
export interface SidebarPropsType {
109109
modalState: SecurityModalStateType
110110
setModalState: React.Dispatch<React.SetStateAction<SecurityModalStateType>>
111-
categoriesConfig: Record<(typeof CATEGORIES)[keyof typeof CATEGORIES], boolean>
111+
categoriesConfig: Record<(typeof CATEGORIES)[keyof typeof CATEGORIES] | 'imageScanLicenseRisks', boolean>
112112
}
113113

114114
export enum SeveritiesDTO {

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export interface customEnv {
7373
API_BATCH_SIZE: number
7474
SERVICE_WORKER_TIMEOUT?: string
7575
HIDE_RELEASES?: boolean
76-
ENABLE_RESOURCE_SCAN?: boolean
7776
FEATURE_USER_DEFINED_GITOPS_REPO_ENABLE: boolean
7877
HIDE_RESOURCE_WATCHER?: boolean
7978
ORGANIZATION_NAME: string

0 commit comments

Comments
 (0)