Skip to content

Commit 1a30521

Browse files
Merge pull request #341 from iriusrisk/release/1.20.0
Release/1.20.0 to main
2 parents 584f067 + 77ad228 commit 1a30521

File tree

231 files changed

+8643
-3596
lines changed

Some content is hidden

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

231 files changed

+8643
-3596
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# StartLeft
22

3+
![Supported python versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)
4+
![Software Quality Assurance](https://github.com/iriusrisk/startleft/actions/workflows/qa.yml/badge.svg)
35
![Semgrep scan with owasp-top-ten & cwe-top-25](https://github.com/iriusrisk/startleft/actions/workflows/semgrep.yml/badge.svg)
46
![Documentation](https://github.com/iriusrisk/startleft/actions/workflows/documentation.yml/badge.svg)
5-
![Software Quality Assurance](https://github.com/iriusrisk/startleft/actions/workflows/qa.yml/badge.svg)
67

78
**StartLeft** is an automation tool for **generating Threat Models** written in the
89
[Open Threat Model (OTM)](http://iriusrisk.github.io/startleft/site/Open-Threat-Model-%28OTM%29/)

_sl_build/modules.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
STARTLEFT_MODULE = {'name': 'startleft', 'type': 'general', 'allowed_imports': ['slp_base', 'otm', 'sl_util']}
66
# TODO Startleft needs to depend on TF and CFT processors until a decision is token about the search function
7-
STARTLEFT_MODULE['allowed_imports'].extend(['slp_cft', 'slp_tf'])
7+
# TODO Startleft needs to depend on VISIO processors until a decision is token about the summary function
8+
STARTLEFT_MODULE['allowed_imports'].extend(['slp_cft', 'slp_tf', 'slp_visio'])
89

910
# TODO Dependency between otm and sl_util must be removed
1011
OTM_MODULE = {'name': 'otm', 'type': 'general', 'allowed_imports': ['sl_util']}
@@ -19,7 +20,9 @@
1920
{'name': 'slp_tfplan', 'type': 'processor', 'provider_type': 'TFPLAN', 'allowed_imports': _slp_allowed_imports},
2021
{'name': 'slp_visio', 'type': 'processor', 'provider_type': 'VISIO', 'allowed_imports': _slp_allowed_imports},
2122
{'name': 'slp_visio', 'type': 'processor', 'provider_type': 'LUCID', 'allowed_imports': _slp_allowed_imports},
22-
{'name': 'slp_mtmt', 'type': 'processor', 'provider_type': 'MTMT', 'allowed_imports': _slp_allowed_imports}
23+
{'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}
2326
]
2427

2528
"""

deployment/Dockerfile.application

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8-alpine
1+
FROM python:3.8-alpine AS startleft-base
22

33
WORKDIR /usr/src/app
44

@@ -15,9 +15,21 @@ COPY . .
1515

1616
RUN pip install .
1717

18-
RUN rm -r ../app/*
1918

20-
# Remove not needed dependencies for runtime
21-
RUN apk del git geos-dev re2-dev py3-pybind11-dev
19+
FROM python:3.8-alpine
20+
21+
WORKDIR /app
22+
23+
RUN apk update && \
24+
apk add libmagic && \
25+
apk add re2 && \
26+
apk add graphviz && \
27+
apk add lapack && \
28+
apk add cblas && \
29+
apk add geos
30+
31+
COPY --from=startleft-base /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
32+
33+
COPY --from=startleft-base /usr/local/bin/startleft /usr/local/bin/startleft
2234

2335
CMD ["startleft", "server", "--host", "0.0.0.0"]

docs/Quickstart-Guide-for-Beginners.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ some commands, set up the REST API and, in summary, familiarize yourself with th
55
## Prerequisites
66

77
---
8-
* Install the **[latest version of Python](https://www.python.org/downloads/)**.
8+
* Install a **[Python version between 3.8 and 3.11](https://www.python.org/downloads/)**.
99
* Install **[pip3](https://pip.pypa.io/en/stable/installation/)**.
1010
* Install **[git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).**
1111
* Install **[graphviz and graphviz-dev](https://pygraphviz.github.io/documentation/stable/install.html#ubuntu-and-debian).**

docs/integration/Quickstart-Guide-for-Integrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ git checkout release/1.5.0
5959

6060
Now, we can create the StartLeft image:
6161
```shell
62-
docker build . -f deployment/Dockerfile.docs.application.application -t startleft
62+
docker build . -f deployment/Dockerfile.application -t startleft
6363
```
6464

6565
And, finally, we can run the docker container for the image we have just generated. Notice that you can select the

docs/startleft-processors/diagram/Lucidchart-support.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ About the parsing logic:
2828
* Dataflows are calculated based on their position, what means that they do not necessarily need to _touch_ origin
2929
or target shapes, but they have some tolerance.
3030

31+
## Catch All Configuration
32+
This processor includes an exclusive functionality to activate the mapping for all the shapes not included in the components' mapper section.
33+
All the unknown shapes will be mapped to the type defined under the `catch_all` property
34+
```yaml
35+
configuration:
36+
catch_all: empty-component
37+
```
38+
39+
#### Skip
40+
This configuration defines a list of resources that will never be mapped.
41+
```yaml
42+
configuration:
43+
skip:
44+
- AmazonCloudWatch
45+
- AmazonDynamoDB
46+
- AmazonRoute53
47+
- DataSharesAzure2021
48+
```
49+
3150
## An example
3251
3352
In this example, we can see a Lucidchart diagram which includes different types of elements.
@@ -68,8 +87,6 @@ Then, we can map the generic shapes by name in a custom mapping file:
6887
6988
- label: Android
7089
type: android-device-client
71-
72-
dataflows: []
7390
```
7491

7592
The expected result for this case should be an OTM like this:
@@ -254,7 +271,7 @@ curl --location --request POST localhost:5000/api/v1/startleft/diagram \
254271
### Command line usage
255272
You can also use the Command Line option for this example, with the files downloaded in the previous section.
256273

257-
Make sure StartLeft is [properly installed](../../../Quickstart-Guide-for-Beginners/#install-startleft)
274+
Make sure StartLeft is [properly installed](../../Quickstart-Guide-for-Beginners.md#install-startleft)
258275
and execute the following command:
259276

260277
```shell

docs/startleft-processors/diagram/Visio-Mapping.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ arrays for the mappings of each type of element:
5555
```yaml
5656
trustzones: []
5757
components: []
58-
dataflows: []
58+
configuration: {}
5959
```
6060
61-
Each of these arrays contains the information for mapping shapes into TrustZones, Components or Dataflows, respectively.
61+
Each of these arrays contains the information for mapping shapes into TrustZones, Components, or configure
62+
particular behavior for the processor.
6263
Also note that all three are mandatory and have to be included in each mapping file, even if they only contain an empty array.
6364
6465
### Mapping TrustZones
@@ -353,8 +354,7 @@ The resulting OTM will be as follows:
353354
More info in the <a href="https://learn.microsoft.com/en-us/openspecs/sharepoint_protocols/ms-vsdx/e58f5f25-76d8-4f65-ae24-d286b10168d7" target="_blank">official Microsoft documentation</a>.
354355

355356
### Mapping DataFlows
356-
Despite the fact that a `dataflows` tag is already defined in the mapping file structure, and it is required by the schema,
357-
the DataFlows mapping process is fixed and not configurable. Basically, it takes all the arrows in the Visio source that connect
357+
The DataFlows mapping process is fixed and not configurable. Basically, it takes all the arrows in the Visio source that connect
358358
components that are mapped and create a DataFlow for them. If some arrow connects shapes that are not mapped, the
359359
DataFlow is not created. This can be easily understood with the following picture:
360360

@@ -388,7 +388,7 @@ All these functionalities are available to map both, components and TrustZones.
388388

389389
This configuration sets all the shapes of name/type `AmazonS3` or `AmazonSimpleStorageServiceS3` to components of type `s3`
390390

391-
#### Mapping by a Regex
391+
### Mapping by a Regex
392392

393393
```yaml
394394
- label: {$regex: ^AWS Region:.*$}

docs/startleft-processors/diagram/Visio-Quickstart.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ components:
100100

101101
- label: Database
102102
type: rds
103-
104-
dataflows: []
105103
```
106104
107105
On the other hand, for this specific request, you need to provide a **custom mapping file** which contains the
@@ -119,8 +117,6 @@ components:
119117

120118
- label: My Custom VPC
121119
type: empty-component
122-
123-
dataflows: []
124120
```
125121
126122
The result of sending to StartLeft this diagram with these mapping files would be an OTM with all the components we
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# What is Visio Summary?
2+
3+
---
4+
5+
> Visio Summary is a tool available at our Command Line Interface for retrieving useful info from VSDX files.
6+
7+
This tool can retrieve all the shapes' information available (type, name)
8+
and their candidate OTM type by emulating the parse method.
9+
10+
You can find [here](../../usage/Command-Line-Interface.md#summary) a complete explanation of this CLI function.
11+
12+
## Summary Options
13+
This summary tool can be executed with multiple configurations:
14+
15+
16+
### without mapping file
17+
---
18+
!!! note ""
19+
20+
The summary retrieves all the availables shapes in the VSDX files without their candidate OTM type.
21+
22+
=== "CLI execution"
23+
```shell
24+
startleft summary \
25+
--diagram-type VISIO \
26+
examples/visio/aws-with-tz-and-vpc.vsdx
27+
```
28+
29+
### by `file path`
30+
---
31+
!!! note ""
32+
33+
The summary is executed against a unique Visio file.
34+
35+
=== "CLI execution"
36+
```shell
37+
startleft summary \
38+
--diagram-type VISIO \
39+
--default-mapping-file examples/visio/iriusrisk-visio-aws-mapping.yaml \
40+
examples/visio/aws-with-tz-and-vpc.vsdx
41+
```
42+
43+
### by `multiple file path`
44+
---
45+
!!! note ""
46+
47+
The summary is executed against multiple Visio files.
48+
49+
=== "CLI execution"
50+
```shell
51+
startleft summary \
52+
--diagram-type VISIO \
53+
--default-mapping-file examples/visio/iriusrisk-visio-aws-mapping.yaml \
54+
examples/visio/aws-with-tz-and-vpc.vsdx examples/visio/visio-basic-example.vsdx
55+
```
56+
57+
### by `folder path`
58+
---
59+
!!! note ""
60+
61+
The summary is executed against a folder path that contains `.vsdx` in it.
62+
63+
=== "CLI execution"
64+
```shell
65+
startleft summary \
66+
--diagram-type VISIO \
67+
--default-mapping-file examples/visio/iriusrisk-visio-aws-mapping.yaml \
68+
examples/visio/
69+
```
70+
71+
### by `multiple folder path`
72+
---
73+
!!! note ""
74+
75+
The summary is executed against multiple folder path that contains `.vsdx` in it.
76+
77+
=== "CLI execution"
78+
```shell
79+
startleft summary \
80+
--diagram-type VISIO \
81+
--default-mapping-file examples/visio/iriusrisk-visio-aws-mapping.yaml \
82+
examples/visio/folder1 examples/visio/folder2
83+
```
84+
85+
## Summary Output Example
86+
87+
```
88+
| SOURCE | SOURCE_ELEMENT_TYPE | SOURCE_ELEMENT_NAME | OTM_MAPPED_TYPE |
89+
|-------------|---------------------|-----------------------|-----------------|
90+
| file_1.vsdx | | Public Cloud | |
91+
| file_1.vsdx | | Custom VPC | |
92+
| file_1.vsdx | | Private Secured Cloud | |
93+
| file_1.vsdx | Amazon CloudWatch | Amazon CloudWatch | cloudwatch |
94+
| file_1.vsdx | Amazon CloudWatch | Custom log system | cloudwatch |
95+
| file_1.vsdx | Amazon EC2 | Amazon EC2 | ec2 |
96+
| file_1.vsdx | Amazon EC2 | Custom machine | ec2 |
97+
| file_1.vsdx | Database | Private Database | rds |
98+
| file_2.vsdx | | Private Secured Cloud | |
99+
| file_2.vsdx | | Public Cloud | |
100+
| file_2.vsdx | | My Custom VPC | |
101+
| file_2.vsdx | | My Custom Machine | |
102+
| file_2.vsdx | Amazon EC2 | My EC2 | ec2 |
103+
| file_2.vsdx | Database | Private Database | rds |
104+
```

docs/usage/Command-Line-Interface.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Commands:
3333
parse Parses source files into Open Threat Model
3434
search Searches source files for the given query
3535
server Launches the REST server to generate OTMs from requests
36+
summary Generates a summary CSV file of the given source files
3637
validate Validates a mapping or OTM file
3738

3839
```
@@ -89,6 +90,7 @@ The list of commands that can be used to work in CLI mode is detailed as follows
8990
| validate | Validates a mapping or OTM file. |
9091
| search | Searches source files for the given query. |
9192
| server | Launches the REST server to generate OTMs from requests. |
93+
| summary | Generate a summary CSV file. |
9294

9395

9496

@@ -777,4 +779,64 @@ receive one or more IaC files, process them and give back the OTM file in the re
777779
INFO on - Waiting for application startup.
778780
INFO on - Application startup complete.
779781
INFO server - Uvicorn running on http://127.0.0.1:5000 (Press CTRL+C to quit)
780-
```
782+
```
783+
784+
### Summary
785+
786+
This command **(only available for VISIO/LUCID)** returns a summary CSV which contains
787+
all the source elements available and their candidate OTM type by emulating the parse method.
788+
789+
The CSV contains the following info:
790+
791+
- SOURCE: The source file name
792+
- SOURCE_ELEMENT_TYPE: The type of the element in the source
793+
- SOURCE_ELEMENT_NAME: The name of the element in the source
794+
- OTM_MAPPED_TYPE: The type of the element in the OTM
795+
796+
```shell
797+
Usage: startleft summary [OPTIONS] [SOURCE_FILES]...
798+
799+
Generates a summary CSV file of the given source files
800+
801+
Options:
802+
-g, --diagram-type [VISIO|LUCID]
803+
The diagram file type. [required]
804+
-d, --default-mapping-file TEXT
805+
Default mapping file to parse the diagram
806+
file.
807+
-c, --custom-mapping-file TEXT Custom mapping file to parse the diagram
808+
file.
809+
-o, --output-file TEXT Summary output file.
810+
--help Show this message and exit.
811+
```
812+
813+
??? example "`Lucid` example"
814+
815+
=== "CLI execution"
816+
```shell
817+
startleft summary \
818+
--diagram-type LUCID \
819+
--default-mapping-file examples/lucidchart/iriusrisk-lucid-aws-mapping.yaml \
820+
examples/lucidchart/lucid-aws-with-tz-and-vpc.vsdx
821+
```
822+
823+
=== "summary.csv"
824+
```csv
825+
| SOURCE | SOURCE_ELEMENT_TYPE | SOURCE_ELEMENT_NAME | OTM_MAPPED_TYPE |
826+
|--------------------------------|------------------------------|--------------------------------|---------------------------|
827+
| lucid-aws-with-tz-and-vpc.vsdx | AWSCloud | Public Cloud | empty-component |
828+
| lucid-aws-with-tz-and-vpc.vsdx | AWSCloudTrail | My CloudTrail | cloudtrail |
829+
| lucid-aws-with-tz-and-vpc.vsdx | AmazonAPIGateway_purple | My API Gateway | api-gateway |
830+
| lucid-aws-with-tz-and-vpc.vsdx | AmazonCloudWatch | My CloudWatch | cloudwatch |
831+
| lucid-aws-with-tz-and-vpc.vsdx | AmazonEC2 | My EC2 | ec2 |
832+
| lucid-aws-with-tz-and-vpc.vsdx | AmazonSimpleStorageServiceS3 | My Simple Storage Service (S3) | s3 |
833+
| lucid-aws-with-tz-and-vpc.vsdx | Client | Web browser | generic-client |
834+
| lucid-aws-with-tz-and-vpc.vsdx | DatabaseBlock | My DynamoDB | other-database |
835+
| lucid-aws-with-tz-and-vpc.vsdx | DefaultSquareBlock | Custom VPC | empty-component |
836+
| lucid-aws-with-tz-and-vpc.vsdx | DefaultSquareBlock | Internet | empty-component |
837+
| lucid-aws-with-tz-and-vpc.vsdx | Mobileclient | Android | |
838+
| lucid-aws-with-tz-and-vpc.vsdx | RectangleBlock | Private Secured Cloud | |
839+
| lucid-aws-with-tz-and-vpc.vsdx | SQLDatabaseAzure2021 | SQL Database | CD-MICROSOFT-AZURE-SQL-DB |
840+
```
841+
842+

0 commit comments

Comments
 (0)