Skip to content

Commit 2044f1b

Browse files
docs(docker): Describe current state of docker image security plus minor fixes (#836)
* fix(docker image build): Point `changed-files` step to correct scripts dir (and sort list) * Add information about docker security as it not obvious --------- Co-authored-by: MaxymVlasov <[email protected]>
1 parent 7fa8aa5 commit 2044f1b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

.github/workflows/build-image-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ jobs:
4141
uses: tj-actions/changed-files@dcc7a0cba800f454d79fff4b993e8c3555bcc0a8 # v45.0.7
4242
with:
4343
files: |
44-
Dockerfile
4544
.dockerignore
46-
tools/entrypoint.sh
4745
.github/workflows/build-image-test.yaml
48-
tools/*.sh
46+
Dockerfile
47+
tools/entrypoint.sh
48+
tools/install/*.sh
4949
5050
- name: Set IMAGE environment variable
5151
if: steps.changed-files-specific.outputs.any_changed == 'true'

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ If you want to support the development of `pre-commit-terraform` and [many other
7070
* [terragrunt\_providers\_lock](#terragrunt_providers_lock)
7171
* [terragrunt\_validate\_inputs](#terragrunt_validate_inputs)
7272
* [Docker Usage](#docker-usage)
73+
* [About Docker image security](#about-docker-image-security)
7374
* [File Permissions](#file-permissions)
7475
* [Download Terraform modules from private GitHub repositories](#download-terraform-modules-from-private-github-repositories)
7576
* [GitHub Actions](#github-actions)
@@ -129,9 +130,12 @@ docker pull ghcr.io/antonbabenko/pre-commit-terraform:$TAG
129130

130131
All available tags [here](https://github.com/antonbabenko/pre-commit-terraform/pkgs/container/pre-commit-terraform/versions).
131132

133+
Check [About Docker image security](#about-docker-image-security) section to learn more about possible security issues and why you probably want to build and maintain your own image.
134+
135+
132136
**Build from scratch**:
133137

134-
> [!IMPORTANT]
138+
> **IMPORTANT**
135139
> To build image you need to have [`docker buildx`](https://docs.docker.com/build/install-buildx/) enabled as default builder.
136140
> Otherwise - provide `TARGETOS` and `TARGETARCH` as additional `--build-arg`'s to `docker build`.
137141
@@ -226,8 +230,8 @@ curl -L "$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/late
226230

227231
We highly recommend using [WSL/WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) with Ubuntu and following the Ubuntu installation guide. Or use Docker.
228232

229-
> [!IMPORTANT]
230-
> We won't be able to help with issues that can't be reproduced in Linux/Mac.
233+
> **IMPORTANT**
234+
> We won't be able to help with issues that can't be reproduced in Linux/Mac.
231235
> So, try to find a working solution and send PR before open an issue.
232236
233237
Otherwise, you can follow [this gist](https://gist.github.com/etiennejeanneaurevolve/1ed387dc73c5d4cb53ab313049587d09):
@@ -1182,6 +1186,17 @@ Example:
11821186

11831187
## Docker Usage
11841188

1189+
### About Docker image security
1190+
1191+
Pre-built Docker images contain the latest versions of tools available at the time of their build and remain unchanged afterward. Tags should be immutable whenever possible, and it is highly recommended to pin them using hash sums for security and reproducibility.
1192+
1193+
This means that most Docker images will include known CVEs, and the longer an image exists, the more CVEs it may accumulate. This applies even to the latest `vX.Y.Z` tags.
1194+
To address this, you can use the `nightly` tag, which rebuilds nightly with the latest versions of all dependencies and latest `pre-commit-terraform` hooks. However, using mutable tags introduces different security concerns.
1195+
1196+
Note: Currently, we DO NOT test third-party tools or their dependencies for security vulnerabilities, corruption, or injection (including obfuscated content). If you have ideas for introducing image scans or other security improvements, please open an issue or submit a PR. Some ideas are already tracked in [#835](https://github.com/antonbabenko/pre-commit-terraform/issues/835).
1197+
1198+
From a security perspective, the best approach is to manage the Docker image yourself and update its dependencies as needed. This allows you to remove unnecessary dependencies, reducing the number of potential CVEs and improving overall security.
1199+
11851200
### File Permissions
11861201

11871202
A mismatch between the Docker container's user and the local repository file ownership can cause permission issues in the repository where `pre-commit` is run. The container runs as the `root` user by default, and uses a `tools/entrypoint.sh` script to assume a user ID and group ID if specified by the environment variable `USERID`.

0 commit comments

Comments
 (0)