Skip to content

Commit b39c5f3

Browse files
committed
undo modulebuilder
1 parent 91ec243 commit b39c5f3

File tree

3 files changed

+19
-144
lines changed

3 files changed

+19
-144
lines changed

.github/workflows/dev_api.yml

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -26,67 +26,6 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- name: Setup PowerShell module cache
30-
id: cacher
31-
uses: actions/cache@v3
32-
with:
33-
path: "~/.local/share/powershell/Modules"
34-
key: ${{ runner.os }}-ModuleBuilder
35-
36-
- name: Install ModuleBuilder
37-
if: steps.cacher.outputs.cache-hit != 'true'
38-
shell: pwsh
39-
run: |
40-
Set-PSRepository PSGallery -InstallationPolicy Trusted
41-
Install-Module ModuleBuilder -AllowClobber -Force
42-
43-
- name: Build CIPPCore Module
44-
shell: pwsh
45-
run: |
46-
$ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CIPPCore"
47-
$OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
48-
49-
Write-Host "Building module from: $ModulePath"
50-
Write-Host "Output directory: $OutputPath"
51-
52-
# Generate function permissions before replacing the source module
53-
$ToolsPath = Join-Path $env:GITHUB_WORKSPACE "Tools"
54-
$ScriptPath = Join-Path $ToolsPath "Build-FunctionPermissions.ps1"
55-
pwsh -File $ScriptPath -ModulePath $ModulePath
56-
57-
# Build the module using ModuleBuilder
58-
Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
59-
60-
# Replace the source module with the built module
61-
Remove-Item -Path $ModulePath -Recurse -Force
62-
Copy-Item -Path (Join-Path $OutputPath "CIPPCore") -Destination $ModulePath -Recurse -Force
63-
64-
Write-Host "Module built and replaced successfully"
65-
66-
# Clean up output directory
67-
Remove-Item -Path $OutputPath -Recurse -Force
68-
69-
- name: Build CippExtensions Module
70-
shell: pwsh
71-
run: |
72-
$ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CippExtensions"
73-
$OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
74-
75-
Write-Host "Building module from: $ModulePath"
76-
Write-Host "Output directory: $OutputPath"
77-
78-
# Build the module using ModuleBuilder
79-
Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
80-
81-
# Replace the source module with the built module
82-
Remove-Item -Path $ModulePath -Recurse -Force
83-
Copy-Item -Path (Join-Path $OutputPath "CippExtensions") -Destination $ModulePath -Recurse -Force
84-
85-
Write-Host "Module built and replaced successfully"
86-
87-
# Clean up output directory
88-
Remove-Item -Path $OutputPath -Recurse -Force
89-
9029
- name: Login to Azure
9130
uses: azure/login@v2
9231
with:

Modules/CIPPCore/Public/Authentication/Get-CIPPHttpFunctions.ps1

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,15 @@ function Get-CIPPHttpFunctions {
55
)
66

77
try {
8-
# Load permissions from cache
9-
if (-not $global:CIPPFunctionPermissions) {
10-
$CIPPCoreModule = Get-Module -Name CIPPCore
11-
if ($CIPPCoreModule) {
12-
$PermissionsFileJson = Join-Path $CIPPCoreModule.ModuleBase 'lib' 'data' 'function-permissions.json'
13-
14-
if (Test-Path $PermissionsFileJson) {
15-
try {
16-
$jsonData = Get-Content -Path $PermissionsFileJson -Raw | ConvertFrom-Json -AsHashtable
17-
$global:CIPPFunctionPermissions = [System.Collections.Hashtable]::new([StringComparer]::OrdinalIgnoreCase)
18-
foreach ($key in $jsonData.Keys) {
19-
$global:CIPPFunctionPermissions[$key] = $jsonData[$key]
20-
}
21-
Write-Information "Loaded $($global:CIPPFunctionPermissions.Count) function permissions from JSON cache"
22-
} catch {
23-
Write-Warning "Failed to load function permissions from JSON: $($_.Exception.Message)"
24-
}
25-
}
26-
}
27-
}
28-
298
$Functions = Get-Command -Module CIPPCore | Where-Object { $_.Visibility -eq 'Public' -and $_.Name -match 'Invoke-*' }
309
$Results = foreach ($Function in $Functions) {
31-
$FunctionName = $Function.Name
32-
if ($global:CIPPFunctionPermissions -and $global:CIPPFunctionPermissions.ContainsKey($FunctionName)) {
33-
$PermissionData = $global:CIPPFunctionPermissions[$FunctionName]
34-
$Functionality = $PermissionData['Functionality']
35-
$Role = $PermissionData['Role']
36-
$Description = $PermissionData['Description']
37-
} else {
38-
$Help = Get-Help $Function
39-
$Functionality = $Help.Functionality
40-
$Role = $Help.Role
41-
$Description = $Help.Description
42-
}
43-
44-
if ($Functionality -notmatch 'Entrypoint') { continue }
45-
if ($Role -eq 'Public') { continue }
10+
$Help = Get-Help $Function
11+
if ($Help.Functionality -notmatch 'Entrypoint') { continue }
12+
if ($Help.Role -eq 'Public') { continue }
4613
[PSCustomObject]@{
47-
Function = $FunctionName
48-
Role = $Role
49-
Description = $Description
14+
Function = $Function.Name
15+
Role = $Help.Role
16+
Description = $Help.Description
5017
}
5118
}
5219

Modules/CIPPCore/Public/Entrypoints/Invoke-ListFunctionParameters.ps1

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,6 @@ function Invoke-ListFunctionParameters {
2121
$CommonParameters = @('Verbose', 'Debug', 'ErrorAction', 'WarningAction', 'InformationAction', 'ErrorVariable', 'WarningVariable', 'InformationVariable', 'OutVariable', 'OutBuffer', 'PipelineVariable', 'TenantFilter', 'APIName', 'Headers', 'ProgressAction', 'WhatIf', 'Confirm', 'Headers', 'NoAuthCheck')
2222
$TemporaryBlacklist = 'Get-CIPPAuthentication', 'Invoke-CippWebhookProcessing', 'Invoke-ListFunctionParameters', 'New-CIPPAPIConfig', 'New-CIPPGraphSubscription'
2323
try {
24-
# Load permissions from cache
25-
if (-not $global:CIPPFunctionPermissions) {
26-
$CIPPCoreModule = Get-Module -Name CIPPCore
27-
if ($CIPPCoreModule) {
28-
$PermissionsFileJson = Join-Path $CIPPCoreModule.ModuleBase 'lib' 'data' 'function-permissions.json'
29-
30-
if (Test-Path $PermissionsFileJson) {
31-
try {
32-
$jsonData = Get-Content -Path $PermissionsFileJson -Raw | ConvertFrom-Json -AsHashtable
33-
$global:CIPPFunctionPermissions = [System.Collections.Hashtable]::new([StringComparer]::OrdinalIgnoreCase)
34-
foreach ($key in $jsonData.Keys) {
35-
$global:CIPPFunctionPermissions[$key] = $jsonData[$key]
36-
}
37-
Write-Information "Loaded $($global:CIPPFunctionPermissions.Count) function permissions from JSON cache"
38-
} catch {
39-
Write-Warning "Failed to load function permissions from JSON: $($_.Exception.Message)"
40-
}
41-
}
42-
}
43-
}
44-
4524
if ($Module -eq 'ExchangeOnlineManagement') {
4625
$ExoRequest = @{
4726
AvailableCmdlets = $true
@@ -57,27 +36,17 @@ function Invoke-ListFunctionParameters {
5736
$Functions = Get-Command @CommandQuery | Where-Object { $_.Visibility -eq 'Public' }
5837
}
5938
$Results = foreach ($Function in $Functions) {
60-
if ($Function -In $TemporaryBlacklist) { continue }
61-
$FunctionName = $Function.Name
62-
if ($Module -ne 'ExchangeOnlineManagement' -and $global:CIPPFunctionPermissions -and $global:CIPPFunctionPermissions.ContainsKey($FunctionName)) {
63-
$PermissionData = $global:CIPPFunctionPermissions[$FunctionName]
64-
$Functionality = $PermissionData['Functionality']
65-
$Synopsis = $PermissionData['Description']
66-
} else {
67-
$GetHelp = @{
68-
Name = $Function
69-
}
70-
if ($Module -eq 'ExchangeOnlineManagement') {
71-
$GetHelp.Path = 'ExchangeOnlineHelp'
72-
}
73-
$Help = Get-Help @GetHelp
74-
$Functionality = $Help.Functionality
75-
$Synopsis = $Help.Synopsis
39+
if ($Function -in $TemporaryBlacklist) { continue }
40+
$GetHelp = @{
41+
Name = $Function
42+
}
43+
if ($Module -eq 'ExchangeOnlineManagement') {
44+
$GetHelp.Path = 'ExchangeOnlineHelp'
7645
}
77-
78-
$ParamsHelp = @()
79-
if ($Functionality -in $IgnoreList) { continue }
80-
if ($Functionality -match 'Entrypoint') { continue }
46+
$Help = Get-Help @GetHelp
47+
$ParamsHelp = ($Help | Select-Object -ExpandProperty parameters).parameter | Select-Object name, @{n = 'description'; exp = { $_.description.Text } }
48+
if ($Help.Functionality -in $IgnoreList) { continue }
49+
if ($Help.Functionality -match 'Entrypoint') { continue }
8150
$Parameters = foreach ($Key in $Function.Parameters.Keys) {
8251
if ($CommonParameters -notcontains $Key) {
8352
$Param = $Function.Parameters.$Key
@@ -103,8 +72,8 @@ function Invoke-ListFunctionParameters {
10372
$StatusCode = [HttpStatusCode]::BadRequest
10473
}
10574
return [HttpResponseContext]@{
106-
StatusCode = $StatusCode
107-
Body = @($Results)
108-
}
75+
StatusCode = $StatusCode
76+
Body = @($Results)
77+
}
10978

11079
}

0 commit comments

Comments
 (0)