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

Add impact qualification #737

Merged
merged 32 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
59ac250
Add the qualification field for RiskScenario
monsieurswag Aug 13, 2024
38fa4dd
Add the qualification field for RiskScenario (again ?)
monsieurswag Aug 14, 2024
1d5993b
Formatter
monsieurswag Aug 14, 2024
b31941d
Fix important typo
monsieurswag Aug 14, 2024
bee6915
zip(range(infinity),data) = enumerate(data)
monsieurswag Aug 14, 2024
7538373
Formatter
monsieurswag Aug 14, 2024
d8c202b
Correct the placement of the qualification select component and displ…
monsieurswag Aug 14, 2024
f184e19
Rename qualification status into qualification
monsieurswag Aug 14, 2024
79aec2c
Formatter + clean some code
monsieurswag Aug 14, 2024
d390f6f
Fix codacy test
monsieurswag Aug 19, 2024
88164f6
Add explicit non-null specifier to the qualification field declaration
monsieurswag Aug 19, 2024
3ae1d55
Formatter
monsieurswag Aug 19, 2024
b79a6dc
Reset migration
monsieurswag Aug 19, 2024
b52d1d7
Formatter
monsieurswag Aug 19, 2024
a38c0d6
Remove choices from qualification field
monsieurswag Aug 19, 2024
3af12a7
Attempt to fix the test-exclusive migration double leaf node issue by…
monsieurswag Aug 20, 2024
661efd7
Fix migration issue
monsieurswag Aug 20, 2024
834aac6
Formatter
monsieurswag Aug 20, 2024
e0cfc0b
Change schema
monsieurswag Aug 20, 2024
108ed80
Fix qualification list endpoint
monsieurswag Aug 20, 2024
a6a5b2c
Formatter
monsieurswag Aug 20, 2024
ec075d2
Fix constraint error due to non-nullable blank qualification field
monsieurswag Aug 20, 2024
27d622c
Remove dead code
monsieurswag Aug 22, 2024
2910ba4
Make qualification plural
monsieurswag Aug 22, 2024
49c765f
Add authenticity qualification
monsieurswag Aug 22, 2024
ec66c75
Formatter
monsieurswag Aug 22, 2024
bb0ebfd
Update data-model.md
eric-intuitem Aug 22, 2024
132166d
Add translations
monsieurswag Aug 24, 2024
08a3be0
Fix typo in translation
monsieurswag Aug 26, 2024
e3f04d0
Fix detail view translation
monsieurswag Aug 26, 2024
84c5011
Rename qualification field into qualifications
monsieurswag Aug 26, 2024
1f9ac90
Formatter
monsieurswag Aug 26, 2024
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
17 changes: 17 additions & 0 deletions backend/core/migrations/0022_riskscenario_qualifications.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.7 on 2024-08-26 10:43

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0021_alter_framework_urn_alter_loadedlibrary_urn_and_more"),
]

operations = [
migrations.AddField(
model_name="riskscenario",
name="qualifications",
field=models.JSONField(default=list, verbose_name="Qualifications"),
),
]
13 changes: 13 additions & 0 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,17 @@ class RiskScenario(NameDescriptionMixin):
("transfer", _("Transfer")),
]

QUALIFICATIONS = [
("Financial", _("Financial")),
("Legal", _("Legal")),
("Reputation", _("Reputation")),
("Operational", _("Operational")),
("Confidentiality", _("Confidentiality")),
("Integrity", _("Integrity")),
("Availability", _("Availability")),
("Authenticity", _("Authenticity")),
]

DEFAULT_SOK_OPTIONS = {
-1: {
"name": _("--"),
Expand Down Expand Up @@ -1787,6 +1798,8 @@ class RiskScenario(NameDescriptionMixin):
verbose_name=_("Treatment status"),
)

qualifications = models.JSONField(default=list, verbose_name=_("Qualifications"))

strength_of_knowledge = models.IntegerField(
default=-1,
verbose_name=_("Strength of Knowledge"),
Expand Down
22 changes: 12 additions & 10 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ def duplicate(self, request, pk):
description=scenario.description,
existing_controls=scenario.existing_controls,
treatment=scenario.treatment,
qualifications=scenario.qualifications,
current_proba=scenario.current_proba,
current_impact=scenario.current_impact,
residual_proba=scenario.residual_proba,
Expand Down Expand Up @@ -745,6 +746,10 @@ class RiskScenarioViewSet(BaseModelViewSet):
def treatment(self, request):
return Response(dict(RiskScenario.TREATMENT_OPTIONS))

@action(detail=False, name="Get qualification choices")
def qualifications(self, request):
return Response(dict(RiskScenario.QUALIFICATIONS))

@action(detail=True, name="Get probability choices")
def probability(self, request, pk):
undefined = dict([(-1, "--")])
Expand Down Expand Up @@ -775,16 +780,13 @@ def strength_of_knowledge(self, request, pk):
_sok_choices = self.get_object().get_matrix().get("strength_of_knowledge")
if _sok_choices is not None:
sok_choices = dict(
zip(
list(range(0, 64)),
[
{
"name": x["name"],
"description": x.get("description"),
"symbol": x.get("symbol"),
}
for x in _sok_choices
],
enumerate(
{
"name": x["name"],
"description": x.get("description"),
"symbol": x.get("symbol"),
}
for x in _sok_choices
)
)
else:
Expand Down
3 changes: 3 additions & 0 deletions documentation/architecture/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ erDiagram
json target_risk_vector
string strength_of_knowledge
string justification
json qualifications

principal[] owner
}
Expand Down Expand Up @@ -863,6 +864,8 @@ A risk scenario contains a treatment option with the values --/open/mitigate/acc

A risk scenario also contains a "strength of knowledge", within the values --/0 (Low)/1 (Medium)/2 (High). This can be used to represent a third dimension of risk, as recommended by the Society for Risk Analysis. The field "justification" can be used to expose the knowledge.

A risk scenario also contains a "qualification" field, containing an array with the following possible values: Confidentiality, Integrity, Availability, Authenticity, Reputation, Operational, Legal, Financial. The qualification can cover none, one or several of the values.

The risk evaluation is automatically done based on the selected risk matrix.

## Risk matrices
Expand Down
11 changes: 10 additions & 1 deletion frontend/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"urn": "URN",
"id": "معرف",
"treatmentStatus": "حالة المعالجة",
"qualification": "المؤهلات",
"currentLevel": "المستوى الحالي",
"residualLevel": "المستوى المتبقي",
"riskMatrix": "مصفوفة المخاطر",
Expand Down Expand Up @@ -617,5 +618,13 @@
"sso": "SSO",
"isSso": "هل هو SSO",
"size": "الحجم",
"requirementMappingSets": "ربط الأطر"
"requirementMappingSets": "ربط الأطر",
"financial": "المالي",
"legal": "القانوني",
"reputation": "السمعة",
"operational": "التشغيلي",
"confidentiality": "السرية",
"integrity": "النزاهة",
"availability": "التوفر",
"authenticity": "الأصالة"
}
11 changes: 10 additions & 1 deletion frontend/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Behandlungsstatus",
"qualification": "Qualifizierung",
"currentLevel": "Aktuelles Niveau",
"residualLevel": "Restrisiko-Niveau",
"riskMatrix": "Risikomatrix",
Expand Down Expand Up @@ -616,5 +617,13 @@
"back": "Zurückkehren",
"duplicate": "Duplikat",
"duplicateRiskAssessment": "Duplizieren Sie die Risikobewertung",
"size": "Größe"
"size": "Größe",
"financial": "Finanzen",
"legal": "Rechtliches",
"reputation": "Reputation",
"operational": "Betrieblich",
"confidentiality": "Vertraulichkeit",
"integrity": "Integrität",
"availability": "Verfügbarkeit",
"authenticity": "Authentizität"
}
11 changes: 10 additions & 1 deletion frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Treatment status",
"qualification": "Qualification",
"currentLevel": "Current level",
"residualLevel": "Residual level",
"riskMatrix": "Risk matrix",
Expand Down Expand Up @@ -660,5 +661,13 @@
"back": "Back",
"duplicate": "Duplicate",
"duplicateRiskAssessment": "Duplicate the risk assessment",
"size": "Size"
"size": "Size",
"financial": "Financial",
"legal": "Legal",
"reputation": "Reputation",
"operational": "Operational",
"confidentiality": "Confidentiality",
"integrity": "Integrity",
"availability": "Availability",
"authenticity": "Authenticity"
}
11 changes: 10 additions & 1 deletion frontend/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Estado del tratamiento",
"qualification": "Cualificación",
"currentLevel": "Nivel actual",
"residualLevel": "Nivel residual",
"riskMatrix": "Matriz de riesgos",
Expand Down Expand Up @@ -616,5 +617,13 @@
"back": "Devolver",
"duplicate": "Duplicar",
"duplicateRiskAssessment": "Duplicar la evaluación de riesgo",
"size": "Tamaño"
"size": "Tamaño",
"financial": "Finanzas",
"legal": "Jurídico",
"reputation": "Reputación",
"operational": "Operativa",
"confidentiality": "Confidencialidad",
"integrity": "Integridad",
"availability": "Disponibilidad",
"authenticity": "Autenticidad"
}
11 changes: 10 additions & 1 deletion frontend/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Statut de traitement",
"qualification": "Qualifcation",
"currentLevel": "Niveau courant",
"residualLevel": "Niveau résiduel",
"riskMatrix": "Matrice de risque",
Expand Down Expand Up @@ -616,5 +617,13 @@
"back": "Retour",
"duplicate": "Dupliquer",
"duplicateRiskAssessment": "Dupliquer l’évaluation de risque",
"size": "Taille"
"size": "Taille",
"financial": "Financier",
"legal": "Juridique",
"reputation": "Réputation",
"operational": "Opérationnel",
"confidentiality": "Confidentialité",
"integrity": "Intégrité",
"availability": "Disponibilité",
"authenticity": "Authenticité"
}
11 changes: 10 additions & 1 deletion frontend/messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Stato del trattamento",
"qualification": "Qualificazione",
"currentLevel": "Livello attuale",
"residualLevel": "Livello residuo",
"riskMatrix": "Matrice di rischio",
Expand Down Expand Up @@ -616,5 +617,13 @@
"back": "Ritorno",
"duplicate": "Duplicare",
"duplicateRiskAssessment": "Duplicare la valutazione del rischio",
"size": "Dimensione"
"size": "Dimensione",
"financial": "Finanziario",
"legal": "Legale",
"reputation": "Reputazione",
"operational": "Operativo",
"confidentiality": "Riservatezza",
"integrity": "Integrità",
"availability": "Disponibilità",
"authenticity": "Autenticità"
}
11 changes: 10 additions & 1 deletion frontend/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Behandelstatus",
"qualification": "Kwalificatie",
"currentLevel": "Huidig niveau",
"residualLevel": "Restniveau",
"riskMatrix": "Risicomatrix",
Expand Down Expand Up @@ -616,5 +617,13 @@
"back": "Opbrengst",
"duplicate": "Duplicaat",
"duplicateRiskAssessment": "Dupliceer de risicobeoordeling",
"size": "Grootte"
"size": "Grootte",
"financial": "Financieel",
"legal": "Juridisch",
"reputation": "Reputatie",
"operational": "Operationeel",
"confidentiality": "Vertrouwelijkheid",
"integrity": "Integriteit",
"availability": "Beschikbaarheid",
"authenticity": "Authenticiteit"
}
11 changes: 10 additions & 1 deletion frontend/messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Status leczenia",
"qualification": "Kwalifikacja",
"currentLevel": "Obecny poziom",
"residualLevel": "Poziom resztkowy",
"riskMatrix": "Macierz ryzyka",
Expand Down Expand Up @@ -653,5 +654,13 @@
"back": "Powrót",
"duplicate": "Duplikować",
"duplicateRiskAssessment": "Powielić ocenę ryzyka",
"size": "Rozmiar"
"size": "Rozmiar",
"financial": "Finansowy",
"legal": "Prawne",
"reputation": "Reputacja",
"operational": "Operacyjne",
"confidentiality": "Poufność",
"integrity": "Integralność",
"availability": "Dostępność",
"authenticity": "Autentyczność"
}
11 changes: 10 additions & 1 deletion frontend/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"urn": "URN",
"id": "ID",
"treatmentStatus": "Status de tratamento",
"qualification": "Qualificação",
"currentLevel": "Nível atual",
"residualLevel": "Nível residual",
"riskMatrix": "Matriz de risco",
Expand Down Expand Up @@ -616,5 +617,13 @@
"back": "Retornar",
"duplicate": "Duplicado",
"duplicateRiskAssessment": "Duplicar a avaliação de risco",
"size": "Tamanho"
"size": "Tamanho",
"financial": "Financeiro",
"legal": "Jurídica",
"reputation": "Reputação",
"operational": "Operacional",
"confidentiality": "Confidencialidade",
"integrity": "Integridade",
"availability": "Acessibilidade",
"authenticity": "Autenticidade"
}
10 changes: 9 additions & 1 deletion frontend/messages/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,5 +660,13 @@
"back": "Înapoi",
"duplicate": "Dublică",
"duplicateRiskAssessment": "Dublarea evaluării riscului",
"size": "Mărime"
"size": "Mărime",
"financial": "Finanțe",
"legal": "Juridic",
"reputation": "Reputație",
"operational": "Operațional",
"confidentiality": "Confidențialitate",
"integrity": "Integritate",
"availability": "Accesibilitate",
"authenticity": "Autenticitate"
}
4 changes: 3 additions & 1 deletion frontend/src/lib/components/Forms/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
export let field: string;
export let helpText: string | undefined = undefined;
export let cachedValue: string | undefined = undefined;
export let blank: boolean = false;
export let cacheLock: CacheLock = {
promise: new Promise((res) => res(null)),
resolve: (x) => x
Expand Down Expand Up @@ -73,7 +74,8 @@
{...$$restProps}
>
{#if !$constraints?.required && !options.find( (o) => new Set( ['--', 'undefined'] ).has(o.label.toLowerCase()) )}
<option value={null} selected>--</option>
{@const defaultValue = blank ? '' : null}
<option value={defaultValue} selected>--</option>
{/if}
{#each options as option}
<option value={option.value} style="background-color: {color_map[option.value]}">
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/lib/components/RiskMatrix/RiskMatrix.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
// reverse data array to display it in the right order
let displayedData: typeof data;
if (data) {
displayedData = data.some((e) => {
return e.length;
})
? data.slice().reverse()
: undefined;
displayedData = data.some((e) => e.length > 0) ? data.slice().reverse() : undefined;
}
let popupHover: PopupSettings[][] = [];
popupHover[0] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
</script>

<p class="whitespace-nowrap">
{#if data.strength_of_knowledge && data.strength_of_knowledge.symbol !== undefined}<sup
class="font-mono text-lg">{data.strength_of_knowledge.symbol}</sup
>{/if}{data.rid}
{#if data.strength_of_knowledge && data.strength_of_knowledge.symbol !== undefined}
<sup class="font-mono text-lg">{data.strength_of_knowledge.symbol}</sup>
{/if}
<span>{data.rid}</span>
</p>
10 changes: 9 additions & 1 deletion frontend/src/lib/utils/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,15 @@ export function localItems(): LocalItems {
appliedControlNoEffort: m.appliedControlNoEffort(),
appliedControlNoLink: m.appliedControlNoLink(),
riskAcceptanceNoExpiryDate: m.riskAcceptanceNoExpiryDate(),
riskAcceptanceExpired: m.riskAcceptanceExpired()
riskAcceptanceExpired: m.riskAcceptanceExpired(),
financial: m.financial(),
legal: m.legal(),
reputation: m.reputation(),
operational: m.operational(),
confidentiality: m.confidentiality(),
integrity: m.integrity(),
availability: m.availability(),
authenticity: m.authenticity()
};
return LOCAL_ITEMS;
}
1 change: 1 addition & 0 deletions frontend/src/lib/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const RiskScenarioSchema = baseNamedObject({
residual_proba: z.number().optional(),
residual_impact: z.number().optional(),
treatment: z.string().optional(),
qualifications: z.string().optional().array().optional(),
strength_of_knowledge: z.number().default(-1).optional(),
justification: z.string().optional().nullable(),
risk_assessment: z.string(),
Expand Down
Loading
Loading