What would be amazing is a tool that analyses the script first, figures out folders and files (and networking) it influences and allows to sandbox it accordingly. This script wants to modify: - /usr/local/program/* - /etc/program/* - $HOME/.program Do you want to execute this? [Yes/No] ..because you know, what happens when you execute a script that does rm -rf /usr in the 100th step?
In its full generality this runs afoul of the halting problem. That doesn't mean what you want is completely unattainable, you just need to figure out whether you're okay with false positives, false negatives, or your tool just giving up on certain scripts (or some combination thereof).
Show HN: Run unknown shell script with a line-by-line confirmation prompt
71–80 of 86 posts
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#72Earlier quoted context omitted.
doesn't the halting problem only hold if you have infinite memory?
I've seen this argument that 'halting problem is undecideable': http://www.lel.ed.ac.uk/~gpullum/loopsnoop.html The argument doesn't rely on infinite memory.
In real systems external inputs provide an infinite source of "memory" to read from.
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#73What would be amazing is a tool that analyses the script first, figures out folders and files (and networking) it influences and allows to sandbox it accordingly. This script wants to modify: - /usr/local/program/* - /etc/program/* - $HOME/.program Do you want to execute this? [Yes/No] ..because you know, what happens when you execute a script that does rm -rf /usr in the 100th step?
In its full generality this runs afoul of the halting problem. That doesn't mean what you want is completely unattainable, you just need to figure out whether you're okay with false positives, false negatives, or your tool just giving up on certain scripts (or some combination thereof).
Such a static analyser would have two interesting aspects: on the end user side, the one mentioned of outputting the touched paths, and also doubling as being a linter for the script developer.
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#74You can also do this with bashdb which is possibly also a more robust solution.
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#75What would be amazing is a tool that analyses the script first, figures out folders and files (and networking) it influences and allows to sandbox it accordingly. This script wants to modify: - /usr/local/program/* - /etc/program/* - $HOME/.program Do you want to execute this? [Yes/No] ..because you know, what happens when you execute a script that does rm -rf /usr in the 100th step?
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#76Earlier quoted context omitted.
A browser extension is not a threat model, I'm not sure what you mean.
Browser extensions are an attack surface, examination of which is a key aspect of threat modeling.
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#77Earlier quoted context omitted.
This would still be defeated by any script that is nondeterministic which is a real possibility if you're trying to defend against malicious scripts or against very poorly written scripts.
You wouldn't need to run the script twice. Just apply the file modifications when the user okays them.
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#78It would be interesting to have a shell that allowed transactions like a database and could list what files have been affected while in the transaction.
You could snapshot your filesystem, then run the script and diff against the snapshot. Isolating executables (even shell scripts) is really outside the scope of what a shell normally provides.
It would be interesting if you could mount the snapshot then attempt to merge in the changes to the live system once approved. I don't know if any filesystems that support merges though.
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#79Earlier quoted context omitted.
In its full generality this runs afoul of the halting problem. That doesn't mean what you want is completely unattainable, you just need to figure out whether you're okay with false positives, false negatives, or your tool just giving up on certain scripts (or some combination thereof).
I would be fine with a static analyser doing the last one (giving up in doubt), considering that install scripts are a smaller subset of all possible shell scripts. Such a static analyser would have two interesting aspects: on the end user side, the one mentioned of outputting the touched paths, and also doubling as being a linter for the script developer.
Re: Show HN: Run unknown shell script with a line-by-line confirmation prompt
#80Earlier quoted context omitted.
One complication is that websites can hijack your copy buffer, and the text you paste isn't the text you copied. I avoid this by pasting into an editor, not directly into a shell.
Excuse my ignorance but when are you copying commands from a site you don't trust? If I don't trust a site I don't run anything it suggests to me, copy hijacking or no.
But if the site is nefarious it can adjust my copy so that I copy a mailious command rather than the one I verified.