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('none-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 () => {

View File

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

View File

@ -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: {
@ -226,9 +226,9 @@ describe('Tags details', () => {
render(<TagDetails />);
expect(await screen.findAllByTestId('none-vulnerability-icon')).toHaveLength(1);
// @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.findAllByTestId('unknown-vulnerability-icon')).toHaveLength(1);
// @ts-ignore
jest.spyOn(api, 'get').mockResolvedValue({ status: 200, data: { data: mockImageLow } });
render(<TagDetails />);

View File

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