Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature/OPT-684] to dev #304

Merged
merged 6 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions otm/otm/entity/otm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List

from otm.otm.entity.component import Component
from otm.otm.entity.dataflow import Dataflow
from otm.otm.entity.representation import Representation, DiagramRepresentation, RepresentationType
from otm.otm.entity.trustzone import Trustzone
from .component import Component
from .dataflow import Dataflow
from .representation import Representation, DiagramRepresentation, RepresentationType
from .trustzone import Trustzone

REPRESENTATIONS_SIZE_DEFAULT_HEIGHT = 1000
REPRESENTATIONS_SIZE_DEFAULT_WIDTH = 1000
Expand All @@ -19,7 +19,7 @@ def __init__(self, project_name, project_id, provider):
self.dataflows: List[Dataflow] = []
self.threats = []
self.mitigations = []
self.version = "0.1.0"
self.version = "0.2.0"
self.__provider = provider

self.add_default_representation()
Expand Down Expand Up @@ -71,13 +71,13 @@ def add_component(self, id, name, type, parent, parent_type, source=None,
attributes=None, tags=None):
self.components.append(
Component(component_id=id, name=name, component_type=type, parent=parent, parent_type=parent_type,
source=source, attributes=attributes, tags=tags))
source=source, attributes=attributes, tags=tags))

def add_dataflow(self, id, name, source_node, destination_node, bidirectional=None,
source=None, attributes=None, tags=None):
self.dataflows.append(Dataflow(dataflow_id=id, name=name, bidirectional=bidirectional, source_node=source_node,
destination_node=destination_node, source=source, attributes=attributes,
tags=tags))
destination_node=destination_node, source=source, attributes=attributes,
tags=tags))

def add_representation(self, id_=None, name=None, type_=None):
self.representations.append(Representation(id_=id_, name=name, type_=type_))
Expand All @@ -86,7 +86,7 @@ def add_diagram_representation(self, id_=None, name=None, type_=None, size=None)
self.representations.append(DiagramRepresentation(id_=id_, name=name, type_=type_, size=size))

def add_default_representation(self):
if not self.__provider.provider_type == RepresentationType.DIAGRAM:
if self.__provider.provider_type != RepresentationType.DIAGRAM:
self.add_representation(id_=self.__provider.provider_name,
name=self.__provider.provider_name,
type_=self.__provider.provider_type)
Expand Down
1 change: 1 addition & 0 deletions otm/otm/entity/trustzone.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def json(self):
json = {
"id": self.id,
"name": self.name,
"type": self.type,
"risk": {
"trustRating": self.trustrating
}
Expand Down
2 changes: 0 additions & 2 deletions slp_base/slp_base/otm_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from otm.otm.otm_pruner import OTMPruner
from slp_base.slp_base.mapping import MappingLoader, MappingValidator
from slp_base.slp_base.otm_representations_pruner import OTMRepresentationsPruner
from slp_base.slp_base.otm_trustzone_unifier import OTMTrustZoneUnifier
from slp_base.slp_base.otm_validator import OTMValidator
from slp_base.slp_base.provider_loader import ProviderLoader
from slp_base.slp_base.provider_parser import ProviderParser
Expand Down Expand Up @@ -43,7 +42,6 @@ def process(self) -> OTM:
self._clean_resources()

OTMRepresentationsPruner(otm).prune()
OTMTrustZoneUnifier(otm).unify()
OTMValidator().validate(otm.json())

return otm
Expand Down
34 changes: 0 additions & 34 deletions slp_base/slp_base/otm_trustzone_unifier.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "public-cloud-01.customvpc",
"name": "CustomVPC",
"parent": {
"trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91"
"trustZone": "public-cloud-01"
},
"tags": [
"AWS::EC2::VPC"
Expand All @@ -15,7 +15,7 @@
"id": "public-cloud-02.rdscluster",
"name": "RDSCluster",
"parent": {
"trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91"
"trustZone": "public-cloud-02"
},
"tags": [
"AWS::RDS::DBCluster"
Expand All @@ -24,7 +24,7 @@
}
],
"dataflows": [],
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"id": "id",
"name": "name"
Expand All @@ -38,7 +38,16 @@
],
"trustZones": [
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"id": "public-cloud-01",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud",
"risk": {
"trustRating": 10
}
},
{
"id": "public-cloud-02",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud",
"risk": {
"trustRating": 10
Expand Down
13 changes: 11 additions & 2 deletions slp_cft/tests/resources/otm/cloudformation_minimal_content.otm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"name": "name",
"id": "id"
Expand All @@ -13,11 +13,20 @@
],
"trustZones": [
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"id": "public-cloud-01",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud 01",
"risk": {
"trustRating": 10
}
},
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud 02",
"risk": {
"trustRating": 10
}
}
],
"components": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"name": "name",
"id": "id"
Expand All @@ -14,6 +14,7 @@
"trustZones": [
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud",
"risk": {
"trustRating": 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"name": "name",
"id": "id"
Expand All @@ -14,6 +14,7 @@
"trustZones": [
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud",
"risk": {
"trustRating": 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"name": "name",
"id": "id"
Expand Down
4 changes: 3 additions & 1 deletion slp_cft/tests/resources/otm/otm_expected_result.otm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"name": "multiple-files",
"id": "multiple-files"
Expand All @@ -14,13 +14,15 @@
"trustZones": [
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud",
"risk": {
"trustRating": 10
}
},
{
"id": "f0ba7722-39b6-4c81-8290-a30a248bb8d9",
"type": "f0ba7722-39b6-4c81-8290-a30a248bb8d9",
"name": "Internet",
"risk": {
"trustRating": 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"name": "name",
"id": "id"
Expand All @@ -14,6 +14,7 @@
"trustZones": [
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Public Cloud",
"risk": {
"trustRating": 10
Expand Down
24 changes: 13 additions & 11 deletions slp_mtmt/tests/resources/mtmt/MTMT_example_coordinates.otm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"otmVersion": "0.1.0",
"otmVersion": "0.2.0",
"project": {
"name": "Example Project",
"id": "example-project"
Expand All @@ -22,7 +22,8 @@
],
"trustZones": [
{
"id": "6376d53e-6461-412b-8e04-7b3fe2b397de",
"id": "13ffd9d9-53ea-4b63-afab-07b730697ddd",
"type": "6376d53e-6461-412b-8e04-7b3fe2b397de",
"name": "Internet",
"risk": {
"trustRating": 10
Expand All @@ -48,7 +49,8 @@
]
},
{
"id": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"id": "acafa4b0-f94d-4077-8a42-74b959bd0796",
"type": "b61d6911-338d-46a8-9f39-8dcd24abfe91",
"name": "Cloud",
"risk": {
"trustRating": 10
Expand Down Expand Up @@ -80,7 +82,7 @@
"name": "Accounting PostgreSQL",
"type": "CD-MICROSOFT-AZURE-DB-POSTGRESQL",
"parent": {
"trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91"
"trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796"
},
"attributes": {
"Name": "Accounting PostgreSQL",
Expand Down Expand Up @@ -141,7 +143,7 @@
"name": "Android",
"type": "android-device-client",
"parent": {
"trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de"
"trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd"
},
"attributes": {
"Name": "Android",
Expand Down Expand Up @@ -191,7 +193,7 @@
"name": "Public API v2",
"type": "web-service",
"parent": {
"trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91"
"trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796"
},
"attributes": {
"Name": "Public API v2",
Expand Down Expand Up @@ -883,7 +885,7 @@
"name": "Azure File Storage",
"type": "azure-storage",
"parent": {
"trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91"
"trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796"
},
"attributes": {
"Name": "Azure File Storage",
Expand Down Expand Up @@ -986,7 +988,7 @@
"name": "iOS",
"type": "ios-device-client",
"parent": {
"trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de"
"trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd"
},
"attributes": {
"Name": "iOS",
Expand Down Expand Up @@ -1036,7 +1038,7 @@
"name": "Browser",
"type": "web-ui",
"parent": {
"trustZone": "6376d53e-6461-412b-8e04-7b3fe2b397de"
"trustZone": "13ffd9d9-53ea-4b63-afab-07b730697ddd"
},
"attributes": {
"Name": "Browser",
Expand Down Expand Up @@ -1085,7 +1087,7 @@
"name": "Web API",
"type": "web-service",
"parent": {
"trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91"
"trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796"
},
"attributes": {
"Name": "Web API",
Expand Down Expand Up @@ -1277,7 +1279,7 @@
"name": "Azure Storage",
"type": "azure-storage",
"parent": {
"trustZone": "b61d6911-338d-46a8-9f39-8dcd24abfe91"
"trustZone": "acafa4b0-f94d-4077-8a42-74b959bd0796"
},
"attributes": {
"Name": "Azure Storage",
Expand Down
Loading