Skip to content

Commit 7c42b45

Browse files
committed
feat(envbuilder.go): document build secrets
1 parent 2ebca75 commit 7c42b45

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

docs/build-secrets.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ docker run -it --rm \
3131
-e ENVBUILDER_BUILD_SECRET_BAR='envbuilder-test-secret-bar' \
3232
-e ENVBUILDER_INIT_SCRIPT='/bin/sh' \
3333
-e ENVBUILDER_CACHE_REPO=$(docker inspect envbuilder-registry | jq -r '.[].NetworkSettings.IPAddress'):5000/test-container \
34-
-e ENVBUILDER_PUSH_IMAGE=0 \
34+
-e ENVBUILDER_PUSH_IMAGE=1 \
3535
-v $PWD:/workspaces/empty \
3636
ghcr.io/coder/envbuilder:latest
3737
```
@@ -41,8 +41,33 @@ You can now verify two things:
4141
* The secrets provided to build are not available once the container is running. They are no longer on disk, nor are they in the process environment, or in `/proc/self/environ`.
4242
* The secrets were still useful during the build:
4343
```bash
44-
cat /foo_secret.txt
45-
cat /bar_secret.txt
44+
cat /foo_secret_hash.txt
45+
cat /bar_secret_hash.txt
46+
```
47+
48+
### Verifying that images are secret free
49+
To verify that the build image doesn't contain build secrets, run the following:
50+
51+
```bash
52+
docker pull localhost:5000/test-container:latest
53+
docker save -o test-container.tar localhost:5000/test-container
54+
mkdir -p test-container
55+
tar -xf test-container.tar -C test-container/
56+
cd test-container
57+
# Scan image layers for secrets:
58+
find . -type f | xargs tar -xOf 2>/dev/null | strings | grep -rin "envbuilder-test-secret"
59+
# Scan image manifests for secrets:
60+
find . -type f | xargs -n1 grep -rinI 'envbuilder-test-secret'
61+
cd ../
62+
```
63+
64+
The output of both find/grep commands should be empty.
65+
To verify that it scans correctly, replace "envbuilder-test-secret" with "envbuilder" and rerun the commands.
66+
67+
Having verified that no secrets were included in the image, we can now delete the artifacts that we saved to disk.
68+
```bash
69+
rm -r test-container
70+
rm -r test-container.tar
4671
```
4772

4873
## Security and Production Use

0 commit comments

Comments
 (0)