Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurswag committed Nov 26, 2024
1 parent e391800 commit f765433
Show file tree
Hide file tree
Showing 23 changed files with 1,579 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.1.1 on 2024-11-09 08:49

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0034_fix_loaded_libraries_objects_meta"),
]

operations = [
migrations.AddField(
model_name="riskscenario",
name="existing_applied_controls",
field=models.ManyToManyField(
blank=True,
related_name="risk_scenarios_e",
to="core.appliedcontrol",
verbose_name="Existing Applied controls",
),
),
]
24 changes: 24 additions & 0 deletions backend/core/migrations/0036_asset_owner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.1 on 2024-11-18 16:21

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0035_riskscenario_existing_applied_controls"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AddField(
model_name="asset",
name="owner",
field=models.ManyToManyField(
blank=True,
related_name="assets",
to=settings.AUTH_USER_MODEL,
verbose_name="Owner",
),
),
]
22 changes: 22 additions & 0 deletions backend/core/migrations/0037_appliedcontrol_priority.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.1.1 on 2024-11-19 15:31

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0036_asset_owner"),
]

operations = [
migrations.AddField(
model_name="appliedcontrol",
name="priority",
field=models.PositiveSmallIntegerField(
blank=True,
choices=[(1, "P1"), (2, "P2"), (3, "P3"), (4, "P4")],
null=True,
verbose_name="Priority",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Generated by Django 5.1.1 on 2024-11-22 07:00

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


class Migration(migrations.Migration):
dependencies = [
("core", "0037_appliedcontrol_priority"),
]

operations = [
migrations.AddField(
model_name="asset",
name="disaster_recovery_objectives",
field=models.JSONField(
blank=True,
default=dict,
help_text="The disaster recovery 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": {
"value": {
"minimum": 0,
"type": "integer",
}
},
"type": "object",
}
},
"type": "object",
}
},
"title": "Security objectives",
"type": "object",
}
)
],
verbose_name="Disaster recovery objectives",
),
),
migrations.AddField(
model_name="asset",
name="reference_link",
field=models.URLField(
blank=True,
help_text="External url for action follow-up (eg. Jira ticket)",
max_length=2048,
null=True,
verbose_name="Link",
),
),
migrations.AddField(
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": {
"minimum": 0,
"type": "integer",
},
},
"type": "object",
}
},
"type": "object",
}
},
"title": "Security objectives",
"type": "object",
}
)
],
verbose_name="Security objectives",
),
),
]
40 changes: 40 additions & 0 deletions backend/core/migrations/0039_make_urn_lowercase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 5.1.1 on 2024-11-23 07:58

from django.db import migrations
from django.db.models.functions import Lower


def make_urn_lowercase(apps, schema_editor):
Threat = apps.get_model("core", "Threat")
ReferenceControl = apps.get_model("core", "ReferenceControl")
RiskMatrix = apps.get_model("core", "RiskMatrix")
Framework = apps.get_model("core", "Framework")
RequirementNode = apps.get_model("core", "RequirementNode")
RequirementMappingSet = apps.get_model("core", "RequirementMappingSet")
StoredLibrary = apps.get_model("core", "StoredLibrary")
LoadedLibrary = apps.get_model("core", "LoadedLibrary")

models = [
Threat,
ReferenceControl,
RiskMatrix,
Framework,
RequirementMappingSet,
StoredLibrary,
LoadedLibrary,
]
for model in models:
model.objects.filter(urn__isnull=False).update(urn=Lower("urn"))

RequirementNode.objects.filter(urn__isnull=False).update(urn=Lower("urn"))
RequirementNode.objects.filter(parent_urn__isnull=False).update(
parent_urn=Lower("parent_urn")
)


class Migration(migrations.Migration):
dependencies = [
("core", "0038_asset_disaster_recovery_objectives_and_more"),
]

operations = [migrations.RunPython(make_urn_lowercase)]
39 changes: 39 additions & 0 deletions backend/core/migrations/0040_riskscenario_ref_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 5.1.1 on 2024-11-21 17:22

from django.db import migrations, models


def populate_default_ref_ids(apps, schema_editor):
RiskAssessment = apps.get_model("core", "RiskAssessment")

def get_default_ref_id(risk_assessment):
"""Return a unique reference ID for a given risk assessment."""
scenarios_ref_ids = [
x.ref_id for x in risk_assessment.risk_scenarios.all() if x.ref_id
]
nb_scenarios = len(scenarios_ref_ids) + 1
candidates = [f"R.{i+1}" for i in range(nb_scenarios)]
return next(x for x in candidates if x not in scenarios_ref_ids)

for risk_assessment in RiskAssessment.objects.all():
for scenario in risk_assessment.risk_scenarios.filter(ref_id=""):
scenario.ref_id = get_default_ref_id(risk_assessment)
scenario.save()


class Migration(migrations.Migration):
dependencies = [
("core", "0039_make_urn_lowercase"),
]

operations = [
migrations.AddField(
model_name="riskscenario",
name="ref_id",
field=models.CharField(
blank=True, max_length=8, verbose_name="Reference ID"
),
preserve_default=False,
),
migrations.RunPython(populate_default_ref_ids),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.1.2 on 2024-11-16 01:00

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


class Migration(migrations.Migration):

dependencies = [
('enterprise_core', '0002_clientsettings_show_images_unauthenticated_and_more'),
]

operations = [
migrations.AlterField(
model_name='clientsettings',
name='favicon',
field=models.ImageField(blank=True, null=True, upload_to='client_favicons', validators=[django.core.validators.FileExtensionValidator(['ico', 'png', 'jpeg', 'jpg', 'webp', 'svg'])]),
),
]
Loading

0 comments on commit f765433

Please sign in to comment.