Skip to content

Commit 61c8e80

Browse files
gavinbarronCopilot
andcommitted
Remediate S360 ReplaceVulnerableRegistryReference for microsoftgraph/powershell image
The image was published only on v* release tags and built FROM mcr.microsoft.com/powershell (floating latest), so the stored digest went stale between releases and accrued Ubuntu USN / PowerShell CVEs (S360 KPI 527fb616-07aa-8198-6419-50d04ef1c2f3, service Graph DevX). Changes: pin the base to a maintained *-ubuntu-22.04 tag via ARG PS_BASE_TAG (default lts-ubuntu-22.04); add .azure-pipelines/docker-image-refresh.yml, an image-only weekly rebuild (always:true) that republishes a patched digest without running the full release/sign/PSGallery stages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d3f8fec7-b00b-46be-ba39-7e1f3e7f7188
1 parent 7237bcc commit 61c8e80

2 files changed

Lines changed: 106 additions & 1 deletion

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
#
4+
# Scheduled rebuild of the microsoftgraph/powershell container image.
5+
#
6+
# Why this pipeline exists:
7+
# The release pipeline (sdk-release.yml) only builds and pushes this image on `v*` tags, so
8+
# between releases the published digest goes stale and keeps accruing Ubuntu USN / PowerShell
9+
# CVEs. That is the root cause of the two S360 "Replace Vulnerable Registry Reference" items.
10+
# This lightweight pipeline rebuilds the image on a cadence against a patched base and pushes a
11+
# fresh digest to :latest, keeping the registry copy patched without re-running the full release.
12+
#
13+
# Setup (one-time): register this YAML as a new pipeline definition in the
14+
# "Graph Developer Experiences" ADO project, targeting the default branch.
15+
name: $(Date:yyyyMMdd)$(Rev:.r)_docker-image-refresh
16+
17+
parameters:
18+
- name: LinuxPool
19+
type: string
20+
default: Azure-Pipelines-1ESPT-ExDShared
21+
22+
variables:
23+
REGISTRY: 'msgraphprodregistry.azurecr.io'
24+
IMAGE_NAME: 'public/microsoftgraph/powershell'
25+
26+
# Rebuild weekly so the image regularly picks up patched OS layers. `always: true` forces a run
27+
# even when there are no new commits (the whole point is to refresh the base image).
28+
schedules:
29+
- cron: "0 6 * * 1" # 06:00 UTC every Monday
30+
displayName: Weekly image refresh
31+
branches:
32+
include:
33+
- main
34+
always: true
35+
36+
# Do not build on every push/PR; the release pipeline already handles tag-driven publishes.
37+
trigger: none
38+
pr: none
39+
40+
resources:
41+
repositories:
42+
- repository: 1ESPipelineTemplates
43+
type: git
44+
name: 1ESPipelineTemplates/1ESPipelineTemplates
45+
ref: refs/tags/release
46+
47+
extends:
48+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
49+
parameters:
50+
pool:
51+
name: ${{ parameters.LinuxPool }}
52+
image: ubuntu-latest
53+
os: linux
54+
settings:
55+
networkIsolationPolicy: Permissive
56+
customBuildTags:
57+
- ES365AIMigrationTooling
58+
stages:
59+
- stage: RefreshDockerImage
60+
displayName: 'Refresh docker image'
61+
jobs:
62+
- job: RebuildAndPush
63+
displayName: 'Rebuild and push patched image'
64+
pool:
65+
name: ${{ parameters.LinuxPool }}
66+
image: ubuntu-latest
67+
os: linux
68+
steps:
69+
- checkout: self
70+
71+
- task: AzureCLI@2
72+
displayName: 'Log in to Azure Container Registry'
73+
inputs:
74+
azureSubscription: 'ACR Images Push Service Connection'
75+
scriptType: 'bash'
76+
scriptLocation: 'inlineScript'
77+
inlineScript: |
78+
az acr login --name $(REGISTRY)
79+
80+
- script: |
81+
docker run --privileged --rm tonistiigi/binfmt --install all
82+
displayName: 'Enable multi-platform builds'
83+
84+
- script: |
85+
docker buildx create --use --name refreshbuilder
86+
displayName: 'Set up Docker BuildX'
87+
88+
- bash: |
89+
set -euo pipefail
90+
formatted_date=$(date +"%Y%m%d%H%M%S")
91+
echo "Rebuilding $(REGISTRY)/$(IMAGE_NAME) on a patched base"
92+
docker buildx build \
93+
--platform linux/amd64 \
94+
--push \
95+
-t "$(REGISTRY)/$(IMAGE_NAME):latest" \
96+
-t "$(REGISTRY)/$(IMAGE_NAME):$formatted_date" \
97+
"$(Build.SourcesDirectory)"
98+
displayName: 'Build and push refreshed image'

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
FROM mcr.microsoft.com/powershell
1+
# Pin to a maintained Ubuntu 22.04 PowerShell base tag instead of the floating :latest.
2+
# The PowerShell team rebuilds these date-stamped rolling tags with patched OS layers, so a
3+
# scheduled rebuild (see .azure-pipelines/docker-image-refresh.yml) picks up Ubuntu/USN and
4+
# PowerShell CVE fixes and produces a fresh digest, clearing the S360
5+
# "Replace Vulnerable Registry Reference" findings. Override at build time with
6+
# --build-arg PS_BASE_TAG=<tag> (e.g. 7.4-ubuntu-22.04 or lts-ubuntu-22.04).
7+
ARG PS_BASE_TAG=lts-ubuntu-22.04
8+
FROM mcr.microsoft.com/powershell:${PS_BASE_TAG}
29

310
ARG VERSION=latest
411

0 commit comments

Comments
 (0)