Skip to content

Commit ec6823c

Browse files
authored
Merge pull request circleci#3936 from circleci/secrets
Documenting secrets masking
2 parents 6fcf751 + 29b58f2 commit ec6823c

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

jekyll/_cci2/contexts.md

+11
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ Environment variables are used according to a specific precedence order, as foll
124124

125125
Environment variables declared inside a shell command `run step`, for example `FOO=bar make install`, will override environment variables declared with the `environment` and `contexts` keys. Environment variables added on the Contexts page will take precedence over variables added on the Project Settings page. Finally, special CircleCI environment variables are loaded.
126126

127+
## Secrets Masking
128+
129+
Contexts hold project secrets or keys that perform crucial functions for your applications. For added security CircleCI performs secret masking on the build output, obscuring the `echo` or `print` output of contexts.
130+
131+
The value of the context will not be masked in the build output if:
132+
133+
* the value of the contex is less than 4 characaters
134+
* the value of the context is equal to one of `true`, `True`, `false` or `False`
135+
136+
**Note:** secret masking will only prevent the value of the context from appearing in your build output. The value of the context is still accessible to users [debugging builds with SSH]({{ site.baseurl }}/2.0/ssh-access-jobs).
137+
127138
## See Also
128139

129140
[CircleCI Environment Variable Descriptions]({{ site.baseurl }}/2.0/env-vars/)

jekyll/_cci2/env-vars.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ This document describes using environment variables in CircleCI in the following
1515
## Overview
1616
{:.no_toc}
1717

18-
To add private keys or secret environment variables to your private project, use the Environment Variables page of the Build > Project > Settings in the CircleCI application. The value of the variables are neither readable nor editable in the app after they are set. To change the value of an environment variable, delete the current variable and add it again with the new value. It is possible to add individual variables or to import variables from another project. Private environment variables enable you to store secrets safely even when your project is public, see [Building Open Source Projects]({{ site.baseurl }}/2.0/oss/) for associated settings information. Use Contexts to further restrict access to environment variables from within the build, refer to the [Restricting a Context]({{ site.baseurl }}/2.0/contexts/#restricting-a-context) documentation.
18+
To add private keys or secret environment variables to your private project, use the Environment Variables page of the Build > Project > Settings in the CircleCI application. The value of the variables are neither readable nor editable in the app after they are set. To change the value of an environment variable, delete the current variable and add it again with the new value. It is possible to add individual variables or to import variables from another project. Private environment variables enable you to store secrets safely even when your project is public, see [Building Open Source Projects]({{ site.baseurl }}/2.0/oss/) for associated settings information. Use Contexts to further restrict access to environment variables from within the build, refer to the [Restricting a Context]({{ site.baseurl }}/2.0/contexts/#restricting-a-context) documentation.
19+
20+
### Secrets Masking
21+
{:.no_toc}
22+
23+
Environment variables may hold project secrets or keys that perform crucial functions for your applications. For added security CircleCI performs secret masking on the build output, obscuring the `echo` or `print` output of environment variables and contexts.
24+
25+
The value of the environment variable will not be masked in the build output if:
26+
27+
* the value of the environment variable is less than 4 characaters
28+
* the value of the environment variable is equal to one of `true`, `True`, `false` or `False`
29+
30+
**Note:** secret masking will only prevent the value of the environment variable from appearing in your build output. The value of the environment variable is still accessible to users [debugging builds with SSH]({{ site.baseurl }}/2.0/ssh-access-jobs).
1931

2032
### Environment Variable Usage Options
2133
{:.no_toc}
@@ -66,19 +78,21 @@ jobs: # basic units of work in a run
6678
command: echo ${CIRCLE_BRANCH}
6779
# Run another step, the same as above; note that you can
6880
# invoke environment variable without curly braces.
81+
# prints: XXXXXXX
6982
- run:
7083
name: "What branch am I on now?"
71-
command: echo $CIRCLE_BRANCH
84+
command: echo $CIRCLE_BRANCH # prints: XXXXXXX
7285
- run:
7386
name: "What was my custom environment variable?"
74-
command: echo ${MY_ENV_VAR}
87+
command: echo ${MY_ENV_VAR} # prints: XXXXXXX
7588
```
7689
7790
The above `config.yml` demonstrates the following:
7891

7992
- Setting custom environment variables
8093
- Reading a built-in environment variable that CircleCI provides (`CIRCLE_BRANCH`)
8194
- How variables are used (or interpolated) in your `config.yml`
95+
- Masking of printed environment variables (secrets masking)
8296

8397
When the above config runs, the output looks like this:
8498

@@ -386,3 +400,4 @@ Variable | Type | Value
386400
{:.no_toc}
387401
388402
[Contexts]( {{ site.baseurl }}/2.0/contexts/)
403+
[Keep environment variables private with secret masking](https://circleci.com/blog/keep-environment-variables-private-with-secret-masking/)
Loading

0 commit comments

Comments
 (0)