Skip to content

Commit

Permalink
Cap asset security objective max value to 3 (#1344)
Browse files Browse the repository at this point in the history
* Cap asset security objective max value to 3

For now, we only manage 4-value security objective scales.

* Missing migration

---------

Co-authored-by: Abderrahmane Smimite <smimite@gmail.com>
  • Loading branch information
nas-tabchiche and ab-smith authored Jan 11, 2025
1 parent e2cb70b commit 810b92a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
52 changes: 52 additions & 0 deletions backend/core/migrations/0048_alter_asset_security_objectives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Generated by Django 5.1.4 on 2025-01-11 11:53

import core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0047_loadedlibrary_publication_date_and_more"),
]

operations = [
migrations.AlterField(
model_name="asset",
name="security_objectives",
field=models.JSONField(
blank=True,
default=dict,
help_text="The security objectives of the asset",
validators=[
core.validators.JSONSchemaInstanceValidator(
{
"$id": "https://ciso-assistant.com/schemas/assets/security_objectives.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "The security objectives of the asset",
"properties": {
"objectives": {
"patternProperties": {
"^[a-z_]+$": {
"properties": {
"is_enabled": {"type": "boolean"},
"value": {
"maximum": 3,
"minimum": 0,
"type": "integer",
},
},
"type": "object",
}
},
"type": "object",
}
},
"title": "Security objectives",
"type": "object",
}
)
],
verbose_name="Security objectives",
),
),
]
1 change: 1 addition & 0 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ class Type(models.TextChoices):
"value": {
"type": "integer",
"minimum": 0,
"maximum": 3,
},
"is_enabled": {
"type": "boolean",
Expand Down

0 comments on commit 810b92a

Please sign in to comment.