You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: learn-pr/github/manage-github-actions-enterprise/includes/manage-encrypted-secrets.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
Secrets are encrypted environment variables that store tokens, credentials, and other sensitive information. Your GitHub Actions workflows and actions can use these secrets when needed. Once created, secrets become accessible to workflows and actions that have permission to access the organization, repository, or environment where the secrets are defined.
2
2
3
-
This section explains how to manage encrypted secrets using tools and strategies in GitHub Enterprise Cloud and GitHub Enterprise Server. You'll also learn how to use these secrets within your workflows and actions.
3
+
This section explains how to manage encrypted secrets using tools and strategies in GitHub Enterprise Cloud and GitHub Enterprise Server. You also learn how to use these secrets within your workflows and actions.
4
4
5
5
## Manage encrypted secrets in the enterprise
6
6
7
-
GitHub Actions lets you securely store and use sensitive data—such as API keys, authentication tokens, passwords, and certificates—through **encrypted secrets**. These secrets are securely stored and injected into workflows. This ensures they do not appear in logs or source code.
7
+
GitHub Actions lets you securely store and use sensitive data—such as API keys, authentication tokens, passwords, and certificates—through **encrypted secrets**. These secrets are securely stored and injected into workflows. This design ensures they do not appear in logs or source code.
8
8
9
9
In an enterprise environment, effective secret management is critical. It helps maintain security, meet compliance requirements, and support operational efficiency. GitHub allows you to manage secrets at four levels: **enterprise**, **organization**, **repository**, and **environment**.
10
10
@@ -17,7 +17,7 @@ Understanding the **scope** of secrets is essential for managing them securely i
17
17
|**Enterprise-Level Secrets**| Apply to all repositories in a GitHub Enterprise Cloud organization. | Enterprise owners, security administrators | Share credentials across multiple repositories. |
18
18
|**Organization-Level Secrets**| Apply to all repositories in an organization; optionally limit to selected repositories. | Organization owners, security administrators | Access cloud services and shared databases. |
19
19
|**Repository-Level Secrets**| Apply only to a single repository. | Repository administrators, workflow runners | Secure credentials for deployment in one repository. |
20
-
|**Environment-Level Secrets**| Apply to specific deployment environments within a repository (e.g., `staging`, `production`). | Workflow runners in the specified environment | Separate credentials by deployment environment. |
20
+
|**Environment-Level Secrets**| Apply to specific deployment environments within a repository, such as staging or production. | Workflow runners in the specified environment | Separate credentials by deployment environment. |
21
21
22
22
**Key considerations:**
23
23
@@ -118,7 +118,7 @@ steps:
118
118
**Pass** the secret as an input parameter to the action. This method is commonly used when the action explicitly defines inputs in its `action.yml`.
119
119
120
120
- **Use `env`:**
121
-
**Expose** the secret as an environment variable to the step. This is useful when the command in the step or a script inside the action expects an environment variable.
121
+
**Expose** the secret as an environment variable to the step. This approach is useful when the command in the step or a script inside the action expects an environment variable.
## Configure security hardening for GitHub Actions
150
150
151
-
Security hardening for GitHub Actions plays a role in keeping your software supply chain secure. The following sections will walk you through recommended practices to strengthen the security of the actions you use in your workflows.
151
+
Security hardening for GitHub Actions plays a role in keeping your software supply chain secure. The following sections walk you through recommended practices to strengthen the security of the actions you use in your workflows.
152
152
153
153
### Identify best practices for mitigating script injection attacks
154
154
155
155
Some best practices for mitigating script injection attacks on GitHub actions include:
156
156
157
157
1. *Use javascript actions instead of inline scripts*: Use JavaScript actions that accept context values as arguments instead of embedding those values in inline scripts. This approach reduces the risk of script injection because the context data is not used to generate or execute shell commands directly.
158
158
159
-
In the example below, passing a variable as an input to a JavaScript action helps prevent it from being used in a script injection attack.
159
+
Passing a variable as an input to a JavaScript action helps prevent it from being used in a script injection attack.
160
160
161
161
```yml
162
162
uses: fakeaction/checktitle@v3
163
163
with:
164
164
title: ${{ github.event.pull_request.title }}
165
165
```
166
166
167
-
2. *Use intermediate environment variables in inline scripts*: When using inline scripts, evaluate variables as environment variables before using them in commands. This ensures the values are resolved before the script runs, reducing the risk of script injection.
167
+
2. *Use intermediate environment variables in inline scripts*: When using inline scripts, evaluate variables as environment variables before using them in commands. This approach ensures the values are resolved before the script runs, reducing the risk of script injection.
168
168
For example, using `github.event.pull_request.title` as an environment variable helps protect against injection vulnerabilities:
169
169
170
170
```yml
@@ -187,7 +187,7 @@ For example, using `github.event.pull_request.title` as an environment variable
187
187
3. **Leverage workflow templates to implement code scanning**:
188
188
**Navigate** to the repository’s **Actions** tab and select the **New Workflow** button on the left pane. On the **Choose a workflow** page, **locate** the **Security** section to access and apply workflow templates.
189
189
190
-
**Configure** the CodeQL scanner to run on specific events, enabling it to scan a branch's files and flag exposures (CWEs) in actions used within workflows, including vulnerabilities such as script injection.
190
+
Configure the CodeQL scanner to run on specific events, enabling it to scan a branch's files and flag exposures CWEs(Common Weakness Enumerations) in actions used within workflows, including vulnerabilities such as script injection.
191
191
192
192
:::image type="content" source="../media/manage-encrypted-secrets_newworkflow.png" alt-text="Screenshot showing the creation of a new GitHub Actions workflow for managing encrypted secrets." border="false":::
193
193
@@ -200,7 +200,7 @@ For example, using `github.event.pull_request.title` as an environment variable
200
200
Follow these best practices to safely incorporate third-party actions into your workflows:
201
201
202
202
1. **Pin actions to a tag only if the author is trusted**
203
-
Use version tags (e.g., `@v4`) only when the action's author is verified and trusted. This helps reduce the risk of unexpected changes in future releases.
203
+
Use version tags such as `v1` or `v2`, only when the action's author is verified and trusted. This action helps reduce the risk of unexpected changes in future releases.
204
204
205
205
```yml
206
206
- name: Checkout
@@ -223,7 +223,7 @@ Follow these best practices to safely incorporate third-party actions into your
223
223
Use trusted actions to reduce risk in your workflows.
224
224
225
225
- **Look for the Verified badge:**
226
-
Trustworthy actions appear in the GitHub Marketplace and display a **Verified creator** badge next to the title. This means the creator has been verified by GitHub.
226
+
Trustworthy actions appear in the GitHub Marketplace and display a **Verified creator** badge next to the title informing you that the creator has been verified by GitHub.
227
227
228
228
- **Check documentation:**
229
229
The `action.yml` file should be well documented and clearly describe how the action works.
@@ -283,18 +283,18 @@ Applying the principle of least privilege to the token’s permissions helps red
283
283
284
284
### Managing cross-repository access
285
285
286
-
When workflows require access to multiple repositories, it's important to choose credentials that minimize security risks. Below are the recommended options, listed from most to least preferred.
286
+
When workflows require access to multiple repositories, it's important to choose credentials that minimize security risks. Some of the recommended options listed from most to least preferred include:
287
287
288
288
1. **`GITHUB_TOKEN`**
289
289
290
-
The `GITHUB_TOKEN` is automatically generated by GitHub for each workflow run. It is scoped to the single repository that triggers the workflow and provides permissions equivalent to a write-access user on that repository. The token is created at the start of each job and expires when the job completes.
290
+
GitHub automatically generates the `GITHUB_TOKEN` for each workflow run. It is scoped to the single repository that triggers the workflow and provides permissions equivalent to a write-access user on that repository. The token is created at the start of each job and expires when the job completes.
291
291
292
292
Use the `GITHUB_TOKEN` whenever possible for secure and scoped authentication.
293
293
For details, see [Automatic token authentication](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication).
294
294
295
295
2. **Repository deploy key**
296
296
297
-
Deploy keys provide read or write access to a single repository and can be used within workflows to clone or push using Git.
297
+
To clone or push using Git within workflows, use deploy keys that provide read or write access to a single repository.
298
298
299
299
However, deploy keys do not support access to GitHub's REST or GraphQL APIs. Use them only when API access is not required and Git access is sufficient.
300
300
@@ -315,7 +315,7 @@ Note: This approach is difficult to scale and is best avoided in favor of deploy
315
315
316
316
5. **SSH keys on personal accounts**
317
317
318
-
Never use SSH keys from personal accounts in workflows. Like classic PATs, they grant access to all repositories associated with the account, including personal and organizational repositories. This exposes workflows to unnecessary risk.
318
+
Never use SSH keys from personal accounts in workflows. Like classic PATs, they grant access to all repositories associated with the account, including personal and organizational repositories. This mistake exposes workflows to unnecessary risk.
319
319
320
320
If your use case involves cloning or pushing via Git, consider using deploy keys instead. They provide scoped access without exposing unrelated repositories or requiring personal credentials.
321
321
@@ -333,11 +333,11 @@ Artifact attestations help establish the provenance of builds, improving softwar
333
333
334
334
#### What to attest
335
335
336
-
With GitHub Actions, you can attest to build provenance & SBOM's for binaries and container images.
336
+
With GitHub Actions, you can attest to build provenance & SBOM's (Software Bill of Materials) for binaries and container images.
337
337
338
338
#### Generating artifact attestations for builds
339
339
340
-
When you generate an artifact attestation for builds you must ensure:
340
+
When you generate an artifact attestation for builds, you must ensure:
341
341
342
342
* You have the appropriate permissions configured in the workflow
343
343
* You have included a step in your workflow that uses the [attest-build-provenance](https://github.com/actions/attest-build-provenance) action.
@@ -364,7 +364,7 @@ The attestation establishes build provenance. You can view attestations in the r
364
364
subject-path: 'PATH/TO/ARTIFACT'
365
365
```
366
366
367
-
Note that the value of the `subject-path` parameter should be set to the path to the binary you will attest.
367
+
>Note that the value of the `subject-path` parameter is set to the path of the binary you attest.
368
368
369
369
##### Generating an attestation for the build provenance of container images
370
370
@@ -378,7 +378,7 @@ Note that the value of the `subject-path` parameter should be set to the path to
378
378
packages: write
379
379
```
380
380
381
-
2. Add this step after the container image has been built:
381
+
2. Add this step after you build the container image:
382
382
383
383
```yml
384
384
- name: Generate artifact attestation
@@ -395,11 +395,11 @@ Note that the value of the `subject-path` parameter should be set to the path to
395
395
396
396
#### Generating attestations for SBOMs
397
397
398
-
You have the ability to generate SBOM attestions for an SBOM. To generate and attest to an SBOM you must perform the following:
398
+
You have the ability to generate SBOM attestions for an SBOM. To generate and attest to an SBOM you must carry out the following steps:
399
399
400
-
* Ensure you have set the appropriate permissions in the workflow (see examples below).
401
-
* You must generate an SBOM for the artifact in a step in the workflow. For an example, see anchore-sbom-action in the GitHub Marketplace.
402
-
* Include a step in your workflow that uses the attest-sbom action (see examples below)
400
+
- Ensure you set the appropriate permissions in the workflow, as shown in the examples.
401
+
-You must generate an SBOM for the artifact in a step in the workflow. For an example, see anchore-sbom-action in the GitHub Marketplace.
402
+
-Include a step in your workflow that uses the attest-sbom action (see examples below)
403
403
404
404
##### Generating an SBOM attestation for binaries
405
405
@@ -504,7 +504,7 @@ Many enterprises integrate GitHub Actions with external secret management soluti
0 commit comments