fix: hide unknown vulnerability

Signed-off-by: Raul Kele <raulkeleblk@gmail.com>
This commit is contained in:
Raul Kele 2022-10-24 16:51:31 +03:00
parent 5b6af45ae5
commit 93f008a48a
4 changed files with 49 additions and 51 deletions

View File

@ -167,7 +167,7 @@ describe('Explore component', () => {
expect(await screen.findAllByTestId('critical-vulnerability-icon')).toHaveLength(1); expect(await screen.findAllByTestId('critical-vulnerability-icon')).toHaveLength(1);
expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1); expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1);
expect(await screen.findAllByTestId('medium-vulnerability-icon')).toHaveLength(1); expect(await screen.findAllByTestId('medium-vulnerability-icon')).toHaveLength(1);
expect(await screen.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1); // expect(await screen.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1);
}); });
it("should log an error when data can't be fetched", async () => { it("should log an error when data can't be fetched", async () => {

View File

@ -66,27 +66,27 @@ const mockRepoDetailsNone = {
} }
}; };
const mockRepoDetailsUnknown = { // const mockRepoDetailsUnknown = {
ExpandedRepoInfo: { // ExpandedRepoInfo: {
Images: [ // Images: [
{ // {
Digest: '2aa7ff5ca352d4d25fc6548f9930a436aacd64d56b1bd1f9ff4423711b9c8718', // Digest: '2aa7ff5ca352d4d25fc6548f9930a436aacd64d56b1bd1f9ff4423711b9c8718',
Tag: 'latest' // Tag: 'latest'
} // }
], // ],
Summary: { // Summary: {
Name: 'test1', // Name: 'test1',
NewestImage: { // NewestImage: {
RepoName: 'mongo', // RepoName: 'mongo',
IsSigned: true, // IsSigned: true,
Vulnerabilities: { // Vulnerabilities: {
MaxSeverity: 'UNKNOWN', // MaxSeverity: 'UNKNOWN',
Count: 15 // Count: 15
} // }
} // }
} // }
} // }
}; // };
const mockRepoDetailsLow = { const mockRepoDetailsLow = {
ExpandedRepoInfo: { ExpandedRepoInfo: {
@ -177,9 +177,9 @@ describe('Repo details component', () => {
render(<RepoDetails />); render(<RepoDetails />);
expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1); expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1);
// @ts-ignore // @ts-ignore
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockRepoDetailsUnknown } }); // jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockRepoDetailsUnknown } });
render(<RepoDetails />); // render(<RepoDetails />);
expect(await screen.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1); // expect(await screen.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1);
// @ts-ignore // @ts-ignore
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockRepoDetailsLow } }); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockRepoDetailsLow } });
render(<RepoDetails />); render(<RepoDetails />);

View File

@ -81,25 +81,25 @@ const mockImageNone = {
} }
}; };
const mockImageUnknown = { // const mockImageUnknown = {
Image: { // Image: {
RepoName: 'centos', // RepoName: 'centos',
Tag: '8', // Tag: '8',
Digest: 'sha256:63a795ca90aa6e7cca60941e826810a4cd0a2e73ea02bf458241df2a5c973e29', // Digest: 'sha256:63a795ca90aa6e7cca60941e826810a4cd0a2e73ea02bf458241df2a5c973e29',
LastUpdated: '2020-12-08T00:22:52.526672082Z', // LastUpdated: '2020-12-08T00:22:52.526672082Z',
Size: '75183423', // Size: '75183423',
ConfigDigest: 'sha256:8dd57e171a61368ffcfde38045ddb6ed74a32950c271c1da93eaddfb66a77e78', // ConfigDigest: 'sha256:8dd57e171a61368ffcfde38045ddb6ed74a32950c271c1da93eaddfb66a77e78',
Platform: { // Platform: {
Os: 'linux', // Os: 'linux',
Arch: 'amd64' // Arch: 'amd64'
}, // },
Vulnerabilities: { // Vulnerabilities: {
MaxSeverity: 'UNKNOWN', // MaxSeverity: 'UNKNOWN',
Count: 10 // Count: 10
}, // },
Vendor: 'CentOS' // Vendor: 'CentOS'
} // }
}; // };
const mockImageLow = { const mockImageLow = {
Image: { Image: {
@ -226,9 +226,9 @@ describe('Tags details', () => {
render(<TagDetails />); render(<TagDetails />);
expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1); expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1);
// @ts-ignore // @ts-ignore
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageUnknown } }); // jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageUnknown } });
render(<TagDetails />); // render(<TagDetails />);
expect(await screen.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1); // expect(await screen.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1);
// @ts-ignore // @ts-ignore
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageLow } }); jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageLow } });
render(<TagDetails />); render(<TagDetails />);

View File

@ -1,13 +1,11 @@
import React from 'react'; import React from 'react';
import { import {
NoneVulnerabilityIcon, NoneVulnerabilityIcon,
UnknownVulnerabilityIcon,
LowVulnerabilityIcon, LowVulnerabilityIcon,
MediumVulnerabilityIcon, MediumVulnerabilityIcon,
HighVulnerabilityIcon, HighVulnerabilityIcon,
CriticalVulnerabilityIcon, CriticalVulnerabilityIcon,
NoneVulnerabilityChip, NoneVulnerabilityChip,
UnknownVulnerabilityChip,
LowVulnerabilityChip, LowVulnerabilityChip,
MediumVulnerabilityChip, MediumVulnerabilityChip,
HighVulnerabilityChip, HighVulnerabilityChip,
@ -41,7 +39,7 @@ const VulnerabilityIconCheck = ({ vulnerabilitySeverity }) => {
result = <CriticalVulnerabilityIcon vulnerabilityStringTitle={vulnerabilityStringTitle} />; result = <CriticalVulnerabilityIcon vulnerabilityStringTitle={vulnerabilityStringTitle} />;
break; break;
default: default:
result = <UnknownVulnerabilityIcon vulnerabilityStringTitle={vulnerabilityStringTitle} />; result = <></>;
} }
return result; return result;
}; };
@ -65,7 +63,7 @@ const VulnerabilityChipCheck = ({ vulnerabilitySeverity }) => {
result = <CriticalVulnerabilityChip />; result = <CriticalVulnerabilityChip />;
break; break;
default: default:
result = <UnknownVulnerabilityChip />; result = <></>;
} }
return result; return result;
}; };