Skip to content

Commit

Permalink
Manage policy CRUD operations
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Feb 14, 2024
1 parent 1044c0e commit 6577d14
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/lib/components/Forms/ModelForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@
field="threats"
label="Threats"
/>
{:else if URLModel === 'security-measures'}
<Select {form} options={model.selectOptions['category']} field="category" label="Category" />
{:else if URLModel === 'security-measures' || URLModel === 'policies'}
{#if schema.shape.category}
<Select {form} options={model.selectOptions['category']} field="category" label="Category" />
{/if}
<Select {form} options={model.selectOptions['status']} field="status" label="Status" />
<AutocompleteSelect
{form}
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@ export const URL_MODEL_MAP: ModelMap = {
{ field: 'folder' }
]
},
policies: {
name: 'policy',
verboseName: 'Policy',
verboseNamePlural: 'Policies',
foreignKeyFields: [
{ field: 'security_function', urlModel: 'security-functions' },
{ field: 'folder', urlModel: 'folders' },
{ field: 'evidences', urlModel: 'evidences' }
],
selectFields: [{ field: 'status' }, { field: 'category' }, { field: 'effort' }],
filters: [
{ field: 'security_function' },
{ field: 'status' },
{ field: 'effort' },
{ field: 'folder' }
]
},
'risk-acceptances': {
name: 'riskacceptance',
verboseName: 'Risk acceptance',
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/lib/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ export const SecurityMeasureSchema = baseNamedObject({
security_function: z.string().optional()
});

export const PolicySchema = baseNamedObject({
status: z.string().optional(),
evidences: z.string().optional().array().optional(),
eta: z.string().optional().nullable(),
expiry_date: z.string().optional().nullable(),
link: z.string().url().optional().nullable(),
effort: z.string().optional(),
folder: z.string(),
security_function: z.string().optional()
});

export const RiskAcceptanceSchema = baseNamedObject({
folder: z.string(),
expiry_date: z.string().optional().nullable(),
Expand Down Expand Up @@ -181,6 +192,7 @@ const SCHEMA_MAP: Record<string, AnyZodObject> = {
threats: ThreatSchema,
'risk-scenarios': RiskScenarioSchema,
'security-measures': SecurityMeasureSchema,
policy: PolicySchema,
'risk-acceptances': RiskAcceptanceSchema,
'security-functions': SecurityFunctionSchema,
assets: AssetSchema,
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export const listViewFields = {
head: ['Name', 'Description', 'Category', 'ETA', 'Domain', 'Security function'],
body: ['name', 'description', 'category', 'eta', 'folder', 'security_function']
},
policies: {
head: ['Name', 'Description', 'ETA', 'Domain', 'Security function'],
body: ['name', 'description', 'eta', 'folder', 'security_function']
},
'security-functions': {
head: ['Ref', 'Name', 'Description', 'Category', 'Provider', 'Domain'],
body: ['ref_id', 'name', 'description', 'category', 'provider', 'folder'],
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const URL_MODEL = [
'threats',
'risk-scenarios',
'security-measures',
'policies',
'risk-acceptances',
'security-functions',
'assets',
Expand Down

0 comments on commit 6577d14

Please sign in to comment.