Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflect recent changes on Applied controls on Policies' CRUD and tabl… #1080

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,26 @@ export const URL_MODEL_MAP: ModelMap = {
verboseName: 'Policy',
verboseNamePlural: 'Policies',
foreignKeyFields: [
{ field: 'reference_control', urlModel: 'reference-controls' },
{ field: 'reference_control', urlModel: 'reference-controls', urlParams: 'category=policy' },
{ field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO&content_type=GL' },
{ field: 'evidences', urlModel: 'evidences' },
{ field: 'owner', urlModel: 'users' }
],
reverseForeignKeyFields: [{ field: 'applied_controls', urlModel: 'evidences' }],
selectFields: [{ field: 'csf_function' }, { field: 'status' }, { field: 'effort' }],
selectFields: [
{ field: 'status' },
{ field: 'csf_function' },
{ field: 'effort' },
{ field: 'priority' }
],
filters: [
{ field: 'reference_control' },
{ field: 'csf_function' },
{ field: 'status' },
{ field: 'csf_function' },
{ field: 'effort' },
{ field: 'folder' }
{ field: 'folder' },
{ field: 'owner' },
{ field: 'priority' }
]
},
vulnerabilities: {
Expand Down Expand Up @@ -613,6 +620,13 @@ export const FIELD_COLORED_TAG_MAP: FieldColoredTagMap = {
on_hold: { text: 'onHold', cssClasses: 'badge bg-gray-300' },
deprecated: { text: 'deprecated', cssClasses: 'badge bg-red-300' },
'--': { text: 'undefined', cssClasses: 'badge bg-gray-300' }
},
priority: {
P1: { text: '', cssClasses: 'fa-solid fa-flag text-red-500' },
P2: { text: '', cssClasses: 'fa-solid fa-flag text-orange-500' },
P3: { text: '', cssClasses: 'fa-solid fa-flag text-blue-500' },
P4: { text: '', cssClasses: 'fa-solid fa-flag text-gray-500' },
'--': { text: '', cssClasses: '' }
}
}
}
Expand Down
12 changes: 1 addition & 11 deletions frontend/src/lib/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,7 @@ export const AppliedControlSchema = baseNamedObject({
owner: z.string().uuid().optional().array().optional()
});

export const PolicySchema = baseNamedObject({
csf_function: z.string().optional().nullable(),
status: z.string().optional().default('--'),
evidences: z.string().optional().array().optional(),
eta: z.union([z.literal('').transform(() => null), z.string().date()]).nullish(),
expiry_date: z.union([z.literal('').transform(() => null), z.string().date()]).nullish(),
link: z.string().url().optional().or(z.literal('')),
effort: z.string().optional().nullable(),
folder: z.string(),
reference_control: z.string().optional().nullable()
});
export const PolicySchema = AppliedControlSchema.omit({ category: true });

export const RiskAcceptanceSchema = baseNamedObject({
folder: z.string(),
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,14 @@ export const listViewFields: ListViewFieldsConfig = {
}
},
policies: {
head: ['name', 'description', 'csfFunction', 'eta', 'domain', 'referenceControl'],
body: ['name', 'description', 'csf_function', 'eta', 'folder', 'reference_control'],
head: ['name', 'description', 'csfFunction', 'eta', 'owner', 'domain', 'referenceControl'],
body: ['name', 'description', 'csf_function', 'eta', 'owner', 'folder', 'reference_control'],
filters: {
folder: DOMAIN_FILTER
folder: DOMAIN_FILTER,
status: STATUS_FILTER,
csf_function: CSF_FUNCTION_FILTER,
owner: OWNER_FILTER,
priority: PRIORITY_FILTER
}
},
'reference-controls': {
Expand Down
Loading