Skip to content

Commit 662ff44

Browse files
committed
touchups
1 parent aaa4d73 commit 662ff44

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed
9.31 KB
Loading

docs/pipelines/security/templates.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ms.assetid: 73d26125-e3ab-4e18-9bcd-387fb21d3568
55
ms.date: 09/12/2025
66
ms.topic: conceptual
77
monikerRange: '>= azure-devops-2020'
8+
#customer intent: As an Azure DevOps user, I want to understand how pipeline templates can help increase security, so I can use templates to do security tasks and help prevent malicious code infiltration and execution.
89
---
910

1011
# Templates for security
@@ -79,18 +80,20 @@ YAML pipeline syntax includes several built-in protections. `Extends` templates
7980

8081
### Step targets
8182

82-
You can restrict specified steps to run in a container rather than on the host. Steps in containers can't access the agent's host, so they can't modify agent configuration or leave malicious code for later execution.
83+
You can restrict specified steps to run in a container rather than on the host. Steps in containers can't access the agent host, so they can't modify agent configuration or leave malicious code for later execution.
8384

84-
For example, you can prevent open network access from within a container, so user steps can't retrieve packages from unauthorized sources or upload code and secrets to external locations. The following example pipeline demonstrates running a step on the agent host before running a step inside a container.
85+
For example, you can run user steps in a container to prevent them from accessing the network, so they can't retrieve packages from unauthorized sources or upload code and secrets to external locations.
86+
87+
The following example pipeline runs a step on the agent host that could potentially alter the host network, followed by a step inside a container that limits network access.
8588

8689
```yaml
8790
resources:
8891
containers:
8992
- container: builder
9093
image: mysecurebuildcontainer:latest
9194
steps:
92-
- script: echo This step runs on the agent host, so could use commands to tear down or limit the host network
93-
- script: echo This step runs inside the builder container, which limits network access
95+
- script: echo This step runs on the agent host
96+
- script: echo This step runs inside the builder container
9497
target: builder
9598
```
9699

@@ -130,9 +133,9 @@ extends:
130133

131134
### Agent logging command restrictions
132135

133-
User steps request services by using *logging commands*, which are specially formatted strings printed to standard output. You can restrict the services that logging commands provide for user steps. In `restricted` mode, most agent services such as uploading artifacts and attaching test results are unavailable.
136+
User steps request services by using *logging commands*, which are specially formatted strings printed to standard output. You can restrict the services that logging commands provide for user steps. In `restricted` mode, most agent services such as uploading artifacts and attaching test results are unavailable for logging commands.
134137

135-
In the following example, the `target` property instructs the agent not to allow publishing artifacts, so the artifact publishing task fails.
138+
In the following example, the `target` property instructs the agent to restrict publishing artifacts, so the artifact publishing task fails.
136139

137140
```yaml
138141
- task: PublishBuildArtifacts@1
@@ -144,11 +147,11 @@ In the following example, the `target` property instructs the agent not to allow
144147

145148
#### Variables in logging commands
146149

147-
The `setvariable` command remains permissible in `restricted` mode, so tasks that output user-provided data, such as open issues retrieved via a REST API, might be vulnerable to injection attacks. Malicious user content could set variables that export as environment variables to subsequent tasks and compromise the agent host.
150+
The `setvariable` command remains permissible in `restricted` mode, so tasks that output user-provided data, such as open issues retrieved via a REST API, might be vulnerable to injection attacks. Malicious user content could set variables that export to subsequent tasks as environment variables and could compromise the agent host.
148151

149152
To mitigate this risk, you can explicitly declare the variables that are settable by using the `setvariable` logging command. If you specify an empty list in `settableVariables`, all variable setting is disallowed.
150153

151-
The following example restricts the `settableVariables` to `expectedVar` or a variable prefixed with `ok`. The task fails because it attempts to set a different variable called `BadVar`.
154+
The following example restricts the `settableVariables` to `expectedVar` and any variable prefixed with `ok`. The task fails because it attempts to set a different variable called `BadVar`.
152155

153156
```yaml
154157
- task: PowerShell@2
@@ -268,7 +271,7 @@ You can configure [approvals and checks](../process/approvals.md) for your agent
268271

269272
To enforce the use of a specific template, configure the [required template](../process/approvals.md#required-template) check on the service connection for a resource. This check applies only when the pipeline extends from a template.
270273

271-
When you view the pipeline job, you can monitor the check's status. If the pipeline doesn't extend from the required template, the check fails. The run stops and notifies you of the failed check.
274+
When you view the pipeline job, you can monitor the check's status. If the pipeline doesn't extend from the required template, the check fails.
272275

273276
:::image type="content" source="../process/media/approval-fail.png" alt-text="Screenshot showing a failed approval check.":::
274277

@@ -298,7 +301,7 @@ steps:
298301
- script: echo ${{ parameters.image }}
299302
```
300303

301-
The following example pipeline extends the *params.yml* template and requires it for approval. To demonstrate a pipeline failure, comment out the reference to *params.yml*.
304+
The following example pipeline extends the *params.yml* template and requires it for approval. To demonstrate a pipeline failure, comment out the `extends` reference to *params.yml*.
302305

303306
```yaml
304307
# azure-pipeline.yml

0 commit comments

Comments
 (0)