-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e391800
commit f765433
Showing
23 changed files
with
1,579 additions
and
12 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
backend/core/migrations/0035_riskscenario_existing_applied_controls.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
), | ||
), | ||
] |
99 changes: 99 additions & 0 deletions
99
backend/core/migrations/0038_asset_disaster_recovery_objectives_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
] |
19 changes: 19 additions & 0 deletions
19
enterprise/backend/enterprise_core/migrations/0003_alter_clientsettings_favicon.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'])]), | ||
), | ||
] |
Oops, something went wrong.