-
Notifications
You must be signed in to change notification settings - Fork 24
fix(shell): isolate execution context for exec/cos commands #996
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
base: main
Are you sure you want to change the base?
fix(shell): isolate execution context for exec/cos commands #996
Conversation
isc-dchui
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor things!
src/cls/IPM/Main.cls
Outdated
| try { | ||
| write ! | ||
| xecute tCommandInfo("parameters","expression") | ||
| } catch ex { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just throw the error and let the exception handling of ShellInternal() handle it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Added the $$$ThrowOnError inside catch block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simplicity's sake, I don't think we need this extra try/catch block in this method. The error should be propagatable up the call stack, so essentially just
ClassMethod ExecuteCOS(ByRef tCommandInfo)
{
new $namespace
write !
xecute commandInfo("parameters","expression")
}
Also minor nit: remove the t- prefixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing. I have updated the method to use the minimalist approach as suggested. I removed the try/catch block and the t- prefixes from the variables.
src/cls/IPM/Main.cls
Outdated
|
|
||
| ClassMethod ExecuteCOS(ByRef tCommandInfo) | ||
| { | ||
| set namespace = $namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new $namespace line before this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Added the new $namespace and removed the set namespace = $namespace
| - #822: The CPF resource processor now supports system expressions and macros in CPF merge files | ||
| - #578 Added functionality to record and display IPM history of install, uninstall, load, and update | ||
| - #961: Adding creation of a lock file for a module by using the `-create-lockfile` flag on install. | ||
| - #996:Ensure COS commands execute in exec under a dedicated, isolated context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you'll need to resolve conflicts here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved the conflicts
isc-dchui
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small test would also be helpful. Shouldn't be too complicated to xecute an erroring expression/code block that switches the namespace and verify the namespace gets reverted back to what it was originally.
src/cls/IPM/Main.cls
Outdated
| try { | ||
| write ! | ||
| xecute tCommandInfo("parameters","expression") | ||
| } catch ex { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simplicity's sake, I don't think we need this extra try/catch block in this method. The error should be propagatable up the call stack, so essentially just
ClassMethod ExecuteCOS(ByRef tCommandInfo)
{
new $namespace
write !
xecute commandInfo("parameters","expression")
}
Also minor nit: remove the t- prefixes.
This PR introduces namespace isolation for the
exec(andcos) command utility.Currently, the
execcommand allows a user to execute arbitrary ObjectScript that can modify the process state. If a user executes a namespace switch (e.g.,exec zn "%SYS"), the shell process remains in that new namespace context after the command completes. If that target namespace does not have the%IPMpackage mapped, the shell immediately crashes when it attempts to render the next prompt or error message because it can no longer find its own configuration classes.Related Issues
Testing Conducted
exec zn "%SYS"from theUSERnamespace.USERnamespace. The prompt rendered correctly.exec set x = 1/0(divide by zero) to trigger an error.execcommands (likeexec write 123) still function normally with no overhead.