5 ms·
I don't think a blacklist could possibly be comprehensive enough. I think you'd have to use some OS permission-limiting system to prevent it and any subprocesse
by rcthompson 8y ago
I don't think a blacklist could possibly be comprehensive enough. I think you'd have to use some OS permission-limiting system to prevent it and any subprocesses it spawns from have any write access to the filesystem.
- esotericn 8y agoPretty much. Is rm blacklisted? OK. How about bash -c "rm"? cp? mv? vim? ...? :D
- y4mi 8y agoYah, a whitelist of commands which includes bash would probably be best. You'd be fine using it and can simply switch to chainsaw mode by adding bash to the command
- malkarouri 8y agoI think the tool would be much more useful with a whitelist. Do this only for grep, awk, sed and other similar tools. Of course, much more thought is needed to try something like this. Somebody could as well use awk with its system command to do whatever..
- deleted 8y ago[deleted]
- conquistadog 8y agoEven an incomplete blacklist might be helpful, just in the interest of keeping perfect from being the enemy of good.
- amelius 8y agoOr perhaps use filesystem snapshots as an undo option ... if your fs supports them, of course.
- akavel 8y agoAuthor here: I hope something like that (syscall/capabilities limits) could work. If it is possible, it would just mostly solve the problem, I believe. I'm kinda starting to realize, that probably any command modifying some external state is potentially somewhat risky already, by potentially spinning some exponential feedback loop. (One person on lobste.rs mentioned that foo.bak.bak.bak.bak files could easily get created.) Regardless, I'm generally considering adding a shortcut/option to pause/unpause, and only execute on Ctrl-Enter when paused.
- rcthompson 8y agoAnother possibly reasonable option would be to create a (configurable) whitelist of commands that are considered safe, and keep running the pipeline automatically as long as it only contains whitelisted commands. Any time a non-whitelisted command is introduced, stop auto-running and require Ctrl+Enter or something, until the command once again consists of only whitelisted commands. This would save you, for example, if you had a custom command called "gr" which was short for "get rid of current directory" (obviously chosen as a pathological example since it's a prefix of grep). As you type the word "grep", auto-running is paused because "g", "gr", and "gre" are not whitelisted, and then once "grep" is fully typed, it recognizes that "grep" is on the whitelist and resumes auto-running. And it never ran the dangerous "gr" command.