Skip to content

Commit

Permalink
Merge branch 'main' into feat/flash_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-intuitem committed May 23, 2024
2 parents 4d027ea + eafdb81 commit 9eacf45
Show file tree
Hide file tree
Showing 10 changed files with 6,023 additions and 4,164 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export EMAIL_HOST_PASSWORD=''
export DEFAULT_FROM_EMAIL=ciso-assistant@ciso-assistantcloud.com
export EMAIL_HOST=localhost
export EMAIL_PORT=1025
export EMAIL_USE_TLS=True
```

**Other variables**
Expand Down
35 changes: 35 additions & 0 deletions backend/core/migrations/0014_auto_20240522_1731.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 5.0.4 on 2024-05-22 17:31

from core.models import StoredLibrary, LoadedLibrary
from django.db import migrations, models


def fix_urns_for_enisa_5g_scm(apps, schema_editor):
enisa_5g_scm_stored_library = StoredLibrary.objects.filter(
urn="urn:intuitem:risk:library:enisa-5g-scm-v1.3"
)
if enisa_5g_scm_stored_library:
enisa_5g_scm_stored_library[
0
].delete() # the lib will be added again in the store at the end of the migration
enisa_5g_scm_loaded_library = LoadedLibrary.objects.filter(
urn="urn:intuitem:risk:library:enisa-5g-scm-v1.3"
)
if enisa_5g_scm_loaded_library:
count = 0
for b in enisa_5g_scm_loaded_library[0].reference_controls.all():
if b.urn[:4] != "urn:":
b.urn = "urn:intuitem:" + b.urn
b.save()
count += 1
print(f"fixed {count} URNs")


class Migration(migrations.Migration):
dependencies = [
("core", "0013_requirementnode_typical_evidence"),
]

operations = [
migrations.RunPython(fix_urns_for_enisa_5g_scm),
]
10 changes: 10 additions & 0 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def __init_class__(cls):
def store_library_content(
cls, library_content: bytes, builtin: bool = False
) -> "StoredLibrary | None":
from library.utils import match_urn

hash_checksum = sha256(library_content)
if hash_checksum in StoredLibrary.HASH_CHECKSUM_SET:
return None # We do not store the library if its hash checksum is in the database.
Expand All @@ -147,8 +149,16 @@ def store_library_content(
raise ValueError(err)

urn = library_data["urn"]
if not match_urn(urn):
raise ValueError("Library URN is badly formatted")
locale = library_data.get("locale", "en")
version = int(library_data["version"])

if StoredLibrary.objects.filter(
urn=urn, locale=locale, version=version
).exists():
return None # We do not store the library if it is same content

is_loaded = LoadedLibrary.objects.filter(
urn=urn, locale=locale, version=version
).exists()
Expand Down
3 changes: 2 additions & 1 deletion backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,8 @@ def generate_html_rec(requirement_node: RequirementNode):
table += bar_graph(requirement_node)
else:
assessment = RequirementAssessment.objects.filter(
requirement__urn=requirement_node.urn
requirement__urn=requirement_node.urn,
compliance_assessment=compliance_assessment,
).first()

table += "<div>"
Expand Down
Loading

0 comments on commit 9eacf45

Please sign in to comment.