Skip to content

Commit cf949b7

Browse files
Merge pull request #343 from iriusrisk/release/1.21.0
Release/1.21.0 to main
2 parents 1a30521 + 225e03c commit cf949b7

File tree

114 files changed

+3150
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3150
-198
lines changed

_sl_build/modules.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
{'name': 'slp_visio', 'type': 'processor', 'provider_type': 'VISIO', 'allowed_imports': _slp_allowed_imports},
2222
{'name': 'slp_visio', 'type': 'processor', 'provider_type': 'LUCID', 'allowed_imports': _slp_allowed_imports},
2323
{'name': 'slp_mtmt', 'type': 'processor', 'provider_type': 'MTMT', 'allowed_imports': _slp_allowed_imports},
24-
# TODO Set type to processor to make the endpoint available
25-
{'name': 'slp_drawio', 'provider_type': 'DRAWIO', 'allowed_imports': _slp_allowed_imports}
24+
{'name': 'slp_drawio', 'type': 'processor', 'provider_type': 'DRAWIO', 'allowed_imports': _slp_allowed_imports}
2625
]
2726

2827
"""

docs/Quickstart-Guide-for-Beginners.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ If we take the same mapping file we have downloaded for the `parse` command, we
145145

146146
#### **Diagram mapping files**
147147
Also described in the processors' documentation, allows you to validate the format of mapping
148-
files used for diagram conversions as Visio and Lucidchart.
148+
files used for diagram conversions as Visio, Lucidchart and Drawio.
149149

150150
Let's download the IriusRisk's Visio mapping file located in the `examples/visio` folder:
151151
```shell
@@ -163,6 +163,12 @@ You can also validate Lucidchart mapping files like it is shown in this example:
163163
```shell
164164
startleft validate --mapping-file iriusrisk-lucid-aws-mapping.yaml --mapping-type LUCID
165165
```
166+
To validate the IriusRisk's Drawio mapping file located in the `examples/drawio` folder:
167+
???+ example "Drawio example"
168+
169+
```shell
170+
startleft validate --mapping-file iriusrisk-drawio-mapping.yaml --mapping-type DRAWIO
171+
```
166172
#### **External Threat Model mapping files**
167173
The last type of mapping file we can validate is External Threat Model. This allows you to validate the format of mapping
168174
files used for External Threat Model conversions as MTMT (Microsoft Threat Modeling Tool):

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Split by type, the currently supported input formats are:
4444

4545
* **Diagram**:
4646
* Microsoft Visio (including diagrams exported from Lucidchart).
47+
* Drawio
4748

4849
* **Threat Model**:
4950
* Microsoft Threat Modeling Tool (MTMT).
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
!!! note ""
2+
3+
This page explains how the drawio processor analyzes the shape data to retrieve its `type`
4+
to be used as a value when mapping.
5+
6+
The basics of parsing Drawio diagrams and generating threat models is to categorize the
7+
shapes into their corresponding component type.
8+
9+
A wide variety of stencils are available at Drawio (even custom).
10+
The scope of this processor is to map a subset of these stencils as indicated below.
11+
12+
### Mapping of AWS Stencils
13+
14+
---
15+
This AWS Stencils can be found under the Networking Section:
16+
17+
![img/shape-type/drawio-aws-stencils.png](img/shape-type/drawio-aws-stencils.png)
18+
19+
Every shape available at those stencils follows the same `style` structure.
20+
21+
Click Edit -> Edit Style...
22+
23+
![img/shape-type/drawio-aws-shape-edit-style.png](img/shape-type/drawio-aws-shape-edit-style.png)
24+
25+
The shape attribute has the information of which type this shape belongs.
26+
27+
![img/shape-type/drawio-aws-shape-style.png](img/shape-type/drawio-aws-shape-style.png)
28+
29+
For example: this shape can be categorized as `AWS EMR (Elastic MapReduce)`.
30+
31+
There are some exceptional cases where the `shape` attribute is not enough
32+
and an attribute equivalence has to be used to get the type.
33+
34+
| shape | equivalence |
35+
|--------------|-------------|
36+
| group | grIcon |
37+
| groupCenter | grIcon |
38+
| resourceIcon | resIcon |
39+
| productIcon | prIcon |
40+
41+
For example, as the shape AWS SNS (Simple Notification Service) has the attribute `productIcon`,
42+
then the `prIcon` value will be used instead.
43+
44+
![img/shape-type/drawio-aws-shape-style-pr-icon.png](img/shape-type/drawio-aws-shape-style-pr-icon.png)
45+
46+
> As many components are repeated in different Stencils available and the only difference is the prefix mxgraph.aws[3/4],
47+
> this prefix is simplified to aws. For example, the `prIcon=mxgraph.aws4.sns` is read as `shape_type: aws.sns`
48+
49+
### Mapping of mxGraph Stencils
50+
51+
---
52+
Many other stencils at drawio use the previous logic of `shape=mxgraph.{group}.{type}` within their style
53+
which we can use to get the type.
54+
55+
When this info is available, the processor will read it and remove the `mxgraph.` prefix to set the `shape_type`.
56+
For example, the `prIcon=mxgraph.android.phone2` is read as `shape_type: android.phone2`
57+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Drawio mapping
2+
3+
4+
---
5+
6+
??? note "This mapping configuration only applies to Drawio Processor."
7+
8+
Please refer to another mapping file configuration documentation if needed.
9+
You can locate each processor's documentation in the left menu under the "StartLeft Processors (SLP)" section.
10+
11+
A source mapping file (or 'mapping file' for short) describes how to find and map components and
12+
trust zones in the source Drawio file.
13+
14+
This mapping file is divided into two sections. The syntax and available functions used to define trust zone and
15+
component mappings are identical.
16+
17+
* `trustzones`.
18+
* `components`.
19+
20+
## How mapping works?
21+
Every shape in the diagram is loaded by the Drawio processor along with its name and internal Drawio type. Extracting
22+
the type is a key part of the parsing process and is explained in deep [here](Drawio-Calculating-Shape-Type.md).
23+
24+
Once the shapes are loaded, the mapping files are used to change the type of the components to the one expected in the
25+
OTM file. If no coincidence is found, a default type (`empty-component`) is set.
26+
27+
### Mapping preference
28+
There are two mapping files, the default and the custom ones. Inside them, there are trust zone and component mappings.
29+
The shapes in the Drawio files can be mapped by its type or name. The preference is the following:
30+
31+
1. Custom mappings prevails over default mappings.
32+
2. Name matches during mapping prevails over type matches.
33+
3. Trust zone mappings prevails over component mappings.
34+
35+
### Mapping functions
36+
Both for components or trust zones, there are different ways to define mappings. A set of functions are available to
37+
simplify the creation of the mapping file. These functions work for mapping by name or type.
38+
39+
#### Mapping by exact match
40+
The simplest case, when the `label` in the mapping file matches exactly the component name or type.
41+
42+
```yaml
43+
- label: aws.s3
44+
type: s3
45+
```
46+
47+
#### Mapping by a Regex
48+
Instead of searching for an exact match, a regex can be used to leverage the mapping capabilities.
49+
50+
```yaml
51+
- label: {$regex: ^aws.s3\_.*$}
52+
type: s3
53+
```
54+
55+
#### Mapping by list
56+
It is used when a group of name or types must be mapped to the same type in the OTM.
57+
58+
```yaml
59+
- label:
60+
- aws.ec2
61+
- aws.ec2_c6a_instance
62+
- aws.ec2_c6gn_instance
63+
- aws.ec2_c6i_instance
64+
- aws.ec2_c6in_instance
65+
type: ec2
66+
```
67+
68+
### The Default Trust Zone
69+
The [OTM standard](../../../Open-Threat-Model-(OTM).md) defines that every component in the
70+
threat model must have a parent. Frequently, the original Drawio diagram has components that are not nested inside any
71+
parent. In those cases, the trust zone set as a default in the mapping file is included in the OTM as their parent.
72+
73+
```yaml
74+
- label: Public Cloud
75+
type: public-cloud
76+
default: true
77+
```
78+
79+
!!! note ""
80+
Notice that this Trust Zone can be created more than once. If there is a component in the original diagram called
81+
"Public Cloud", a Trust Zone object will be created in the OTM. Then, if there are some missing components, a
82+
default Trust Zone of the same type will be created again to gather them.

0 commit comments

Comments
 (0)