Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

replace load of PS1 files in psd1 by a main psm1 loading the ps1 #59

Open
MS-LUF opened this issue Nov 16, 2022 · 3 comments
Open

replace load of PS1 files in psd1 by a main psm1 loading the ps1 #59

MS-LUF opened this issue Nov 16, 2022 · 3 comments

Comments

@MS-LUF
Copy link

MS-LUF commented Nov 16, 2022

Hello,

Not sure this title could be understand ^^
My issue : in PWSH constraint language mode, the import of ps1 files in forbidden.

So it's more a feature request than an issue : could you replace the call of autonomous ps1 files in the psd1 by a psm1 submodule that load the ps1 files ?

Thank you,

Kind regards,

Lucas Cueff

@jazuntee
Copy link
Contributor

jazuntee commented Dec 6, 2022

This is only one of several reasons this module will not currently work in constrained language mode. There is significant work required to support that.

@MS-LUF
Copy link
Author

MS-LUF commented Dec 7, 2022

Hello, thanks for your feedback.
From my point of view the work is not so huge because your code signing should cover 90 % of the constraint language mode limitations (forbidden type and so one). So the work is focused mainly on 3 files : the PSD1 to avoid any dot source call, the PSM1 to load all ps1 files as dot sourced files and export all function names based on function names imported. On my side, I have done a quick and dirty fix to test it and it is working well :

  • create a new module with your current psm1 file modified to import all ps1 from msal.ps source directory + your current psm1 code adapted (for path reason mainly) ==> I use also AST to get back dynamically the function names used in each ps1 file to export them automatically using Export-ModuleMember
  • create a new psd1 linked to this module without any dot source prerequisites
  • forked the main ps1 file mainly to fix path issue
  • sign the three files
    ==> all is working fine with PowerShell constraint language mode enabled and several other applocker enforcement.

@jazuntee
Copy link
Contributor

jazuntee commented Jan 9, 2023

Alright, I'll leave this open. I do want to add a step in our publishing pipeline to combine everything into a single .psm1 file it just hasn't been a priority.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants