-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5105 from daghack/secrets-used-in-args-rule
Lint Rule for catching common secret related env/arg keys
- Loading branch information
Showing
6 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
frontend/dockerfile/docs/rules/secrets-used-in-arg-or-env.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: SecretsUsedInArgOrEnv | ||
description: Sensitive data should not be used in the ARG or ENV commands | ||
aliases: | ||
- /go/dockerfile/rule/secrets-used-in-arg-or-env/ | ||
--- | ||
|
||
## Output | ||
|
||
```text | ||
Potentially sensitive data should not be used in the ARG or ENV commands | ||
``` | ||
|
||
## Description | ||
|
||
While it is common to pass secrets to running processes | ||
through environment variables during local development, | ||
setting secrets in a Dockerfile using `ENV` or `ARG` | ||
is insecure because they persist in the final image. | ||
This rule reports violations where `ENV` and `ARG` keys | ||
indicate that they contain sensitive data. | ||
|
||
Instead of `ARG` or `ENV`, you should use secret mounts, | ||
which expose secrets to your builds in a secure manner, | ||
and do not persist in the final image or its metadata. | ||
See [Build secrets](https://docs.docker.com/build/building/secrets/). | ||
|
||
## Examples | ||
|
||
❌ Bad: `AWS_SECRET_ACCESS_KEY` is a secret value. | ||
|
||
```dockerfile | ||
FROM scratch | ||
ARG AWS_SECRET_ACCESS_KEY | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Output | ||
|
||
```text | ||
Potentially sensitive data should not be used in the ARG or ENV commands | ||
``` | ||
|
||
## Description | ||
|
||
While it is common to pass secrets to running processes | ||
through environment variables during local development, | ||
setting secrets in a Dockerfile using `ENV` or `ARG` | ||
is insecure because they persist in the final image. | ||
This rule reports violations where `ENV` and `ARG` keys | ||
indicate that they contain sensitive data. | ||
|
||
Instead of `ARG` or `ENV`, you should use secret mounts, | ||
which expose secrets to your builds in a secure manner, | ||
and do not persist in the final image or its metadata. | ||
See [Build secrets](https://docs.docker.com/build/building/secrets/). | ||
|
||
## Examples | ||
|
||
❌ Bad: `AWS_SECRET_ACCESS_KEY` is a secret value. | ||
|
||
```dockerfile | ||
FROM scratch | ||
ARG AWS_SECRET_ACCESS_KEY | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters