Skip to content

Commit 86d2b4f

Browse files
committed
Mention checkout refs in context expression restriction example
Pipelines can use different sources for checkout and for config. When this is the case, both of these need to be restricted for the context to be protected from unreviewed code, or unreviewed config.
1 parent 45a9930 commit 86d2b4f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/guides/modules/security/pages/contexts.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,19 @@ You must be an *organization admin* to remove projects from contexts though the
245245
[#expression-restrictions]
246246
== Expression restrictions
247247

248-
Restrict contexts by setting up _expression restrictions_. Expression restrictions are rules that xref:orchestrate:pipeline-variables.adoc#pipeline-values[pipeline values] must match. Using expression restrictions allows you to create arbitrary constraints on the circumstances in which a context is available for use. For example, you may have a context containing credentials that should only be used for deploying your code from your protected `main` branch:
248+
Restrict contexts by setting up _expression restrictions_. Expression restrictions are rules that xref:orchestrate:pipeline-variables.adoc#pipeline-values[pipeline values] must match. Using expression restrictions allows you to create arbitrary constraints on the circumstances in which a context is available for use. For example, you may have a context containing credentials that should only be used for deploying your code from your protected `main` branch. You also want to make sure that the config is from a protected `main` branch for any triggers that use a different checkout and config source:
249249

250250
[source]
251251
----
252-
pipeline.git.branch == "main" and not job.ssh.enabled and not (pipeline.config_source starts-with "api"")
252+
pipeline.git.branch == "main" and pipeline.config.ref == "refs/heads/main" and not job.ssh.enabled and not (pipeline.config_source starts-with "api"")
253253
----
254254

255255
Tabs and new lines are considered whitespace so can be used to break long lines, but have no other significance. For example, the snippet above could also be written:
256256

257257
[source]
258258
----
259259
pipeline.git.branch == "main"
260+
and pipeline.config.ref == "refs/heads/main"
260261
and not job.ssh.enabled
261262
and not (pipeline.config_source starts-with "api")
262263
----

0 commit comments

Comments
 (0)