Skip to content

Commit 65103ef

Browse files
committed
ci: verify MCR images in compile jobs
Run the shared Notation verification steps on both architecture compile agents, preserving verification before compilation while removing the dedicated Azure Pipelines agent and stage transition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0abe4d46-be3e-478e-bb36-a58a255110a0
1 parent b198adc commit 65103ef

3 files changed

Lines changed: 59 additions & 48 deletions

File tree

‎.pipelines/templates/Dacs.Pipeline.Stages.yml‎

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,9 @@ parameters:
3131
default: false
3232

3333
stages:
34-
- stage: VerifyBaseImages
35-
displayName: Verify MCR base image signatures
36-
dependsOn: []
37-
jobs:
38-
- job: VerifyBaseImages
39-
displayName: Verify MCR base image signatures
40-
timeoutInMinutes: 10
41-
steps:
42-
- checkout: self
43-
path: s/dacs
44-
fetchDepth: 1
45-
persistCredentials: false
46-
- task: Notation@0
47-
displayName: Install Notation
48-
inputs:
49-
command: install
50-
version: 1.3.2
51-
- bash: |
52-
set -euo pipefail
53-
54-
readonly trust_store="$(Agent.TempDirectory)/notation-truststore"
55-
references="$(./.github/scripts/list-pinned-mcr-images.sh | paste -sd, -)"
56-
if [[ -z "$references" ]]; then
57-
echo "No pinned MCR base images were found." >&2
58-
exit 1
59-
fi
60-
61-
./.github/scripts/setup-notation-trust-store.sh "$trust_store"
62-
echo "##vso[task.setvariable variable=mcrBaseImages]$references"
63-
displayName: Prepare Microsoft trust policy
64-
workingDirectory: $(Pipeline.Workspace)/s/dacs
65-
- task: Notation@0
66-
displayName: Verify Microsoft supply-chain signatures
67-
inputs:
68-
command: verify
69-
artifactRefs: $(mcrBaseImages)
70-
trustPolicy: $(Pipeline.Workspace)/s/dacs/.github/notation/trustpolicy.json
71-
trustStore: $(Agent.TempDirectory)/notation-truststore
72-
7334
- stage: Build_amd64
7435
displayName: Compile linux/amd64
75-
dependsOn: VerifyBaseImages
36+
dependsOn: []
7637
jobs:
7738
- job: Build_amd64
7839
displayName: Compile linux/amd64
@@ -94,6 +55,7 @@ stages:
9455
fetchDepth: 0
9556
fetchTags: true
9657
persistCredentials: true
58+
- template: /.pipelines/templates/Dacs.VerifyBaseImages.Steps.yml@self
9759
- template: /.pipelines/templates/Dacs.Build.Steps.yml@self
9860
parameters:
9961
architecture: amd64
@@ -103,7 +65,7 @@ stages:
10365

10466
- stage: Build_arm64
10567
displayName: Compile linux/arm64
106-
dependsOn: VerifyBaseImages
68+
dependsOn: []
10769
pool:
10870
name: 1es-dacs-pool-arm64
10971
image: 1es-pt-linux-arm64
@@ -130,6 +92,7 @@ stages:
13092
fetchDepth: 0
13193
fetchTags: true
13294
persistCredentials: true
95+
- template: /.pipelines/templates/Dacs.VerifyBaseImages.Steps.yml@self
13396
- template: /.pipelines/templates/Dacs.Build.Steps.yml@self
13497
parameters:
13598
architecture: arm64
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (c) Microsoft Corporation.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
steps:
16+
- task: Notation@0
17+
displayName: Install Notation
18+
inputs:
19+
command: install
20+
version: 1.3.2
21+
22+
- bash: |
23+
set -euo pipefail
24+
25+
readonly trust_store="$(Agent.TempDirectory)/notation-truststore"
26+
references="$(./.github/scripts/list-pinned-mcr-images.sh | paste -sd, -)"
27+
if [[ -z "$references" ]]; then
28+
echo "No pinned MCR base images were found." >&2
29+
exit 1
30+
fi
31+
32+
./.github/scripts/setup-notation-trust-store.sh "$trust_store"
33+
echo "##vso[task.setvariable variable=mcrBaseImages]$references"
34+
displayName: Prepare Microsoft trust policy
35+
workingDirectory: $(Pipeline.Workspace)/s/dacs
36+
37+
- task: Notation@0
38+
displayName: Verify Microsoft supply-chain signatures
39+
inputs:
40+
command: verify
41+
artifactRefs: $(mcrBaseImages)
42+
trustPolicy: $(Pipeline.Workspace)/s/dacs/.github/notation/trustpolicy.json
43+
trustStore: $(Agent.TempDirectory)/notation-truststore

‎docs/azure-pipeline-build-and-caching.md‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ validation leaves it disabled.
3333
| |
3434
Build_amd64 Build_arm64
3535
| |
36+
Verify MCR base images Verify MCR base images
3637
Build/load native-build image Build/load native-build image
3738
Compile C++ and Go Compile C++ and Go
3839
Build Python wheel Build Python wheel
@@ -193,13 +194,17 @@ digest guarantees that a build uses the reviewed image contents even if the
193194
upstream tag is moved. Dependabot proposes reviewed updates when a newer digest
194195
is available for the configured tag.
195196

196-
Before either architecture build starts, the `VerifyBaseImages` stage discovers
197-
every MCR base image referenced by a Dockerfile and validates its ESRP signature
198-
with the built-in Azure Pipelines `Notation@0` task. The stage downloads the
199-
public Microsoft supply-chain and timestamp roots over HTTPS, verifies their
200-
pinned SHA-256 fingerprints, and applies the same strict trust policy used by
201-
GitHub Actions. An unpinned image, invalid signature, untrusted signer, or
202-
repository missing from the trust policy fails the pipeline.
197+
At the start of each architecture build, the shared
198+
`Dacs.VerifyBaseImages.Steps.yml` template discovers every MCR base image
199+
referenced by a Dockerfile and validates its ESRP signature with the built-in
200+
Azure Pipelines `Notation@0` task. Running verification on the already
201+
allocated compile agents removes the dedicated verification agent and stage
202+
transition while preserving verification before compilation on both
203+
architectures. The template downloads the public Microsoft supply-chain and
204+
timestamp roots over HTTPS, verifies their pinned SHA-256 fingerprints, and
205+
applies the same strict trust policy used by GitHub Actions. An unpinned image,
206+
invalid signature, untrusted signer, or repository missing from the trust
207+
policy fails the corresponding architecture build.
203208

204209
The Go scheduler and controller images compile Go in their own Dockerfiles.
205210

0 commit comments

Comments
 (0)