1- Reproducible builds exercise
2- ============================
3-
4- Reproducing a package ~ 20min
5-
6- Exec inside the container ` docker compose run --rm -ti secure_coding /bin/bash `
7-
8- ``` shell
9- root@7ccad3d01d39:/# cd /local_data/python_package/
10-
11- root@7ccad3d01d39:/local_data/python_package# ls
12- pyproject.toml secure_coding_demo_package
13-
14- root@7ccad3d01d39:/local_data/python_package# python3 -m build
15- ...
16- Successfully built secure_coding_demo_package-0.0.1.tar.gz and secure_coding_demo_package-0.0.1-py3-none-any.whl
17-
18-
19- root@7ccad3d01d39:/local_data/python_package# diffoscope dist/secure_coding_demo_package-0.0.1-py3-none-any.whl /local_data/prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl
20-
21- root@7ccad3d01d39:/local_data/python_package# mkdir /local_data/html
22- root@7ccad3d01d39:/local_data/python_package# diffoscope dist/secure_coding_demo_package-0.0.1-py3-none-any.whl /local_data/prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl --html-dir /local_data/html
23-
24- root@7ccad3d01d39:/local_data/python_package# strip-nondeterminism dist/secure_coding_demo_package-0.0.1-py3-none-any.whl
25- root@7ccad3d01d39:/local_data/python_package# diffoscope dist/secure_coding_demo_package-0.0.1-py3-none-any.whl /local_data/prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl
26- root@7ccad3d01d39:/local_data/python_package# md5sum dist/secure_coding_demo_package-0.0.1-py3-none-any.whl /local_data/prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl
27-
28- e11a303eef41e70032b4130652e740be dist/secure_coding_demo_package-0.0.1-py3-none-any.whl
29- e11a303eef41e70032b4130652e740be /local_data/prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl
30- ```
31-
32-
33- compare compiled code ~ 5 min
34- ``` shell
35- root@8157f590f783:/# cd /local_data/
36- root@8157f590f783:/local_data# diff hello_world.c malwaretest.c
37- 4c4
38- < printf(" Hello world\n" );
39- ---
40- > printf(" malwaretest\n" );
41-
42-
43- gcc hello_world.c -o a.out
44- gcc malwaretest.c -o b.out
45-
46- diffoscope a.out b.out
47-
48- ```
49-
50- CTX Malware exercise ~ 15 min
51-
521
532Vault
543=====
@@ -60,13 +9,8 @@ Vault KV
609
6110``` bash
6211# verify creds
63-
64- docker compose logs vault
65-
66- docker compose exec -ti vault /bin/sh
67-
68-
6912vault status
13+ # vault operator unseal
7014vault login
7115
7216# Store secret
@@ -99,25 +43,11 @@ curl -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" http://
9943```
10044
10145
102-
10346Vault PostgresQL Integration
10447============================
10548
10649~ 20 min
10750
108- Setup DB
109- ``` shell
110- docker compose exec -ti vault /bin/sh
111- apk add postgresql-client
112-
113- / # psql -h postgres -U postgres
114- Password for user postgres: not_so_secure_default_password
115- postgres=# create database secure_data;
116- postgres=# \c secure_data;
117- secure_data=# create table users (name VARCHAR(255));
118- secure_data=# \q
119-
120- ```
12151
12252Configure vault
12353``` shell
@@ -129,8 +59,8 @@ Success! Enabled the database secrets engine at: database/
12959/ # vault write database/config/secure_db \
13060 plugin_name=" postgresql-database-plugin" \
13161 allowed_roles=" secure_coding_role" \
132- connection_url=" postgresql://{{username}}:{{password}}@postgres :5432/secure_data " \
133- username=" postgres " \
62+ connection_url=" postgresql://{{username}}:{{password}}@<YOUR_IP> :5432/secure_db?sslmode=disable " \
63+ username=" vault " \
13464 password=" not_so_secure_default_password"
13565Success! Data written to: database/config/secure_db
13666
@@ -156,3 +86,77 @@ secure_data=> INSERT INTO users VALUES ('ratata');
15686ERROR: permission denied for table users
15787```
15888
89+
90+
91+ Reproducible builds exercise
92+ ============================
93+
94+ Reproducing a package ~ 20min
95+
96+ ``` shell
97+ root@debian12:/secure_coding# cd /secure_coding/local_data/
98+ root@debian12:/secure_coding/local_data# tree
99+ .
100+ ├── hello_world.c
101+ ├── malwaretest.c
102+ ├── prebuild_package
103+ │ └── secure_coding_demo_package-0.0.1-py3-none-any.whl
104+ └── python_package
105+ ├── pyproject.toml
106+ └── secure_coding_demo_package
107+ ├── __init__.py
108+ └── sneaky_package
109+ └── __init__.py
110+
111+ 5 directories, 6 files
112+
113+
114+ root@debian12:/secure_coding/local_data# cd python_package/
115+ root@debian12:/secure_coding/local_data/python_package# python3 -m build
116+ ...
117+ Successfully built secure_coding_demo_package-0.0.1.tar.gz and secure_coding_demo_package-0.0.1-py3-none-any.whl
118+
119+
120+ root@debian12:/secure_coding/local_data/python_package# strip-nondeterminism dist/secure_coding_demo_package-0.0.1-py3-none-any.whl
121+ root@debian12:/secure_coding/local_data/python_package# strip-nondeterminism dist/secure_coding_demo_package-0.0.1-py3-none-any.whl
122+ root@debian12:/secure_coding/local_data/python_package# diffoscope dist/secure_coding_demo_package-0.0.1-py3-none-any.whl ../prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl
123+ root@debian12:/secure_coding/local_data/python_package# md5sum dist/secure_coding_demo_package-0.0.1-py3-none-any.whl ../prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl
124+ 81cab8eab03f8255a8c05bb014c40824 dist/secure_coding_demo_package-0.0.1-py3-none-any.whl
125+ 81cab8eab03f8255a8c05bb014c40824 ../prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl
126+
127+ root@7ccad3d01d39:/secure_coding/python_package# mkdir /secure_coding/html
128+ root@7ccad3d01d39:/secure_coding/python_package# diffoscope dist/secure_coding_demo_package-0.0.1-py3-none-any.whl /secure_coding/prebuild_package/secure_coding_demo_package-0.0.1-py3-none-any.whl --html-dir /local_data/html
129+
130+
131+ ```
132+
133+
134+ compare compiled code ~ 5 min
135+ ``` shell
136+ root@debian12:/secure_coding/local_data# cd /secure_coding/local_data/
137+ root@debian12:/secure_coding/local_data# ls
138+ hello_world.c malwaretest.c prebuild_package python_package
139+ root@debian12:/secure_coding/local_data# cat hello_world.c
140+ root@debian12:/secure_coding/local_data# cat malwaretest.c
141+
142+ root@debian12:/secure_coding/local_data# gcc hello_world.c -o a.out
143+ root@debian12:/secure_coding/local_data# gcc malwaretest.c -o b.out
144+ root@debian12:/secure_coding/local_data# ls
145+ a.out b.out hello_world.c malwaretest.c prebuild_package python_package
146+ root@debian12:/secure_coding/local_data# diffoscope a.out b.out
147+
148+ ```
149+
150+ CTX Malware exercise ~ 15 min
151+ ---
152+
153+
154+ ``` shell
155+ root@debian12:/secure_coding/local_data# mkdir /var/www/html/diffoscope
156+ root@debian12:/secure_coding/local_data# diffoscope a.out wannabe_ransomware --html-dir /var/www/html/diffoscope
157+
158+ root@debian12:/secure_coding# cd /secure_coding/malware/
159+ root@debian12:/secure_coding/malware# ls
160+ b40297af54e3f99b02e105f013265fd8d0a1b1e1f7f0b05bcb5dbdc9125b3bb5.gz ctx-0.1.2.tar.gz
161+ root@debian12:/secure_coding/malware# diffoscope ctx-0.1.2.tar.gz b40297af54e3f99b02e105f013265fd8d0a1b1e1f7f0b05bcb5dbdc9125b3bb5.gz
162+ ```
0 commit comments