Skip to content

Commit 5be2286

Browse files
Merge pull request #25052 from microsoftgraph/update-permissions-reference-update-script
Update permissions reference update script
2 parents dfea6e5 + 5fb262a commit 5be2286

File tree

6 files changed

+144
-13
lines changed

6 files changed

+144
-13
lines changed

.gdn/.gdnbaselines

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"hydrated": true,
3+
"properties": {
4+
"helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/baselines",
5+
"hydrationStatus": "This file does not contain identifying data. It is safe to check into your repo. To hydrate this file with identifying data, run `guardian hydrate --help` and follow the guidance."
6+
},
7+
"version": "1.0.0",
8+
"baselines": {
9+
"default": {
10+
"name": "default",
11+
"createdDate": "2024-08-26 12:06:54Z",
12+
"lastUpdatedDate": "2024-08-26 12:06:54Z"
13+
}
14+
},
15+
"results": {
16+
"b3d46ea406a66acd0fa8b1130ec9be5b501ad4a933d98ce70193c68771b6e7be": {
17+
"signature": "b3d46ea406a66acd0fa8b1130ec9be5b501ad4a933d98ce70193c68771b6e7be",
18+
"alternativeSignatures": [
19+
"79e125fb7927450b0ebb02d6b3ddb03d7a6a971e21dfdc1c246ba8fd39f0969e"
20+
],
21+
"target": "update-permissions-reference.ps1",
22+
"line": 170,
23+
"memberOf": [
24+
"default"
25+
],
26+
"tool": "psscriptanalyzer",
27+
"ruleId": "PSAvoidUsingConvertToSecureStringWithPlainText",
28+
"createdDate": "2024-08-26 12:06:54Z"
29+
}
30+
}
31+
}

.gdn/.gdnsuppress

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"hydrated": true,
3+
"properties": {
4+
"helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions",
5+
"hydrationStatus": "This file does not contain identifying data. It is safe to check into your repo. To hydrate this file with identifying data, run `guardian hydrate --help` and follow the guidance."
6+
},
7+
"version": "1.0.0",
8+
"suppressionSets": {
9+
"default": {
10+
"name": "default",
11+
"createdDate": "2024-08-26 12:06:54Z",
12+
"lastUpdatedDate": "2024-08-26 12:06:54Z"
13+
}
14+
},
15+
"results": {
16+
"b3d46ea406a66acd0fa8b1130ec9be5b501ad4a933d98ce70193c68771b6e7be": {
17+
"signature": "b3d46ea406a66acd0fa8b1130ec9be5b501ad4a933d98ce70193c68771b6e7be",
18+
"alternativeSignatures": [
19+
"79e125fb7927450b0ebb02d6b3ddb03d7a6a971e21dfdc1c246ba8fd39f0969e"
20+
],
21+
"target": "update-permissions-reference.ps1",
22+
"line": 170,
23+
"memberOf": [
24+
"default"
25+
],
26+
"tool": "psscriptanalyzer",
27+
"ruleId": "PSAvoidUsingConvertToSecureStringWithPlainText",
28+
"createdDate": "2024-08-26 12:06:54Z"
29+
}
30+
}
31+
}

.github/workflows/permissions-reference-gen.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
path: docs
2525

26-
- name: Run PowerShell script
26+
- name: Run PowerShell script to update permissions
2727
shell: pwsh
2828
run: |
2929
$ClientId = "${{ secrets.GRAPH_CLIENT_ID }}"
@@ -38,22 +38,46 @@ jobs:
3838
application-id: ${{ secrets.APPLICATION_ID }}
3939
application-private-key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
4040

41-
- name: Commit updates and open a pull request
41+
- name: Commit updates from service principal
4242
working-directory: ./docs
4343
shell: pwsh
4444
env:
45-
GH_TOKEN: ${{ steps.get_token.outputs.app-token }}
45+
GH_TOKEN: ${{ steps.get_token.outputs.app-token }}
4646
run: |
4747
$status = git status --porcelain
4848
if ($status -eq $null) {
4949
Write-Host "No changes to commit." -ForegroundColor Green
50-
} else {
51-
$timestamp = Get-Date -Format FileDateTimeUniversal
50+
}
51+
else {
5252
git config user.email "GraphTooling@service.microsoft.com"
5353
git config user.name "Microsoft Graph DevX Tooling"
54-
git checkout -b permissions-reference/$timestamp
5554
git add .
5655
git commit -m "Update permissions reference"
57-
git push --set-upstream origin permissions-reference/$timestamp
58-
gh pr create --base main --title "Automated permissons reference update" --body "Scheduled permissions reference update" --reviewer "FaithOmbongi","msewaweru" --label "ready for content review"
56+
}
57+
58+
- name: Run PowerShell script to correct errors in permissions descriptions
59+
shell: pwsh
60+
run: |
61+
./docs/correct-permissions-reference-errors.ps1
62+
63+
- name: Commit errors correction and open a pull request
64+
working-directory: ./docs
65+
shell: pwsh
66+
env:
67+
GH_TOKEN: ${{ steps.get_token.outputs.app-token }}
68+
run: |
69+
$status = git status --porcelain
70+
if ($status -eq $null) {
71+
Write-Host "No changes to commit." -ForegroundColor Green
72+
} else {
73+
$dateToday = Get-Date -Format 'yyyy-MM-dd'
74+
$branchName = "permissions-reference/$dateToday"
75+
$prTitle = "${dateToday}: Automated permissions reference update"
76+
77+
git add .
78+
git commit -m "Correct errors in permissions reference"
79+
git checkout -b $branchName
80+
git push --set-upstream origin $branchName
81+
82+
gh pr create --base main --title $prTitle --body "Scheduled permissions reference update" --reviewer "FaithOmbongi,msewaweru" --label "ready for content review"
5983
}

apidoctor.validation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ extends:
5050
sdl:
5151
credscan:
5252
suppressionsFile: $(Build.SourcesDirectory)\.azure-pipelines\.config\CredScanSuppressions.json
53+
baseline:
54+
baselineFile: $(Build.SourcesDirectory)\.gdn\.gdnbaselines
55+
suppression:
56+
suppressionFile: $(Build.SourcesDirectory)\.gdn\.gdnsuppress
5357
customBuildTags:
5458
- ES365AIMigrationTooling
5559

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
$docsRepoPath = Join-Path (Get-Location).Path -ChildPath "docs"
2+
3+
$permissionsReferenceFilePath = Join-Path $docsRepoPath -ChildPath "\concepts\permissions-reference.md"
4+
5+
# Define a hash table of typos and their corrections
6+
$corrections = @{
7+
"Precention" = "Prevention"
8+
"oganization's" = "organization's"
9+
"backed up snapshot" = "backed-up snapshot"
10+
"organizatio" = "organization"
11+
"organization\u2019s" = "organization's"
12+
"device\u2019s" = "device's"
13+
"providers\u2019" = "providers'"
14+
"the the signed-in user" = "the signed-in user"
15+
"dimissing" = "dismissing"
16+
"user\u2019s" = "user's"
17+
"users\u2019" = "users'"
18+
"intellgence" = "intelligence"
19+
"polices" = "policies"
20+
"by the you" = "by you"
21+
"mesages" = "messages"
22+
"team\u2019s" = "team's"
23+
"calendars\u0020." = "calendars."
24+
}
25+
26+
# Read the file content
27+
$content = Get-Content -Path $permissionsReferenceFilePath -Raw
28+
29+
# Iterate through the corrections and replace typos
30+
foreach ($typo in $corrections.Keys) {
31+
$content = $content -replace "\b$typo\b", $corrections[$typo]
32+
}
33+
34+
# Write the corrected content back to the file
35+
Set-Content -Path $permissionsReferenceFilePath -Value $content
36+
37+
Write-Output "Typos corrected and saved in $permissionsReferenceFilePath."

update-permissions-reference.ps1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function Generate-Markdown {
5252
)
5353
$markdown = ""
5454

55-
$markdown += "`n## All permissions`n`n"
55+
$markdown += "## All permissions`n`n"
5656

5757
foreach ($name in ($permissions.Name | Get-Unique)) {
5858
$markdown += "### $name`n`n"
@@ -106,7 +106,7 @@ function Generate-Markdown {
106106
$markdown += "| $($resourceSpecificApplicationPermission.value) | $($resourceSpecificApplicationPermission.id) | $($resourceSpecificApplicationPermission.displayName) | $($resourceSpecificApplicationPermission.description) |`n"
107107
}
108108

109-
$markdown += "---`n"
109+
$markdown += "`n---`n"
110110

111111
return $markdown
112112
}
@@ -134,10 +134,14 @@ function Update-FileContent {
134134
# Split the file content into three parts: before first header index, the new content, and after second header index
135135
$beforeFirstHeader = $fileContents[0..($firstHeaderIndex - 1)]
136136
$afterSecondHeader = $fileContents[$secondHeaderIndex..($fileContents.Count - 1)]
137+
138+
# Update ms.date
139+
$today = Get-Date -Format "MM/dd/yyyy"
140+
$beforeFirstHeader = $beforeFirstHeader -replace '^ms\.date:.*', "ms.date: $today"
137141

138142
# Combine the parts with the new content
139143
$updatedContent = $beforeFirstHeader + $NewContent.Split("`n") + $afterSecondHeader
140-
144+
141145
# Write the updated content back to the file
142146
$updatedContent | Set-Content -Path $FilePath
143147
}
@@ -162,7 +166,7 @@ $authUri = "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token"
162166
$response = Invoke-RestMethod $authUri -Method 'POST' -Headers $headers -Body $body
163167
$response | ConvertTo-Json
164168
$accessToken = $response.access_token
165-
# $secureAccessToken = ConvertTo-SecureString $accessToken -AsPlainText -Force
169+
$secureAccessToken = ConvertTo-SecureString $accessToken -AsPlainText -Force
166170

167171
# Install the Microsoft Graph PowerShell module if not already installed
168172
if (-not (Get-Module -Name Microsoft.Graph -ListAvailable)) {
@@ -171,7 +175,7 @@ if (-not (Get-Module -Name Microsoft.Graph -ListAvailable)) {
171175

172176
# Connect to Microsoft Graph
173177
try {
174-
Connect-MgGraph -Thumbprint $secureAccessToken -NoWelcome
178+
Connect-MgGraph -AccessToken $secureAccessToken -NoWelcome
175179
Write-Host "Connected successfully."
176180
}
177181
catch {

0 commit comments

Comments
 (0)