Skip to content

Commit bc335ff

Browse files
authored
Merge pull request #8 from francesco-racciatti/francesco-revamp-documentation
chore: revamp security-playground
2 parents 64d945f + 93ce14e commit bc335ff

File tree

5 files changed

+185
-73
lines changed

5 files changed

+185
-73
lines changed

Dockerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
FROM python:3.7-buster
1+
FROM python:3.9-slim
22

3-
RUN pip install pipenv==2018.11.26
3+
RUN pip install --upgrade pipenv
44

55
WORKDIR /app
6-
7-
COPY Pipfile /app
8-
COPY Pipfile.lock /app
6+
COPY . .
97
RUN pipenv install --system --deploy
108

11-
COPY app.py /app
12-
139
EXPOSE 8080
1410

15-
CMD ["gunicorn", "-b", ":8080", "--workers", "2", "--threads", "4", "--worker-class", "gthread", "--access-logfile", "-", "--error-logfile", "-", "app:app"]
11+
ENTRYPOINT ["./entrypoint.sh"]

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[[source]]
2-
url = "https://pypi.python.org/simple"
2+
url = "https://pypi.org/simple"
33
verify_ssl = true
44
name = "pypi"
55

@@ -10,4 +10,4 @@ gunicorn = "*"
1010
[dev-packages]
1111

1212
[requires]
13-
python_version = "3.7"
13+
python_version = "3.9"

Pipfile.lock

Lines changed: 123 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,89 @@
22

33
![last commit](https://flat.badgen.net/github/last-commit/sysdiglabs/security-playground?icon=github) ![licence](https://flat.badgen.net/github/license/sysdiglabs/security-playground) ![docker pulls](https://flat.badgen.net/docker/pulls/sysdiglabs/security-playground?icon=docker)
44

5-
The security playground is a HTTP web server to simulate security breaches in
6-
run time.
5+
The security playground is an HTTP web server to simulate security breaches. It allows you to read, write, and execute commands in a containerized environment.
6+
7+
8+
## Build
9+
10+
```
11+
$ docker build -t sysdiglabs/security-playground:latest .
12+
```
13+
714

815
## Installation
916

10-
Use the docker image to deploy it in your Kubernetes cluster or locally in a
11-
container.
17+
Deploy the docker image in your environment, and setup the probe health check to the `/health:8080` endpoint if required.
18+
19+
You can also run the image locally:
1220

1321
```bash
1422
$ docker run --rm -p 8080:8080 sysdiglabs/security-playground
1523
```
1624

25+
1726
## Usage
1827

19-
The HTTP API exposes tree endpoints to interact with the system.
28+
The application provides endpoints for:
29+
- [Health checks](#health-checks)
30+
- [Reading file](#reading-a-file)
31+
- [Writing file](#writing-a-file)
32+
- [Executing commands](#executing-a-command)
33+
34+
35+
### Health checks
36+
37+
The health check endpoint is `/health` on port `8080` and returns the `200` HTTP status code.
38+
2039

2140
### Reading a file
2241

23-
You can read a file using just the URL.
42+
You can retrieve a file's contents by sending a `GET` request to the application's URL.
43+
44+
```bash
45+
$ curl <URL>:8080/<PATH>
46+
```
47+
48+
For example:
2449

2550
```bash
2651
$ curl localhost:8080/etc/shadow
2752
```
2853

29-
This will return the content of the /etc/shadow file.
54+
This will return the content of the `/etc/shadow` file in the container running locally.
55+
56+
3057

3158
### Writing a file
3259

33-
You can write to a file using the URL and POSTing the content.
60+
You can write data to a file by sending a `POST` request to the application's URL with the desired content.
61+
62+
```bash
63+
$ curl -X POST <URL>:8080/<PATH> -d 'content=<CONTENT>'
64+
```
65+
66+
For example:
3467

3568
```bash
3669
$ curl -X POST localhost:8080/bin/hello -d 'content=hello-world'
3770
```
3871

39-
This will write to /bin/hello the hello-world string
72+
This command writes the string hello-world to /bin/hello.
73+
74+
4075

4176
### Executing a command
4277

43-
You can execute a command using the /exec endpoint and POSTing the command.
78+
To execute a command, send a `POST` request to the `/exec` endpoint with the command as the payload.
79+
80+
```bash
81+
$ curl -X POST <URL>:8080/exec -d 'command=<CMD>'
82+
```
83+
84+
For example:
4485

4586
```bash
46-
$ curl -X POST /exec -d 'command=ls -la'
87+
$ curl -X POST localhost:8080/exec -d 'command=ls'
4788
```
4889

49-
This will capture and return the STDOUT of the command executed.
90+
This will run the command and return its STDOUT output.

entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
gunicorn -b :8080 --workers 2 --threads 4 --worker-class gthread --access-logfile - --error-logfile - app:app

0 commit comments

Comments
 (0)