Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix delimiter selection on powershell payload commands #12463
While looking at getting some rex-powershell stuff landed, I tried adding powershell payloads to the automated testing, but while the testing system supports it (to my happy surprise), the cmd_exec tests fail.
After some digging, it turns out that the poswershell session was adding the bytestring 0xdad20 after our second delimiter. For some reason (I now see) rather than splitting on the delimiter, we were deleting the second delimiter so that the odd bytestring remained and screwed up the echo tests. Normally, this would be taken care of by our call to
One solution was to call "strip" to the response, but then we'd lose any expected trailing whitespace. In this case, I simply split on the second delimiter and threw away any trailing characters.
That approach works, but is is super slow. Significantly slower than I would expect. If someone can find a faster route, I am game. Previously, I tried to combine the regexes and split the substring between the delimiters, and it was not appreciably different in speed than this solution. I also tried using a second buffer under the theory in-place changes might take longer. No such luck.
List the steps needed to make sure this thing works
There are still some things that need attention in the cmd_exec stuff and I've already got an idea on how to fix this for shells, but I wanted to get this up now and see if anyone had feedback on the performance issue.
Added changes so that cmd_exec tests pass with shell sessions, too.
I went ahead and guarded against @wvu-r7's cases when
There are still some issues related to automated testing, but that's all over in the geppetto repo and I'll iron those out there. I'd still like to see powershell commands be snappier, but as the Rolling Stones remind me, you can't always get what you want.
OK; I give.