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

Workshop 1 #1130

Merged
merged 50 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
04ef58a
starting point
ab-smith Nov 29, 2024
c32cad4
Basic tile styling
ab-smith Nov 29, 2024
e3c8065
Merge branch 'main' into ebios-rm-tiles
ab-smith Nov 29, 2024
5683520
wip
ab-smith Nov 29, 2024
f15e8e0
wip
ab-smith Nov 29, 2024
8e296c6
Merge branch 'main' into ebios-rm-tiles
ab-smith Nov 30, 2024
b410a6e
Merge branch 'main' into ebios-rm-tiles
ab-smith Dec 1, 2024
ff16985
Closer to the training materials
ab-smith Dec 1, 2024
454aae0
Formatter
ab-smith Dec 1, 2024
4f9c994
workshop1: prepare step 1/2
Mohamed-Hacene Dec 2, 2024
1d44ddd
Merge remote-tracking branch 'origin/CA-660-create-base-models' into …
Mohamed-Hacene Dec 3, 2024
c3e6497
chore: remove bad imports
Mohamed-Hacene Dec 3, 2024
2b6b927
feat: add ebios rm base endpoint
Mohamed-Hacene Dec 3, 2024
25e369f
feat: manage ebios rm from front
Mohamed-Hacene Dec 3, 2024
fa9c7c6
feat: set ebios object breadcrumbs
Mohamed-Hacene Dec 3, 2024
0789977
feat: add risk matrix field in ebios rm
Mohamed-Hacene Dec 3, 2024
eac11ca
Merge remote-tracking branch 'origin/CA-660-create-base-models' into …
Mohamed-Hacene Dec 3, 2024
7e730ea
chore: remove repeated argument
Mohamed-Hacene Dec 3, 2024
b6084b4
feat: prepare step 1/2
Mohamed-Hacene Dec 3, 2024
eae82e4
Merge branch 'main' into CA-672-Step-1.1-1.2
Mohamed-Hacene Dec 3, 2024
334bf99
Fix code scanning alert no. 18: Information exposure through an excep…
Mohamed-Hacene Dec 3, 2024
e0b1521
chore: format
Mohamed-Hacene Dec 3, 2024
6d733ab
Merge branch 'CA-672-Step-1.1-1.2' of github.com:intuitem/ciso-assist…
Mohamed-Hacene Dec 3, 2024
2023fd5
chore: format serializer
Mohamed-Hacene Dec 3, 2024
4c5090b
Merge remote-tracking branch 'origin/CA-681-create-crud-endpoints-for…
Mohamed-Hacene Dec 4, 2024
4a9da32
feat: map new ebios endpoint
Mohamed-Hacene Dec 4, 2024
3ef3052
chore: format
Mohamed-Hacene Dec 4, 2024
356b552
feat: add step 1.3
Mohamed-Hacene Dec 4, 2024
3c7ec09
fix: typos
Mohamed-Hacene Dec 4, 2024
7fc9aa3
Merge branch 'CA-672-Step-1.1-1.2' into CA-673-Step-1.3
Mohamed-Hacene Dec 4, 2024
41373e5
feat: add qualifications endpoints
Mohamed-Hacene Dec 4, 2024
1abf468
feat: add step 1.4
Mohamed-Hacene Dec 4, 2024
5eeb5a3
chore: remove form debug
Mohamed-Hacene Dec 5, 2024
cdae724
Merge branch 'main' into CA-674-Step-1.4
Mohamed-Hacene Dec 5, 2024
050c587
fix: typos
Mohamed-Hacene Dec 5, 2024
17c48aa
Rename base route to baseline
nas-tabchiche Dec 5, 2024
6e26974
Add risk_matrix property and endpoint to feared events
nas-tabchiche Dec 5, 2024
052c067
Add gravity choices endpoint for feared events
nas-tabchiche Dec 5, 2024
7f03d85
Internationalize gravity field
nas-tabchiche Dec 5, 2024
981bb34
Add gravity field to feared event form
nas-tabchiche Dec 5, 2024
4db984a
Add valueType parameter to SelectField interface
nas-tabchiche Dec 5, 2024
1bfca6e
chore: use PrimaryKeyRelatedField insteand of SlugRelatedField
Mohamed-Hacene Dec 6, 2024
76f84ef
Merge branch 'CA-674-Step-1.4' of github.com:intuitem/ciso-assistant-…
Mohamed-Hacene Dec 6, 2024
475a7b0
Merge branch 'main' into CA-674-Step-1.4
Mohamed-Hacene Dec 6, 2024
0120a29
Remove required contraint from ref_id
nas-tabchiche Dec 6, 2024
c8b5471
Add ebios_rm before core in INSTALLED_APPS
nas-tabchiche Dec 6, 2024
c597f00
Add selectOptions for feared event
nas-tabchiche Dec 6, 2024
414e106
Fix choices for feared event gravity on create
nas-tabchiche Dec 6, 2024
1263644
Serialize feared event gravity display
nas-tabchiche Dec 6, 2024
b6d9220
Add translations
nas-tabchiche Dec 6, 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
19 changes: 19 additions & 0 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from core.models import *
from iam.models import *
from ebios_rm.models import EbiosRMStudy

from rest_framework import serializers
from rest_framework.exceptions import PermissionDenied
Expand Down Expand Up @@ -600,6 +601,14 @@ class ComplianceAssessmentWriteSerializer(BaseModelSerializer):
required=False,
allow_null=True,
)
ebios_rm_studies = serializers.SlugRelatedField(
many=True,
slug_field="id",
queryset=EbiosRMStudy.objects.all(),
required=False,
allow_null=True,
write_only=True,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EBIOS RM stuff leaking on core should be avoided unless absolutely necessary. Since this field would only be needed in EBIOS RM contexts, what about having a serializer inheriting from this one in the ebios_rm app, with the additional field?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, let's take this shortcut.

create_applied_controls_from_suggestions = serializers.BooleanField(
write_only=True, required=False, default=False
)
Expand Down Expand Up @@ -712,3 +721,13 @@ class FilteringLabelWriteSerializer(BaseModelSerializer):
class Meta:
model = FilteringLabel
exclude = ["folder", "is_published"]


class QualificationReadSerializer(ReferentialSerializer):
class Meta:
model = Qualification
exclude = ["translations"]


class QualificationWriteSerializer(QualificationReadSerializer):
pass
4 changes: 4 additions & 0 deletions backend/core/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@
"view_operationalscenario",
"change_operationalscenario",
"delete_operationalscenario",
"view_qualification",
"add_qualification",
"change_qualification",
"delete_qualification",
]

THIRD_PARTY_RESPONDENT_PERMISSIONS_LIST = [
Expand Down
5 changes: 5 additions & 0 deletions backend/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
FilteringLabelViewSet,
basename="filtering-labels",
)
router.register(
r"qualifications",
QualificationViewSet,
basename="qualifications",
)

ROUTES = settings.ROUTES
MODULES = settings.MODULES.values()
Expand Down
19 changes: 17 additions & 2 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,13 @@ class AssetViewSet(BaseModelViewSet):
"""

model = Asset
filterset_fields = ["folder", "parent_assets", "type", "risk_scenarios"]
filterset_fields = [
"folder",
"parent_assets",
"type",
"risk_scenarios",
"ebios_rm_studies",
]
search_fields = ["name", "description", "business_value"]

@action(detail=False, name="Get type choices")
Expand Down Expand Up @@ -2025,13 +2031,22 @@ def post(self, request, *args, **kwargs):
return Response(status=status.HTTP_400_BAD_REQUEST)


class QualificationViewSet(BaseModelViewSet):
"""
API endpoint that allows qualifications to be viewed or edited.
"""

model = Qualification
search_fields = ["name"]


class ComplianceAssessmentViewSet(BaseModelViewSet):
"""
API endpoint that allows compliance assessments to be viewed or edited.
"""

model = ComplianceAssessment
filterset_fields = ["framework", "project", "status"]
filterset_fields = ["framework", "project", "status", "ebios_rm_studies"]
search_fields = ["name", "description", "ref_id"]
ordering_fields = ["name", "description"]

Expand Down
1 change: 1 addition & 0 deletions backend/ebios_rm/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class Migration(migrations.Migration):
related_name="ebios_rm_studies",
to="core.riskmatrix",
verbose_name="Risk matrix",
blank=True,
),
),
],
Expand Down
1 change: 1 addition & 0 deletions backend/ebios_rm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Status(models.TextChoices):
help_text=_(
"Risk matrix used as a reference for the study. Defaults to `urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm`"
),
blank=True,
)
assets = models.ManyToManyField(
Asset,
Expand Down
2 changes: 1 addition & 1 deletion backend/ebios_rm/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class Meta:


class FearedEventReadSerializer(BaseModelSerializer):
str = serializers.CharField(source="__str__")
ebios_rm_study = FieldsRelatedField()
qualifications = FieldsRelatedField(["name"], many=True)
folder = FieldsRelatedField()

class Meta:
Expand Down
4 changes: 4 additions & 0 deletions backend/ebios_rm/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def status(self, request):
class FearedEventViewSet(BaseModelViewSet):
model = FearedEvent

filterset_fields = [
"ebios_rm_study",
]


class RoToViewSet(BaseModelViewSet):
model = RoTo
Expand Down
7 changes: 7 additions & 0 deletions frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,13 @@
"ebiosWs5_4": "Assess and document residual risks",
"ebiosWs5_5": "Establish risk monitoring framework",
"activity": "Activity",
"ebiosRmMatrixHelpText": "Risk matrix used as a reference for the study. Defaults to `urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm`",
"activityOne": "Activity 1",
"activityTwo": "Activity 2",
"ebiosRmStudy": "Ebios RM study",
"qualifications": "Qualifications",
"impacts": "Impacts",
"ebiosRmStudies": "Ebios RM studies",
"bringTheEvidences": "Bring the evidences",
"bringTheEvidencesHelpText": "If disabled, the object will be duplicated without its evidences"
}
2 changes: 1 addition & 1 deletion frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
let tokenPath = '';
crumbs = tokens.map((t) => {
tokenPath += '/' + t;
if (t === $breadcrumbObject.id) {
if (t === $breadcrumbObject?.id) {
if ($breadcrumbObject.name) {
t = $breadcrumbObject.name;
} else if ($breadcrumbObject.first_name && $breadcrumbObject.last_name) {
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/lib/components/Forms/ModelForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import SsoSettingsForm from './ModelForm/SsoSettingForm.svelte';
import FolderForm from './ModelForm/FolderForm.svelte';
import GeneralSettingsForm from './ModelForm/GeneralSettingForm.svelte';
import EbiosRmForm from './ModelForm/EbiosRmForm.svelte';
import FearedEventForm from './ModelForm/FearedEventForm.svelte';

import AutocompleteSelect from './AutocompleteSelect.svelte';

Expand Down Expand Up @@ -255,6 +257,10 @@
<GeneralSettingsForm {form} {model} {cacheLocks} {formDataCache} {data} />
{:else if URLModel === 'filtering-labels'}
<FilteringLabelForm {form} {model} {cacheLocks} {formDataCache} />
{:else if URLModel === 'ebios-rm'}
<EbiosRmForm {form} {model} {cacheLocks} {formDataCache} {context} />
{:else if URLModel === 'feared-events'}
<FearedEventForm {form} {model} {cacheLocks} {formDataCache} {initialData} />
{/if}
<div class="flex flex-row justify-between space-x-4">
{#if closeModal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
options={getOptions({ objects: model.foreignKeys['baseline'] })}
/>
{/if}
{#if initialData.ebios_rm_studies}
<AutocompleteSelect
{form}
field="ebios_rm_studies"
multiple
cacheLock={cacheLocks['ebios_rm_studies']}
bind:cachedValue={formDataCache['ebios_rm_studies']}
label={m.ebiosRmStudies()}
options={getOptions({ objects: model.foreignKeys['ebios_rm_studies'] })}
hidden
/>
{/if}
<AutocompleteSelect
{form}
options={getOptions({
Expand Down
110 changes: 110 additions & 0 deletions frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<script lang="ts">
import type { SuperValidated } from 'sveltekit-superforms';
import type { ModelInfo, CacheLock } from '$lib/utils/types';
import TextField from '$lib/components/Forms/TextField.svelte';
import AutocompleteSelect from '$lib/components/Forms/AutocompleteSelect.svelte';
import Select from '$lib/components/Forms/Select.svelte';
import * as m from '$paraglide/messages.js';
import { getOptions } from '$lib/utils/crud';
import TextArea from '../TextArea.svelte';

export let form: SuperValidated<any>;
export let model: ModelInfo;
export let cacheLocks: Record<string, CacheLock> = {};
export let formDataCache: Record<string, any> = {};
export let initialData: Record<string, any> = {};
export let context: string;
</script>

{#if context !== 'ebiosRmStudy'}
<TextField
{form}
field="version"
label={m.version()}
cacheLock={cacheLocks['version']}
bind:cachedValue={formDataCache['version']}
/>
<TextField
{form}
field="ref_id"
label={m.refId()}
cacheLock={cacheLocks['ref_id']}
bind:cachedValue={formDataCache['ref_id']}
/>
<AutocompleteSelect
{form}
options={getOptions({ objects: model.foreignKeys['folder'] })}
field="folder"
cacheLock={cacheLocks['folder']}
bind:cachedValue={formDataCache['folder']}
label={m.domain()}
hidden={initialData.folder}
/>
<AutocompleteSelect
{form}
options={getOptions({ objects: model.foreignKeys['risk_matrix'] })}
field="risk_matrix"
cacheLock={cacheLocks['risk_matrix']}
bind:cachedValue={formDataCache['risk_matrix']}
label={m.riskMatrix()}
helpText={m.ebiosRmMatrixHelpText()}
/>
{:else if context === 'ebiosRmStudy'}
<div class="relative p-2 space-y-2 border rounded-md">
<p class="absolute -top-3 bg-white font-bold">{m.activityOne()}</p>
<TextField
{form}
field="version"
label={m.version()}
cacheLock={cacheLocks['version']}
bind:cachedValue={formDataCache['version']}
/>
<TextField
{form}
required
field="ref_id"
label={m.refId()}
cacheLock={cacheLocks['ref_id']}
bind:cachedValue={formDataCache['ref_id']}
/>
<TextArea
{form}
field="observation"
label={m.observation()}
cacheLock={cacheLocks['observation']}
bind:cachedValue={formDataCache['observation']}
/>
<AutocompleteSelect
multiple
{form}
options={getOptions({ objects: model.foreignKeys['authors'], label: 'email' })}
field="authors"
cacheLock={cacheLocks['authors']}
bind:cachedValue={formDataCache['authors']}
label={m.authors()}
/>
<AutocompleteSelect
multiple
{form}
options={getOptions({ objects: model.foreignKeys['reviewers'], label: 'email' })}
field="reviewers"
cacheLock={cacheLocks['reviewers']}
bind:cachedValue={formDataCache['reviewers']}
label={m.reviewers()}
/>
</div>
<div class="relative p-2 space-y-2 border rounded-md">
<p class="absolute -top-3 bg-white font-bold">{m.activityTwo()}</p>
<AutocompleteSelect
multiple
{form}
options={getOptions({
objects: model.foreignKeys['assets'],
extra_fields: [['folder', 'str']],
label: 'auto'
})}
field="assets"
label={m.assets()}
/>
</div>
{/if}
61 changes: 61 additions & 0 deletions frontend/src/lib/components/Forms/ModelForm/FearedEventForm.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script lang="ts">
import type { SuperValidated } from 'sveltekit-superforms';
import type { ModelInfo, CacheLock } from '$lib/utils/types';
import TextField from '$lib/components/Forms/TextField.svelte';
import AutocompleteSelect from '$lib/components/Forms/AutocompleteSelect.svelte';
import Select from '$lib/components/Forms/Select.svelte';
import * as m from '$paraglide/messages.js';
import { getOptions } from '$lib/utils/crud';
import TextArea from '../TextArea.svelte';

export let form: SuperValidated<any>;
export let model: ModelInfo;
export let cacheLocks: Record<string, CacheLock> = {};
export let formDataCache: Record<string, any> = {};
export let initialData: Record<string, any> = {};
export let context: string;
</script>

<AutocompleteSelect
{form}
options={getOptions({ objects: model.foreignKeys['ebios_rm_study'] })}
field="ebios_rm_study"
cacheLock={cacheLocks['ebios_rm_study']}
bind:cachedValue={formDataCache['ebios_rm_study']}
label={m.ebiosRmStudy()}
hidden={initialData.ebios_rm_study}
/>
<TextField
{form}
field="ref_id"
label={m.refId()}
cacheLock={cacheLocks['ref_id']}
bind:cachedValue={formDataCache['ref_id']}
/>
<TextArea
{form}
field="justification"
label={m.justification()}
cacheLock={cacheLocks['justification']}
bind:cachedValue={formDataCache['justification']}
/>
<AutocompleteSelect
multiple
{form}
options={getOptions({
objects: model.foreignKeys['assets'],
extra_fields: [['folder', 'str']],
label: 'auto'
})}
field="assets"
label={m.assets()}
/>
<AutocompleteSelect
multiple
{form}
options={getOptions({
objects: model.foreignKeys['qualifications']
})}
field="qualifications"
label={m.qualifications()}
/>
Loading
Loading