fix: updated unknown vulnerability logic
Signed-off-by: Raul Kele <raulkeleblk@gmail.com>
This commit is contained in:
parent
5fe7c88472
commit
f33aa8d647
@ -81,25 +81,25 @@ const mockImageNone = {
|
||||
}
|
||||
};
|
||||
|
||||
// const mockImageUnknown = {
|
||||
// Image: {
|
||||
// RepoName: 'centos',
|
||||
// Tag: '8',
|
||||
// Digest: 'sha256:63a795ca90aa6e7cca60941e826810a4cd0a2e73ea02bf458241df2a5c973e29',
|
||||
// LastUpdated: '2020-12-08T00:22:52.526672082Z',
|
||||
// Size: '75183423',
|
||||
// ConfigDigest: 'sha256:8dd57e171a61368ffcfde38045ddb6ed74a32950c271c1da93eaddfb66a77e78',
|
||||
// Platform: {
|
||||
// Os: 'linux',
|
||||
// Arch: 'amd64'
|
||||
// },
|
||||
// Vulnerabilities: {
|
||||
// MaxSeverity: 'UNKNOWN',
|
||||
// Count: 10
|
||||
// },
|
||||
// Vendor: 'CentOS'
|
||||
// }
|
||||
// };
|
||||
const mockImageUnknown = {
|
||||
Image: {
|
||||
RepoName: 'centos',
|
||||
Tag: '8',
|
||||
Digest: 'sha256:63a795ca90aa6e7cca60941e826810a4cd0a2e73ea02bf458241df2a5c973e29',
|
||||
LastUpdated: '2020-12-08T00:22:52.526672082Z',
|
||||
Size: '75183423',
|
||||
ConfigDigest: 'sha256:8dd57e171a61368ffcfde38045ddb6ed74a32950c271c1da93eaddfb66a77e78',
|
||||
Platform: {
|
||||
Os: 'linux',
|
||||
Arch: 'amd64'
|
||||
},
|
||||
Vulnerabilities: {
|
||||
MaxSeverity: 'UNKNOWN',
|
||||
Count: 10
|
||||
},
|
||||
Vendor: 'CentOS'
|
||||
}
|
||||
};
|
||||
|
||||
const mockImageLow = {
|
||||
Image: {
|
||||
@ -220,27 +220,27 @@ describe('Tags details', () => {
|
||||
// @ts-ignore
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImage } });
|
||||
render(<TagDetails />);
|
||||
expect(await screen.findAllByTestId('critical-vulnerability-icon')).toHaveLength(1);
|
||||
expect(await screen.findByTestId('critical-vulnerability-icon')).toBeInTheDocument();
|
||||
// @ts-ignore
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageNone } });
|
||||
render(<TagDetails />);
|
||||
expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1);
|
||||
expect(await screen.findByTestId('none-vulnerability-icon')).toBeInTheDocument();
|
||||
// @ts-ignore
|
||||
// jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageUnknown } });
|
||||
// render(<TagDetails />);
|
||||
// expect(await screen.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1);
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageUnknown } });
|
||||
render(<TagDetails />);
|
||||
expect(await screen.findByTestId('unknown-vulnerability-icon')).toBeInTheDocument();
|
||||
// @ts-ignore
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageLow } });
|
||||
render(<TagDetails />);
|
||||
expect(await screen.findAllByTestId('low-vulnerability-icon')).toHaveLength(1);
|
||||
expect(await screen.findByTestId('low-vulnerability-icon')).toBeInTheDocument();
|
||||
// @ts-ignore
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageMedium } });
|
||||
render(<TagDetails />);
|
||||
expect(await screen.findAllByTestId('medium-vulnerability-icon')).toHaveLength(1);
|
||||
expect(await screen.findByTestId('medium-vulnerability-icon')).toBeInTheDocument();
|
||||
// @ts-ignore
|
||||
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageHigh } });
|
||||
render(<TagDetails />);
|
||||
expect(await screen.findAllByTestId('high-vulnerability-icon')).toHaveLength(1);
|
||||
expect(await screen.findByTestId('high-vulnerability-icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should copy the pull string to clipboard', async () => {
|
||||
|
@ -63,7 +63,7 @@ const endpoints = {
|
||||
repoList: ({ pageNumber = 1, pageSize = 15 } = {}) =>
|
||||
`/v2/_zot/ext/search?query={RepoListWithNewestImage(requestedPage: {limit:${pageSize} offset:${
|
||||
(pageNumber - 1) * pageSize
|
||||
}}){Name LastUpdated Size Platforms {Os Arch} NewestImage { Tag Vulnerabilities {MaxSeverity Count} Description Licenses Logo Title Source IsSigned Documentation History {Layer {Size Digest} HistoryDescription {Created CreatedBy Author Comment EmptyLayer}} Vendor Labels} DownloadCount}}`,
|
||||
}}){Name LastUpdated Size Platforms {Os Arch} NewestImage { Tag Vulnerabilities {MaxSeverity Count} Description Licenses Logo Title Source IsSigned Documentation Vendor Labels} DownloadCount}}`,
|
||||
detailedRepoInfo: (name) =>
|
||||
`/v2/_zot/ext/search?query={ExpandedRepoInfo(repo:"${name}"){Images {Digest Vulnerabilities {MaxSeverity Count} Tag LastUpdated Vendor Size Platform {Os Arch}} Summary {Name LastUpdated Size Platforms {Os Arch} Vendors NewestImage {RepoName IsSigned Vulnerabilities {MaxSeverity Count} Layers {Size Digest} Digest Tag Logo Title Documentation DownloadCount Source Description Licenses History {Layer {Size Digest} HistoryDescription {Created CreatedBy Author Comment EmptyLayer}}}}}}`,
|
||||
detailedImageInfo: (name, tag) =>
|
||||
|
@ -113,8 +113,10 @@ function Explore() {
|
||||
vendor={item.vendor}
|
||||
platforms={item.platforms}
|
||||
key={index}
|
||||
vulnerabiltySeverity={item.vulnerabiltySeverity}
|
||||
vulnerabilityCount={item.vulnerabilityCount}
|
||||
vulnerabilityData={{
|
||||
vulnerabilitySeverity: item.vulnerabiltySeverity,
|
||||
count: item.vulnerabilityCount
|
||||
}}
|
||||
lastUpdated={item.lastUpdated}
|
||||
logo={item.logo}
|
||||
/>
|
||||
|
@ -103,8 +103,10 @@ function Home() {
|
||||
vendor={item.vendor}
|
||||
platforms={item.platforms}
|
||||
key={index}
|
||||
vulnerabiltySeverity={item.vulnerabiltySeverity}
|
||||
vulnerabilityCount={item.vulnerabilityCount}
|
||||
vulnerabilityData={{
|
||||
vulnerabilitySeverity: item.vulnerabiltySeverity,
|
||||
count: item.vulnerabilityCount
|
||||
}}
|
||||
lastUpdated={item.lastUpdated}
|
||||
logo={item.logo}
|
||||
/>
|
||||
@ -150,8 +152,10 @@ function Home() {
|
||||
vendor={item.vendor}
|
||||
platforms={item.platforms}
|
||||
key={index}
|
||||
vulnerabiltySeverity={item.vulnerabiltySeverity}
|
||||
vulnerabilityCount={item.vulnerabilityCount}
|
||||
vulnerabilityData={{
|
||||
vulnerabilitySeverity: item.vulnerabiltySeverity,
|
||||
count: item.vulnerabilityCount
|
||||
}}
|
||||
lastUpdated={item.lastUpdated}
|
||||
logo={item.logo}
|
||||
/>
|
||||
|
@ -67,7 +67,7 @@ const useStyles = makeStyles(() => ({
|
||||
function PreviewCard(props) {
|
||||
const classes = useStyles();
|
||||
const navigate = useNavigate();
|
||||
const { name, isSigned, vulnerabiltySeverity, logo } = props;
|
||||
const { name, isSigned, vulnerabilityData, logo } = props;
|
||||
|
||||
const goToDetails = () => {
|
||||
navigate(`/image/${encodeURIComponent(name)}`);
|
||||
@ -107,7 +107,7 @@ function PreviewCard(props) {
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
<Stack direction="row" spacing={0.5} sx={{ marginLeft: 'auto', marginRight: 0 }}>
|
||||
<VulnerabilityIconCheck vulnerabilitySeverity={vulnerabiltySeverity} />
|
||||
<VulnerabilityIconCheck {...vulnerabilityData} />
|
||||
<SignatureIconCheck isSigned={isSigned} />
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
@ -90,18 +90,8 @@ const useStyles = makeStyles(() => ({
|
||||
function RepoCard(props) {
|
||||
const classes = useStyles();
|
||||
const navigate = useNavigate();
|
||||
const {
|
||||
name,
|
||||
vendor,
|
||||
platforms,
|
||||
description,
|
||||
downloads,
|
||||
isSigned,
|
||||
lastUpdated,
|
||||
logo,
|
||||
version,
|
||||
vulnerabiltySeverity
|
||||
} = props;
|
||||
const { name, vendor, platforms, description, downloads, isSigned, lastUpdated, logo, version, vulnerabilityData } =
|
||||
props;
|
||||
|
||||
const goToDetails = () => {
|
||||
navigate(`/image/${encodeURIComponent(name)}`);
|
||||
@ -166,7 +156,7 @@ function RepoCard(props) {
|
||||
{name}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
<VulnerabilityIconCheck vulnerabilitySeverity={vulnerabiltySeverity} />
|
||||
<VulnerabilityIconCheck {...vulnerabilityData} />
|
||||
<SignatureIconCheck isSigned={isSigned} />
|
||||
{/* <Chip label="Verified licensee" sx={{ backgroundColor: "#E8F5E9", color: "#388E3C" }} variant="filled" onDelete={() => { return }} deleteIcon={vulnerabilityCheck()} /> */}
|
||||
</Stack>
|
||||
|
@ -266,6 +266,8 @@ function RepoDetails() {
|
||||
// @ts-ignore
|
||||
repoDetailData.vulnerabiltySeverity
|
||||
}
|
||||
// @ts-ignore
|
||||
count={repoDetailData?.vulnerabilityCount}
|
||||
/>
|
||||
<SignatureIconCheck
|
||||
isSigned={
|
||||
|
@ -194,12 +194,13 @@ function TagDetails() {
|
||||
setImageDetailData(imageData);
|
||||
setFullName(imageData.name + ':' + imageData.tag);
|
||||
setPullString(dockerPull(imageData.name + ':' + imageData.tag));
|
||||
setIsLoading(false);
|
||||
}
|
||||
setIsLoading(false);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
setImageDetailData({});
|
||||
setIsLoading(false);
|
||||
});
|
||||
return () => {
|
||||
abortController.abort();
|
||||
@ -263,6 +264,8 @@ function TagDetails() {
|
||||
// @ts-ignore
|
||||
imageDetailData.vulnerabiltySeverity
|
||||
}
|
||||
// @ts-ignore
|
||||
count={imageDetailData.vulnerabilityCount}
|
||||
/>
|
||||
<SignatureIconCheck
|
||||
isSigned={
|
||||
|
@ -13,7 +13,8 @@ import {
|
||||
UnverifiedSignatureIcon,
|
||||
VerifiedSignatureIcon,
|
||||
UnverifiedSignatureChip,
|
||||
VerifiedSignatureChip
|
||||
VerifiedSignatureChip,
|
||||
UnknownVulnerabilityIcon
|
||||
} from './vulnerabilityAndSignatureComponents';
|
||||
|
||||
const VulnerabilityIconCheck = ({ vulnerabilitySeverity }) => {
|
||||
@ -24,7 +25,7 @@ const VulnerabilityIconCheck = ({ vulnerabilitySeverity }) => {
|
||||
}
|
||||
switch (vulnerabilitySeverity) {
|
||||
case 'NONE':
|
||||
result = <NoneVulnerabilityIcon vulnerabilityStringTitle={vulnerabilityStringTitle} />;
|
||||
result = <NoneVulnerabilityIcon vulnerabilityStringTitle={'No'} />;
|
||||
break;
|
||||
case 'LOW':
|
||||
result = <LowVulnerabilityIcon vulnerabilityStringTitle={vulnerabilityStringTitle} />;
|
||||
@ -38,6 +39,9 @@ const VulnerabilityIconCheck = ({ vulnerabilitySeverity }) => {
|
||||
case 'CRITICAL':
|
||||
result = <CriticalVulnerabilityIcon vulnerabilityStringTitle={vulnerabilityStringTitle} />;
|
||||
break;
|
||||
case 'UNKNOWN':
|
||||
result = <UnknownVulnerabilityIcon vulnerabilityStringTitle={vulnerabilityStringTitle} />;
|
||||
break;
|
||||
default:
|
||||
result = <></>;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ const CriticalVulnerabilityIcon = ({ vulnerabilityStringTitle }) => {
|
||||
const NoneVulnerabilityChip = () => {
|
||||
return (
|
||||
<Chip
|
||||
label="None Vulnerability"
|
||||
label="No Vulnerability"
|
||||
sx={{ backgroundColor: '#E8F5E9', color: '#388E3C', fontSize: '0.8125rem' }}
|
||||
variant="filled"
|
||||
onDelete={() => {
|
||||
|
Loading…
Reference in New Issue
Block a user