Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Execution Policy setting to Powershell based shell plugins #1505

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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