Skip to content

Commit

Permalink
Add Execution Policy setting to Powershell based shell plugins (Acade…
Browse files Browse the repository at this point in the history
…mySoftwareFoundation#1505)

Signed-off-by: Erwan Leroy <[email protected]>
Signed-off-by: Jose Enriquez <[email protected]>
  • Loading branch information
herronelou authored and Jose Enriquez committed Feb 14, 2024
1 parent 1858342 commit 0b44d54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rezplugins/shell/_utils/powershell_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ def _record_shell(ex, files, bind_rez=True, print_msg=False):
# Suppresses copyright message of PowerShell and pwsh
cmd += ["-NoLogo"]

# Powershell execution policy overrides
# Prevent injections/mistakes by ensuring policy value only contains letters.
execution_policy = self.settings.execution_policy
if execution_policy and execution_policy.isalpha():
cmd += ["-ExecutionPolicy", execution_policy]

# Generic form of sourcing that works in powershell and pwsh
cmd += ["-File", target_file]

Expand Down
2 changes: 2 additions & 0 deletions src/rezplugins/shell/rezconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ powershell:
prompt: '> $ '
additional_pathext: ['.PY']
executable_fullpath: null
execution_policy: null

pwsh:
prompt: '> $ '
additional_pathext: ['.PY']
executable_fullpath: null
execution_policy: null

gitbash:
prompt: '>'
Expand Down

0 comments on commit 0b44d54

Please sign in to comment.