Skip to content

Commit ec92836

Browse files
Merge branch 'main' into chore/removeRedundantPackage
2 parents 8db30d2 + ffb89f7 commit ec92836

131 files changed

Lines changed: 47657 additions & 20308 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.azure-pipelines/command-metadata-refresh.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ extends:
137137
targetType: inline
138138
script: |
139139
. "$(System.DefaultWorkingDirectory)\tools\Versions\BumpModuleVersion.ps1" -BumpV1Module -BumpBetaModule -BumpAuthModule -Debug
140+
- template: .azure-pipelines/common-templates/get-github-app-token.yml@self
140141
- task: Bash@3
141142
displayName: Push version bump changes
142143
env:
@@ -147,7 +148,7 @@ extends:
147148
git status
148149
git add "$(System.DefaultWorkingDirectory)/config/ModuleMetadata.json"
149150
git commit -m 'Bump module versions after metadata generation.'
150-
git push "https://$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git"
151+
git push "https://x-access-token:$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git"
151152
git status
152153
153154
- ${{ if eq(parameters.CreatePullRequest, true) }}:

.azure-pipelines/common-templates/create-pr.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ parameters:
1616
default: ""
1717

1818
steps:
19+
- template: ./get-github-app-token.yml
20+
1921
- task: PowerShell@2
2022
displayName: Create Pull Request for generated build
2123
env:
@@ -31,5 +33,5 @@ steps:
3133
3234
git status
3335
gh auth login
34-
git push "https://$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git"
36+
git push "https://x-access-token:$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git"
3537
gh pr create -t $Title -b $Body -B $BaseBranchName -H $Head

.azure-pipelines/common-templates/download-openapi-docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ steps:
7878
script: dotnet run
7979
workingDirectory: "$(System.DefaultWorkingDirectory)/tools/OpenApiInfoGenerator/OpenApiInfoGenerator"
8080

81+
- template: ./get-github-app-token.yml
82+
8183
- task: Bash@3
8284
displayName: Commit downloaded files
8385
condition: and(succeeded(), ne(variables['ModuleGenerationList'], ''))
@@ -90,7 +92,7 @@ steps:
9092
git add .
9193
git commit -m 'Weekly OpenApiDocs Download.'
9294
git status
93-
git push --set-upstream "https://$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git" $(Branch)
95+
git push --set-upstream "https://x-access-token:$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git" $(Branch)
9496
git status
9597
9698
# References
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
# Fetches the Microsoft Graph DevX GitHub App credentials from Key Vault and mints a short-lived
5+
# installation access token, exposing it to subsequent steps as the secret variable GITHUB_TOKEN.
6+
#
7+
# Include this template immediately before any step that pushes to GitHub or creates a pull
8+
# request. Downstream steps continue to reference $(GITHUB_TOKEN) exactly as before, but the value
9+
# is now a GitHub App installation token instead of a long-lived PAT. Because installation tokens
10+
# expire after ~1 hour, generate the token right before it is used rather than once per job.
11+
12+
parameters:
13+
- name: RepoName
14+
type: string
15+
default: microsoftgraph/msgraph-sdk-powershell
16+
17+
steps:
18+
- task: AzureKeyVault@2
19+
displayName: "Azure Key Vault: Get GitHub App secrets"
20+
inputs:
21+
azureSubscription: "Federated AKV Managed Identity Connection"
22+
KeyVaultName: akv-prod-eastus
23+
SecretsFilter: "microsoft-graph-devx-bot-appid,microsoft-graph-devx-bot-privatekey"
24+
25+
- task: PowerShell@2
26+
displayName: "Generate GitHub App installation token"
27+
env:
28+
GhAppId: $(microsoft-graph-devx-bot-appid)
29+
GhAppKey: $(microsoft-graph-devx-bot-privatekey)
30+
inputs:
31+
pwsh: true
32+
targetType: inline
33+
errorActionPreference: stop
34+
script: |
35+
$token = & "$(System.DefaultWorkingDirectory)/scripts/Generate-Github-Token.ps1" `
36+
-AppClientId $env:GhAppId `
37+
-AppPrivateKeyContents $env:GhAppKey `
38+
-Repository "${{ parameters.RepoName }}"
39+
if ([string]::IsNullOrWhiteSpace($token)) {
40+
throw "Failed to generate GitHub App installation token (empty result)."
41+
}
42+
# Mask the token so it can never surface in pipeline logs, then expose it to later steps.
43+
Write-Host "##vso[task.setsecret]$token"
44+
Write-Host "##vso[task.setvariable variable=GITHUB_TOKEN;issecret=true]$token"
45+
Write-Host "Generated GitHub App installation token and set GITHUB_TOKEN."

.azure-pipelines/common-templates/install-sdk.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@ steps:
55
targetType: 'inline'
66
pwsh: true
77
script: |
8+
# Register the central CFS feed (network-isolation compliance) and install the SDK modules from it.
9+
$token = ConvertTo-SecureString "$env:SYSTEM_ACCESSTOKEN" -AsPlainText -Force
10+
$cred = [System.Management.Automation.PSCredential]::new("azure", $token)
11+
$feedUrl = "https://microsoftgraph.pkgs.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_packaging/PowerShell_V2_Build/nuget/v2"
12+
if (-not (Get-PSRepository -Name PowerShell_V2_Build -ErrorAction SilentlyContinue)) {
13+
Register-PSRepository -Name PowerShell_V2_Build -SourceLocation $feedUrl -InstallationPolicy Trusted -Credential $cred
14+
}
815
try{
916
# Installing Beta module.
10-
Install-Module Microsoft.Graph.Beta -Repository PSGallery -Scope AllUsers -AcceptLicense -SkipPublisherCheck -Force -AllowClobber
17+
Install-Module Microsoft.Graph.Beta -Repository PowerShell_V2_Build -Credential $cred -Scope AllUsers -AcceptLicense -SkipPublisherCheck -Force -AllowClobber
1118
}catch{
1219
echo "Error when installing Beta"
1320
}
1421
try{
1522
# Installing V1 module.
16-
Install-Module Microsoft.Graph -Repository PSGallery -Scope AllUsers -AcceptLicense -SkipPublisherCheck -Force -AllowClobber
23+
Install-Module Microsoft.Graph -Repository PowerShell_V2_Build -Credential $cred -Scope AllUsers -AcceptLicense -SkipPublisherCheck -Force -AllowClobber
1724
}catch{
1825
echo "Error when installing V1"
19-
}
26+
}
27+
env:
28+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

.azure-pipelines/config/credscan/credscan-suppressions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
],
5757
"_justification": "[DeviceManagement.Actions] Examples contain random values recognized as secret"
5858
},
59+
{
60+
"file": [
61+
"src\\DeviceManagement.Administration\\v1.0\\examples\\Update-MgDeviceManagementVirtualEndpointOnPremiseConnectionAdDomainPassword.md"
62+
],
63+
"_justification": "[DeviceManagement.Administration] Examples contain random values recognized as secret"
64+
},
5965
{
6066
"file": [
6167
"src\\Users.Actions\\v1.0\\examples\\Reset-MgUserAuthenticationMethodPassword.md"
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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: WindowsPool
19+
type: string
20+
default: 1es-windows-ps-compute-m
21+
- name: LinuxPool
22+
type: string
23+
default: Azure-Pipelines-1ESPT-ExDShared
24+
25+
variables:
26+
REGISTRY: 'msgraphprodregistry.azurecr.io'
27+
REGISTRY_NAME: 'msgraphprodregistry' # ACR resource name (az acr build uses this, not the FQDN)
28+
IMAGE_NAME: 'public/microsoftgraph/powershell'
29+
30+
# Rebuild weekly so the image regularly picks up patched OS layers. `always: true` forces a run
31+
# even when there are no new commits (the whole point is to refresh the base image).
32+
schedules:
33+
- cron: "0 6 * * 1" # 06:00 UTC every Monday
34+
displayName: Weekly image refresh
35+
branches:
36+
include:
37+
- main
38+
always: true
39+
40+
# Do not build on every push/PR; the release pipeline already handles tag-driven publishes.
41+
trigger: none
42+
pr: none
43+
44+
resources:
45+
repositories:
46+
- repository: 1ESPipelineTemplates
47+
type: git
48+
name: 1ESPipelineTemplates/1ESPipelineTemplates
49+
ref: refs/tags/release
50+
51+
extends:
52+
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
53+
parameters:
54+
# The 1ES template injects an SDL/compliance stage that MUST run on a Windows pool, so the
55+
# template-level pool is Windows. The actual container build overrides to a Linux pool at the
56+
# job level below. (Same pattern as sdk-release.yml.)
57+
pool: ${{ parameters.WindowsPool }}
58+
settings:
59+
networkIsolationPolicy: Permissive
60+
customBuildTags:
61+
- ES365AIMigrationTooling
62+
stages:
63+
- stage: RefreshDockerImage
64+
displayName: 'Refresh docker image'
65+
jobs:
66+
- job: RebuildAndPush
67+
displayName: 'Rebuild and push patched image'
68+
pool:
69+
name: ${{ parameters.LinuxPool }}
70+
image: ubuntu-latest
71+
os: linux
72+
steps:
73+
- checkout: self
74+
75+
# Build server-side with ACR Tasks: no local Docker daemon, no buildx/QEMU, and no
76+
# Docker Hub dependency (which the network-isolated 1ES pool can't reach). ACR pulls the
77+
# base image from MCR and pushes the result back to the registry.
78+
- task: AzureCLI@2
79+
displayName: 'Build and push patched image (ACR Tasks)'
80+
inputs:
81+
azureSubscription: 'ACR Images Push Service Connection'
82+
scriptType: 'bash'
83+
scriptLocation: 'inlineScript'
84+
inlineScript: |
85+
set -euo pipefail
86+
formatted_date=$(date +"%Y%m%d%H%M%S")
87+
echo "Rebuilding $(REGISTRY_NAME) / $(IMAGE_NAME) on a patched base via ACR Tasks"
88+
az acr build \
89+
--registry $(REGISTRY_NAME) \
90+
--image "$(IMAGE_NAME):latest" \
91+
--image "$(IMAGE_NAME):$formatted_date" \
92+
--platform linux/amd64 \
93+
"$(Build.SourcesDirectory)"

.azure-pipelines/generation-templates/generate-command-metadata.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ steps:
1717
script: |
1818
. $(System.DefaultWorkingDirectory)/tools/PostGeneration/AuthModuleMetadata.ps1
1919
20+
- template: ../common-templates/get-github-app-token.yml
21+
2022
- task: Bash@3
2123
displayName: Push command metadata
2224
enabled: true
@@ -28,5 +30,5 @@ steps:
2830
git status
2931
git add "$(System.DefaultWorkingDirectory)/src/Authentication/Authentication/custom/common/MgCommandMetadata.json"
3032
git commit -m 'Add generated MgCommandMetadata.json. [run ci]'
31-
git push "https://$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git"
33+
git push "https://x-access-token:$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git"
3234
git status

.azure-pipelines/generation-templates/generate-helpdocs-template.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.azure-pipelines/weekly-examples-update.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ extends:
8282
targetType: 'filePath'
8383
pwsh: true
8484
filePath: tools\ImportExamples.ps1
85+
- template: .azure-pipelines/common-templates/get-github-app-token.yml@self
8586
- task: PowerShell@2
8687
displayName: Pushing to github
8788
env:
@@ -95,7 +96,7 @@ extends:
9596
git status
9697
git add .
9798
git commit -m "Updating examples"
98-
git push --set-upstream https://$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git $(ComputeBranch.WeeklyExamplesBranch)
99+
git push --set-upstream "https://x-access-token:$(GITHUB_TOKEN)@github.com/microsoftgraph/msgraph-sdk-powershell.git" $(ComputeBranch.WeeklyExamplesBranch)
99100
git status
100101
- template: .azure-pipelines/common-templates/create-pr.yml@self
101102
parameters:

0 commit comments

Comments
 (0)