Skip to content

Commit

Permalink
Merge pull request #5735 from NikCharlebois/Fixes-Graph-Endpoints
Browse files Browse the repository at this point in the history
Added checks for hardcoded Graph URL
  • Loading branch information
NikCharlebois authored Feb 7, 2025
2 parents c39a6db + aa0a817 commit c2d9ad4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/Validation Checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Validation Checks
on: [push, pull_request]

jobs:
# This workflow contains a single job called "build"
UnitTests:
# The type of runner that the job will run on
runs-on: windows-latest

permissions: write-all

# Only when run from the main repo
if: github.repository == 'microsoft/Microsoft365DSC'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Repository
uses: actions/checkout@v3

- name: Ensure No Hardcoded Graph Endpoints
shell: pwsh
run: |
$resources = Get-ChildItem './Modules/Microsoft365DSC/DSCResources/*.psm1' -Recurse
foreach ($resource in $resources)
{
$content = Get-Content $resource.FullName -Raw
$foundPosition = $content.IndexOf('https://graph.microsoft.com', 0)
if ($foundPosition -ge 0)
{
throw "Resource {$($Resource.Name)} contains hardcoded Graph references."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function Get-TargetResource
$Id = $getId.Id
}

$uri = 'https://graph.microsoft.com/v1.0/identityGovernance/privilegedAccess/group/eligibilitySchedules/' + $Id
$uri = "$((Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl)v1.0/identityGovernance/privilegedAccess/group/eligibilitySchedules/" + $Id
$getvalue = Invoke-GraphRequest -Uri $uri -Method Get -ErrorAction SilentlyContinue

#endregion
Expand Down

0 comments on commit c2d9ad4

Please sign in to comment.