Skip to content

Commit

Permalink
fix missing posture scan status
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-deepfence committed Jun 10, 2024
1 parent 1c65ff2 commit 637f0de
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from 'ui-components';

import {
ModelCloudComplianceStatusEnum,
ModelComplianceStatusEnum,
ModelIntegrationFilters,
ModelIntegrationListResp,
ModelNodeIdentifierNodeTypeEnum,
Expand All @@ -24,6 +26,7 @@ import { SearchableImageList } from '@/components/forms/SearchableImageList';
import { FieldSelection } from '@/features/integrations/components/report-form/FieldSelection';
import { SuccessModalContent } from '@/features/settings/components/SuccessModalContent';
import { ScanTypeEnum } from '@/types/common';
import { getPostureStatusPrettyName } from '@/utils/enum';

import {
ActionEnumType,
Expand Down Expand Up @@ -343,17 +346,31 @@ const AdvancedFilters = ({
}}
>
<div className="px-3 pt-2 text-p3 text-text-text-and-icon">Host</div>
<ListboxOption value={'Alarm'}>Alarm</ListboxOption>
<ListboxOption value={'Note'}>Note</ListboxOption>
<ListboxOption value={'Ok'}>Ok</ListboxOption>
<ListboxOption value={ModelCloudComplianceStatusEnum.Alarm}>
{getPostureStatusPrettyName(ModelCloudComplianceStatusEnum.Alarm)}
</ListboxOption>
<ListboxOption value={ModelComplianceStatusEnum.Note}>
{getPostureStatusPrettyName(ModelComplianceStatusEnum.Note)}
</ListboxOption>
<ListboxOption value={ModelCloudComplianceStatusEnum.Ok}>
{getPostureStatusPrettyName(ModelCloudComplianceStatusEnum.Ok)}
</ListboxOption>
<div className="px-3 pt-4 text-p3 text-text-text-and-icon">
Kubernetes
</div>
<ListboxOption value={'Pass'}>Pass</ListboxOption>
<ListboxOption value={'Skip'}>Skip</ListboxOption>
<ListboxOption value={'Warn'}>Warn</ListboxOption>
<ListboxOption value={ModelComplianceStatusEnum.Pass}>
{getPostureStatusPrettyName(ModelComplianceStatusEnum.Pass)}
</ListboxOption>
<ListboxOption value={ModelCloudComplianceStatusEnum.Skip}>
{getPostureStatusPrettyName(ModelCloudComplianceStatusEnum.Skip)}
</ListboxOption>
<ListboxOption value={ModelComplianceStatusEnum.Warn}>
{getPostureStatusPrettyName(ModelComplianceStatusEnum.Warn)}
</ListboxOption>
<div className="px-3 pt-4 text-p3 text-text-text-and-icon">Common</div>
<ListboxOption value={'Info'}>Info</ListboxOption>
<ListboxOption value={ModelCloudComplianceStatusEnum.Info}>
{getPostureStatusPrettyName(ModelCloudComplianceStatusEnum.Info)}
</ListboxOption>
</Listbox>
)}
{isCloudComplianceNotification(notificationType) && (
Expand All @@ -373,10 +390,13 @@ const AdvancedFilters = ({
return value && value.length ? `${value.length} selected` : '';
}}
>
<ListboxOption value={'Pass'}>Pass</ListboxOption>
<ListboxOption value={'Skip'}>Skip</ListboxOption>
<ListboxOption value={'Warn'}>Warn</ListboxOption>
<ListboxOption value={'Info'}>Info</ListboxOption>
{Object.values(ModelCloudComplianceStatusEnum).map((status) => {
return (
<ListboxOption key={status} value={status}>
{getPostureStatusPrettyName(status)}
</ListboxOption>
);
})}
</Listbox>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ const action = async ({ request, params }: ActionFunctionArgs): Promise<ActionDa
const filters = _filters.fields_filters.contains_filter.filter_in;
const newFilter = {
...filters,
status: statusFilter.map((status) => status.toLowerCase()),
status: statusFilter,
};
_filters.fields_filters.contains_filter.filter_in = newFilter;
}
Expand Down
30 changes: 30 additions & 0 deletions deepfence_frontend/apps/dashboard/src/utils/enum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {
ModelBenchmarkType,
ModelCloudComplianceStatusEnum,
ModelComplianceStatusEnum,
ModelMalwareFileSeverityEnum,
ModelSecretLevelEnum,
ModelVulnerabilityCveSeverityEnum,
Expand Down Expand Up @@ -41,3 +43,31 @@ export function getBenchmarkPrettyName(backendBenchmark: ModelBenchmarkType) {
throw new Error(`Unhandled case: ${_exhaustiveCheck}`);
}
}

export function getPostureStatusPrettyName(
status: ModelCloudComplianceStatusEnum | ModelComplianceStatusEnum,
) {
switch (status) {
case ModelCloudComplianceStatusEnum.Alarm:
return 'Alarm';
case ModelCloudComplianceStatusEnum.Info:
return 'Info';
case ModelCloudComplianceStatusEnum.Ok:
return 'Ok';
case ModelCloudComplianceStatusEnum.Skip:
return 'Skip';
case ModelCloudComplianceStatusEnum.Delete:
return 'Delete';
case ModelComplianceStatusEnum.Pass:
return 'Pass';
case ModelComplianceStatusEnum.Warn:
return 'Warn';
case ModelComplianceStatusEnum.Note:
return 'Note';

default:
// eslint-disable-next-line no-case-declarations
const _exhaustiveCheck: never = status;
throw new Error(`Unhandled case: ${_exhaustiveCheck}`);
}
}

0 comments on commit 637f0de

Please sign in to comment.