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

[Close #71] Do not escape to local system shell #72

Merged
merged 4 commits into from
Apr 16, 2020

Conversation

schneems
Copy link
Contributor

@schneems schneems commented Apr 1, 2020

Right now if someone wrote this code:

app.run("ls && rm -rf /")

It would be interpreted as:

$ heroku run ls
$ rm -rf /

Which is surprising at best and harmful at worst. This PR auto escapes commands by default. This was the default behavior before 59f76d4 which removed shellescape-ing, but this edge case was not considered.

If the user wants more flexibility, they can specify they're using their own escaping by passing in raw: true.

I also updated the method signature for App#run so that the heroku: option can be used without having to specify a nil argument in the middle, I'm deprecating the ReplRunner interface (which was pretty broken and I don't believe used) so that we can simplify the method signature in the future.

Copy link
Member

@Malax Malax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an improvement to the previous behaviour, even if it breaks backwards compat again. I had to change my specs for work when I updated hatchet to work with the "raw by default" feature. But I really didn't need the feature. Having raw as opt-in makes sense to me.

Right now if someone wrote this code:

```
app.run("ls && rm -rf /")
```

It would be interpreted as:

```
$ heroku run ls
$ rm -rf /
```

Which is surprising at best and harmful at worst. This PR auto escapes commands by default. This was the default behavior before 59f76d4 which removed shellescape-ing, but this edge case was not considered.

If the user wants more flexibility, they can specify they're using their own escaping by passing in `raw: true`.

I also updated the method signature for `App#run` so that the `heroku:` option can be used without having to specify a `nil` argument in the middle, I'm deprecating the ReplRunner interface (which was pretty broken and I don't believe used) so that we can simplify the method signature in the future.
@schneems schneems force-pushed the schneems/multi-commands-run branch from 6fea687 to 014c343 Compare April 16, 2020 17:02
@schneems schneems merged commit 9c07a53 into master Apr 16, 2020
@schneems schneems deleted the schneems/multi-commands-run branch April 16, 2020 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants