Skip to content

Commit

Permalink
Merge pull request #461 from intuitem/improve/5g-perf
Browse files Browse the repository at this point in the history
Improve performance for 5G SCM
  • Loading branch information
ab-smith committed May 20, 2024
2 parents fc82f9e + 3a5d871 commit 5baf1fc
Show file tree
Hide file tree
Showing 9 changed files with 1,807 additions and 3,764 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ django_secret_key
temp/
db/
.dccache
/backend/profiles
12 changes: 0 additions & 12 deletions backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,6 @@ def get_sorted_requirement_nodes_rec(
"status_display": req_as.get_status_display(),
"status_i18n": camel_case(req_as.status),
"style": "leaf",
"threats": ThreatReadSerializer(
req.threats.all(), many=True
).data,
"reference_controls": ReferenceControlReadSerializer(
req.reference_controls.all(), many=True
).data,
}
)
else:
Expand All @@ -325,12 +319,6 @@ def get_sorted_requirement_nodes_rec(
"name": req.name,
"description": req.description,
"style": "leaf",
"threats": ThreatReadSerializer(
req.threats.all(), many=True
).data,
"reference_controls": ReferenceControlReadSerializer(
req.reference_controls.all(), many=True
).data,
}
)
return result
Expand Down
19 changes: 19 additions & 0 deletions backend/core/migrations/0013_requirementnode_typical_evidence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.4 on 2024-05-20 10:52

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0012_alter_appliedcontrol_updated_at_and_more"),
]

operations = [
migrations.AddField(
model_name="requirementnode",
name="typical_evidence",
field=models.TextField(
blank=True, null=True, verbose_name="Typical evidence"
),
),
]
3 changes: 3 additions & 0 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ class RequirementNode(ReferentialObjectMixin):
null=True, verbose_name=_("Implementation groups")
)
assessable = models.BooleanField(null=False, verbose_name=_("Assessable"))
typical_evidence = models.TextField(
null=True, blank=True, verbose_name=_("Typical evidence")
)

class Meta:
verbose_name = _("RequirementNode")
Expand Down
5,524 changes: 1,775 additions & 3,749 deletions backend/library/libraries/enisa-5g-scm-v1.3.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/library/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def import_requirement_node(self, framework_object: Framework):
assessable=self.requirement_data.get("assessable"),
ref_id=self.requirement_data.get("ref_id"),
annotation=self.requirement_data.get("annotation"),
typical_evidence=self.requirement_data.get("typical_evidence"),
provider=framework_object.provider,
order_id=self.index,
name=self.requirement_data.get("name"),
Expand Down
6 changes: 6 additions & 0 deletions tools/convert_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- threats
- reference_controls
- annotation
- typical_evidence
The normal tree order shall be respected
If multiple threats or reference_control are given for a requirements, they shall be separated by blank or comma.
They shall be prefixed by the id of the corresponding base_urn and a semicolumn.
Expand Down Expand Up @@ -311,6 +312,9 @@ def get_color(wb, cell):
annotation = (
row[header["annotation"]].value if "annotation" in header else None
)
typical_evidence = (
row[header["typical_evidence"]].value if "typical_evidence" in header else None
)
implementation_groups = (
row[header["implementation_groups"]].value
if "implementation_groups" in header
Expand Down Expand Up @@ -346,6 +350,8 @@ def get_color(wb, cell):
req_node["description"] = description
if annotation:
req_node["annotation"] = annotation
if typical_evidence:
req_node["typical_evidence"] = typical_evidence
if implementation_groups:
req_node["implementation_groups"] = implementation_groups.split(",")
threats = row[header["threats"]].value if "threats" in header else None
Expand Down
5 changes: 2 additions & 3 deletions tools/enisa/convert_5g_scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
current_objective_id = objective_id
output_table.append(("", 2, objective_id, objectives[objective_id][0], objectives[objective_id][1], ""))
req_measures = ["1:"+measure_id for measure_id in measures if measures[measure_id][0] == objective_id]
output_table.append(("x", 3, ref_id, "", description, ",".join(req_measures)))
output_table.append(("", 4, "", "Evidence", evidence, ""))
output_table.append(("x", 3, ref_id, "", description, ",".join(req_measures), evidence))

print("generating", output_file_name)
wb_output = openpyxl.Workbook()
Expand Down Expand Up @@ -100,7 +99,7 @@

ws1 = wb_output.create_sheet("requirements")
ws1.append(
["assessable", "depth", "ref_id", "name", "description", "reference_controls"]
["assessable", "depth", "ref_id", "name", "description", "reference_controls", "typical_evidence"]
)
for row in output_table:
ws1.append(row)
Expand Down
Binary file modified tools/enisa/enisa-5g-scm-v1.3.xlsx
Binary file not shown.

0 comments on commit 5baf1fc

Please sign in to comment.