Skip to content

Commit b3e3adf

Browse files
committed
feat: use scan type from config in security card
1 parent 89c7749 commit b3e3adf

File tree

3 files changed

+30
-43
lines changed

3 files changed

+30
-43
lines changed

src/Shared/Components/Security/SecurityDetailsCards/SecurityCard.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { ReactComponent as ICShieldWarning } from '@Icons/ic-shield-warning-outl
33
import { ReactComponent as ICShieldSecure } from '@Icons/ic-shield-check.svg'
44
import { ReactComponent as ICArrowRight } from '@Icons/ic-caret-down-small.svg'
55
import { SecurityCardProps } from './types'
6-
import { CATEGORIES, SUB_CATEGORIES } from '../SecurityModal/types'
7-
import { CATEGORY_LABELS, SEVERITIES } from '../SecurityModal/constants'
6+
import { SUB_CATEGORIES } from '../SecurityModal/types'
7+
import { SEVERITIES } from '../SecurityModal/constants'
88
import './securityCard.scss'
99
import { getTotalSeverities } from '../utils'
10+
import { SECURITY_CONFIG } from '../constants'
1011

1112
const SecurityCard = ({
1213
category,
@@ -26,17 +27,6 @@ const SecurityCard = ({
2627
}))
2728
.filter((entity) => !!entity.value)
2829

29-
const getScanType = () => {
30-
switch (category) {
31-
case CATEGORIES.KUBERNETES_MANIFEST:
32-
return CATEGORY_LABELS.KUBERNETES_MANIFEST
33-
case CATEGORIES.CODE_SCAN:
34-
return CATEGORY_LABELS.CODE_SCAN
35-
default:
36-
return CATEGORY_LABELS.IMAGE_SCAN
37-
}
38-
}
39-
4030
const getTitleSubtitle = (): { title: string; subtitle?: string } => {
4131
switch (subCategory) {
4232
case SUB_CATEGORIES.EXPOSED_SECRETS:
@@ -79,7 +69,7 @@ const SecurityCard = ({
7969
>
8070
<div className="flexbox dc__content-space">
8171
<div className="flexbox-col">
82-
<span className="fs-12 fw-4 lh-1-5 cn-7">{getScanType()}</span>
72+
<span className="fs-12 fw-4 lh-1-5 cn-7">{SECURITY_CONFIG[category].label}</span>
8373
<div className="fs-15 fw-6 lh-1-5 cn-9 flex">
8474
<span className="security-card-title">{title}</span>
8575
<ICArrowRight className="icon-dim-20 dc__flip-270 scb-5 arrow-right" />

src/Shared/Components/Security/SecurityDetailsCards/SecurityDetailsCards.tsx

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,31 @@ const SecurityDetailsCards = ({ scanResult, Sidebar }: SecurityDetailsCardsProps
5959
return (
6060
<>
6161
<div className="flexbox-col dc__gap-20">
62-
{Object.keys(SECURITY_CONFIG).map((category: ScanCategories) => {
63-
const scanToolId = getScanToolId(category)
64-
return (
65-
<div className="flexbox-col dc__gap-12" key={category}>
66-
<div className="flexbox dc__content-space pb-8 dc__border-bottom-n1">
67-
<span className="fs-13 fw-6 lh-1-5 cn-9">{SECURITY_CONFIG[category].label}</span>
68-
<ScannedByToolModal scanToolId={scanToolId} />
69-
</div>
70-
<div className="dc__grid security-cards">
71-
{SECURITY_CONFIG[category].subCategories.map((subCategory: ScanSubCategories) => {
72-
const severityCount =
73-
subCategory === SUB_CATEGORIES.MISCONFIGURATIONS
74-
? scanResult[category][subCategory]?.misConfSummary?.status
75-
: scanResult[category][subCategory]?.summary?.severities
62+
{Object.keys(SECURITY_CONFIG).map((category: ScanCategories) => (
63+
<div className="flexbox-col dc__gap-12" key={category}>
64+
<div className="flexbox dc__content-space pb-8 dc__border-bottom-n1">
65+
<span className="fs-13 fw-6 lh-1-5 cn-9">{SECURITY_CONFIG[category].label}</span>
66+
<ScannedByToolModal scanToolId={getScanToolId(category)} />
67+
</div>
68+
<div className="dc__grid security-cards">
69+
{SECURITY_CONFIG[category].subCategories.map((subCategory: ScanSubCategories) => {
70+
const severityCount =
71+
subCategory === SUB_CATEGORIES.MISCONFIGURATIONS
72+
? scanResult[category][subCategory]?.misConfSummary?.status
73+
: scanResult[category][subCategory]?.summary?.severities
7674

77-
return (
78-
<SecurityCard
79-
category={category}
80-
subCategory={subCategory}
81-
severityCount={severityCount}
82-
handleCardClick={handleCardClick(category, subCategory)}
83-
/>
84-
)
85-
})}
86-
</div>
75+
return (
76+
<SecurityCard
77+
category={category}
78+
subCategory={subCategory}
79+
severityCount={severityCount}
80+
handleCardClick={handleCardClick(category, subCategory)}
81+
/>
82+
)
83+
})}
8784
</div>
88-
)
89-
})}
85+
</div>
86+
))}
9087
</div>
9188
{showSecurityModal && (
9289
<SecurityModal

src/Shared/Components/Security/utils.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export const getSecurityConfig = ({
1717
kubernetesManifest,
1818
}: CategoriesConfig): SecurityConfigType => ({
1919
...(imageScan && {
20-
[CATEGORIES.IMAGE_SCAN]: SECURITY_CONFIG.imageScan,
20+
[CATEGORIES.IMAGE_SCAN]: SECURITY_CONFIG[CATEGORIES.IMAGE_SCAN],
2121
}),
2222
...(codeScan && {
23-
[CATEGORIES.CODE_SCAN]: SECURITY_CONFIG.codeScan,
23+
[CATEGORIES.CODE_SCAN]: SECURITY_CONFIG[CATEGORIES.CODE_SCAN],
2424
}),
2525
...(kubernetesManifest && {
26-
[CATEGORIES.KUBERNETES_MANIFEST]: SECURITY_CONFIG.kubernetesManifest,
26+
[CATEGORIES.KUBERNETES_MANIFEST]: SECURITY_CONFIG[CATEGORIES.KUBERNETES_MANIFEST],
2727
}),
2828
})
2929

0 commit comments

Comments
 (0)