Repository: xlab-si/iac-scan-runner (language: python)

Issue:
Updating examples
In examples directory, self-contained, standalone examples should be added in order to check whether the tool is properly installed or no. After that, the existing ones might be removed or updated as well.


Discussion / hints:
Would recommend to create "Quickstart" section in readme, where curl commands are used to test the installation. 

Fix patch:
diff --git a/README.md b/README.md
index 9c02867..052f0bb 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
 # IaC Scan Runner
+
 Service that scans your Infrastructure as Code for common vulnerabilities.
 
 [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/xlab-si/iac-scan-runner/Build%20and%20publish?label=ci%2Fcd)](https://github.com/xlab-si/iac-scan-runner/actions)
@@ -6,33 +7,37 @@ Service that scans your Infrastructure as Code for common vulnerabilities.
 [![PyPI](https://img.shields.io/pypi/v/iac-scan-runner)](https://pypi.org/project/iac-scan-runner/)
 [![Test PyPI](https://img.shields.io/badge/test%20pypi-dev%20version-blueviolet)](https://test.pypi.org/project/iac-scan-runner/)
 
-| Aspect            | Information          |
-| ----------------- |:--------------------:|
-| Tool name         | **IaC Scan Runner**  |
-| Docker image      | [xscanner/runner]    |
-| PyPI package      | [iac-scan-runner]    |
-| Documentation     | [docs]               |
-| Contact us        | [xopera@xlab.si]     |
+| Aspect        |     Information     |
+|---------------|:-------------------:|
+| Tool name     | **IaC Scan Runner** |
+| Docker image  |  [xscanner/runner]  |
+| PyPI package  |  [iac-scan-runner]  |
+| Documentation |       [docs]        |
+| Contact us    |  [xopera@xlab.si]   |
 
 ## Table of Contents
-  - [Description](#purpose-and-description)
-  - [Running](#running)
-      - [Run with Docker](#run-with-docker)
-      - [Run from CLI](#run-from-cli)
-      - [Run from source](#run-from-source)
-  - [License](#license)
-  - [Contact](#contact)
-  - [Acknowledgement](#acknowledgement)
+
+- [Description](#purpose-and-description)
+- [Running](#running)
+    - [Run with Docker](#run-with-docker)
+    - [Run from CLI](#run-from-cli)
+    - [Run from source](#run-from-source)
+- [License](#license)
+- [Contact](#contact)
+- [Acknowledgement](#acknowledgement)
 
 ## Purpose and description
-The **IaC Scan Runner** is a REST API service used to scan IaC (Infrastructure as Code) package and perform various 
+
+The **IaC Scan Runner** is a REST API service used to scan IaC (Infrastructure as Code) package and perform various
 code checks in order to find possible vulnerabilities and improvements.
 Explore the [docs] for more info.
 
 ## Running
+
 This section explains how to run the REST API.
 
 ### Run with Docker
+
 You can run the REST API using a public [xscanner/runner] Docker image as follows:
 
 ```console
@@ -52,6 +57,7 @@ $ docker run --name iac-scan-runner -p 8080:80 iac-scan-runner
 ```
 
 ### Run from CLI
+
 To run using the IaC Scan Runner CLI:
 
 ```console
@@ -67,6 +73,7 @@ $ python3 -m venv .venv && . .venv/bin/activate
 ```
 
 ### Run from source
+
 To run locally from source:
 
 ```console
@@ -78,20 +85,104 @@ $ python3 -m venv .venv && . .venv/bin/activate
 (.venv) $ uvicorn src.iac_scan_runner.api:app
 ```
 
+## Usage and examples
+
+This part will show one of the possible deployments and short examples on how to use API calls.
+
+Firstly we will clone the [iac scan runner] repository and run the API.
+
+```console
+$ git clone https://github.com/xlab-si/iac-scan-runner.git
+$ docker compose up
+```
+
+After this is done you can use different API endpoints by calling localhost:8000.
+You can also navigate to localhost:8000/swagger or localhost:8000/redoc and test all the API endpoints there.
+In this example, we will use curl for calling API endpoints.
+
+1. Lets create a project named test.
+
+```console
+curl -X 'POST' \
+  'http://127.0.0.1:8000/project?creator_id=test' \
+  -H 'accept: application/json' \
+  -d ''
+```
+
+2. Now check if project is created by listing all existing projects.
+
+```console
+curl -X 'GET' \
+  'http://127.0.0.1:8000/project' \
+  -H 'accept: application/json'
+```
+
+3. For example, lets say that we only want to check if file has any git leaks want to check for potential security
+   leaks in our terraform files. We need to enable git-leaks and tfsec scans.
+
+```console
+curl -X 'PUT' \
+  'http://127.0.0.1:8000/checks/git-leaks/enable?project_id=df833571-55d0-4396-8d21-a0fa08b44a06' \
+  -H 'accept: application/json'
+```
+
+```console
+curl -X 'PUT' \
+  'http://127.0.0.1:8000/checks/tfsec/enable?project_id=df833571-55d0-4396-8d21-a0fa08b44a06' \
+  -H 'accept: application/json'
+```
+
+4. Now when project is configured, we can simply choose files that we want to scan and zip them. For IaC-Scan-Runner to
+   work files are expected to be a compressed archives (usually zip files). In this case response type will be json
+   , but it is possible to change it to html.
+
+```console
+curl -X 'POST' \
+  'http://127.0.0.1:8000/scan?project_id=df833571-55d0-4396-8d21-a0fa08b44a06&scan_response_type=json' \
+  -H 'accept: application/json' \
+  -H 'Content-Type: multipart/form-data' \
+  -F 'checks=' \
+  -F 'iac=@example.zip;type=application/zip'
+```
+
+Same can be achieved by calling /scan endpoint and define check list.
+
+```console
+curl -X 'POST' \
+  'http://127.0.0.1:8000/scan?scan_response_type=json' \
+  -H 'accept: application/json' \
+  -H 'Content-Type: multipart/form-data' \
+  -F 'checks=tfsec,git-leaks' \
+  -F 'iac=@example.zip;type=application/zip'
+```
+
+That is it.
+
 ## License
+
 This work is licensed under the [Apache License 2.0].
 
 ## Contact
+
 You can contact the xOpera team by sending an email to [xopera@xlab.si].
 
 ## Acknowledgement
-This project has received funding from the European Union’s Horizon 2020 research and innovation programme under Grant 
+
+This project has received funding from the European Union’s Horizon 2020 research and innovation programme under Grant
 Agreement No. 101000162 ([PIACERE]).
 
 [xscanner/runner]: https://hub.docker.com/r/xscanner/runner
+
 [iac-scan-runner]: https://pypi.org/project/iac-scan-runner/
+
 [Documentation]: https://xlab-si.github.io/iac-scanner-docs/02-runner.html
+
 [docs]: https://xlab-si.github.io/iac-scanner-docs/02-runner.html
+
 [xopera@xlab.si]: mailto:xopera@xlab.si
+
 [Apache License 2.0]: https://www.apache.org/licenses/LICENSE-2.0
+
 [PIACERE]: https://www.piacere-project.eu/
+
+[iac scan runner]: https://github.com/xlab-si/iac-scan-runner
\ No newline at end of file
diff --git a/examples/configs_example.py b/examples/configs_example.py
deleted file mode 100644
index 920243b..0000000
--- a/examples/configs_example.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import requests
-import sys
-
-url = "http://127.0.0.1:8000/new_config"
-
-par = {
-    "creatorid": "8357c950-78d3-4a15-94c6-f911116dcd10"
-}
-
-response = requests.post(url, params=par)
-configid = str(response.json())
-print(configid)
-
-
-url = "http://127.0.0.1:8000/set_config_params"
-
-parameters = dict()
-
-parameters["user"]="user"
-
-print(parameters)
-
-par1 = {
-    "configid": configid,
-    "parameters": str(parameters)
-}
-
-response = requests.post(url, params=par1)
-configid = str(response.json())
-print(configid)
-
diff --git a/examples/persistence_example.py b/examples/persistence_example.py
deleted file mode 100644
index 062c084..0000000
--- a/examples/persistence_example.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import requests
-import sys
-
-
-
-print("SHOW ALL RESULTS")
-
-URL = "http://127.0.0.1:8000/results"
-
-uuids = {
-    "uuid": "8357c950-78d3-4a15-94c6-f911116dcd10"
-}
-
-response = requests.get(URL, uuids)
-print(response.json())
-
-scan_result = response.json()
-
-print(scan_result)
-
-uuid="8357c950-78d3-4a15-94c6-f911116dcd10"
-
-print('SHOW SINGLE RESULT')
-
-URL = "http://127.0.0.1:8000/results"
-
-response = requests.get(URL, uuids)
-scan_result = response.json()
-
-print(scan_result)
-
-print('DELETE SINGLE RESULT')
-
-URL = f"http://127.0.0.1:8000/results/{uuid}"
-
-response = requests.delete(URL)
-scan_result = response.json()
-
-print(scan_result)
-
diff --git a/examples/projects_example.py b/examples/projects_example.py
deleted file mode 100644
index a4da32f..0000000
--- a/examples/projects_example.py
+++ /dev/null
@@ -1,63 +0,0 @@
-import requests
-import sys
-
-url = "http://127.0.0.1:8000/new_project"
-
-par = {
-    "creatorid": "penenadpi"
-}
-
-response = requests.post(url, params=par)
-projectid = str(response.json())
-print(projectid)
-
-checkname="tfsec"
-
-url = f"http://127.0.0.1:8000/checks/{checkname}/enable"
-
-par = {
-    "projectid": projectid
-}
-
-response = requests.put(url, params=par)
-print(response.json())
-
-
-
-checkname="tflint"
-
-url = f"http://127.0.0.1:8000/checks/{checkname}/enable"
-
-par = {
-    "projectid": projectid
-}
-
-response = requests.put(url, params=par)
-print(response.json())
-
-
-
-checkname="tfsec"
-
-url = f"http://127.0.0.1:8000/checks/{checkname}/disable"
-
-par = {
-    "projectid": projectid
-}
-
-response = requests.put(url, params=par)
-print(response.json())
-
-par = {
-    "creatorid": "penenadpi"
-}
-
-url = "http://127.0.0.1:8000/projects"
-response = requests.get(url, par)
-print(response.json())
-
-url = "http://127.0.0.1:8000/projects"
-response = requests.get(url)
-print(response.json())
-
-


Test patch:
diff --git a/examples/test_scanner_simple.py b/examples/test_scanner_simple.py
deleted file mode 100644
index 3940bcf..0000000
--- a/examples/test_scanner_simple.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import requests
-import sys
-
-URL = "http://127.0.0.1:8000/scan"
-
-print(sys.argv[0])
-multipart_form_data = {
-    "iac": (sys.argv[1], open(sys.argv[1], "rb")),
-    "checks": (None, sys.argv[2])
-}
-
-par = { 
-    "projectid" : (None, "074c9d59-02f1-4996-b919-a95bf497e9e1") 
-}
-
-response = requests.post(URL, files = multipart_form_data, params=par)
-print(response.json())
-
-scan_result = response.json()
-
-print(scan_result)