Skip to content

Commit

Permalink
Merge branch 'CA-708-workshop-4-UX' of github.com:intuitem/ciso-assis…
Browse files Browse the repository at this point in the history
…tant-community into CA-708-workshop-4-UX
  • Loading branch information
Mohamed-Hacene committed Dec 16, 2024
2 parents 7eebaf3 + 2fb6202 commit c60f974
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
9 changes: 5 additions & 4 deletions backend/ebios_rm/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,13 @@ class Migration(migrations.Migration):
models.TextField(blank=True, verbose_name="Justification"),
),
(
"attack_paths",
models.ManyToManyField(
help_text="Attack paths that are pertinent to the operational scenario",
related_name="operational_scenarios",
"attack_path",
models.OneToOneField(
help_text="Attack path that is pertinent to the operational scenario",
related_name="operational_scenario",
to="ebios_rm.attackpath",
verbose_name="Attack paths",
on_delete=django.db.models.deletion.CASCADE,
),
),
(
Expand Down
14 changes: 6 additions & 8 deletions backend/ebios_rm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,12 @@ class OperationalScenario(AbstractBaseModel, FolderMixin):
related_name="operational_scenarios",
on_delete=models.CASCADE,
)
attack_paths = models.ManyToManyField(
attack_path = models.OneToOneField(
AttackPath,
verbose_name=_("Attack paths"),
related_name="operational_scenarios",
help_text=_("Attack paths that are pertinent to the operational scenario"),
related_name="operational_scenario",
help_text=_("Attack path that is pertinent to the operational scenario"),
on_delete=models.CASCADE,
)
threats = models.ManyToManyField(
Threat,
Expand Down Expand Up @@ -465,11 +466,7 @@ def ref_id(self):

@property
def gravity(self):
gravity = -1
for attack_path in self.attack_paths.all():
if attack_path.gravity > gravity:
gravity = attack_path.gravity
return gravity
return self.attack_path.gravity

def get_likelihood_display(self):
if self.likelihood < 0:
Expand All @@ -478,6 +475,7 @@ def get_likelihood_display(self):
"name": "--",
"description": "not rated",
"value": -1,
"hexcolor": "#f9fafb",
}
risk_matrix = self.parsed_matrix
return {
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 @@ -157,7 +157,7 @@ class OperationalScenarioReadSerializer(BaseModelSerializer):
str = serializers.CharField(source="__str__")
ebios_rm_study = FieldsRelatedField()
folder = FieldsRelatedField()
attack_paths = FieldsRelatedField(many=True)
attack_path = FieldsRelatedField()
threats = FieldsRelatedField(many=True)
likelihood = serializers.JSONField(source="get_likelihood_display")
gravity = serializers.JSONField(source="get_gravity_display")
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ export const URL_MODEL_MAP: ModelMap = {
{ field: 'ebios_rm_study', urlModel: 'ebios-rm' },
{ field: 'threats', urlModel: 'threats' },
{
field: 'attack_paths',
field: 'attack_path',
urlModel: 'attack-paths',
endpointUrl: 'ebios-rm/attack-paths',
urlParams: 'ebios_rm_study=',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export const AttackPathSchema = z.object({

export const operationalScenarioSchema = z.object({
ebios_rm_study: z.string(),
attack_paths: z.string().uuid().array(),
attack_path: z.string().uuid(),
threats: z.string().uuid().optional().array().optional(),
description: z.string(),
likelihood: z.number().optional().default(-1),
Expand Down

0 comments on commit c60f974

Please sign in to comment.