Run unknown shell script with a line-by-line confirmation prompt

Dev tools

shell script safety

SHOW HN2021

158points
82comments
#304of 2,533 in 2021
Top 13%of 2021 by points

How HN took it

CuriousMostly questions and neutral comments

3 positive, 23 neutral or asking, 0 mixed, 14 critical, out of 40 comments about the project. Thread score -0.29.

Idea: 3 for, 11 againstExecution: 0 for, 3 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Useful for running your own legacy scripts with a review step.

    From 2 comments
    • I want this to run my own shell scripts. I have a bunch of scripts that are halfway between "documentation" and "automation"; mostly the record of the last time I did X. Add a…
      GauntletWizard on HN
    • > I want this to run my own shell scripts. That's really the only use case for this tool that I could get behind, and I commend you for your diligence.
      dumpsterdiver on HN

Objections

  • Reading a script before running it is safer than a prompt tool.

    From 3 comments
    • > Useful for running unknown scripts Or just, you know, read them before you run them.
      barbazoo on HN
    • If you are considering using this tool, then I would suggest that you seriously reevaluate your life choices. You should never run shell scripts without reading them first, ever.…
      dumpsterdiver on HN
    • I understand your point, but there is a big difference between running a 20 year old program written in C and running a shell script that someone with one or two years of…
      dumpsterdiver on HN
  • Prompts can be fooled by obfuscation, heredocs and backspace tricks.

    From 2 comments
    • You can fool it with ^H (Insert with ^V^H in vim) ``` #!/bin/sh rm not ^H^H^H^H expected ``` Gives: ``` -> rm expected Run command? [Y/n] rm: cannot remove 'not': No such file or…
      tyingq on HN
    • Heredocs are a little odd, because you can't see what they might be piping to. This script, for example looks sort of innocuous when run through your tool because it's not…
      tyingq on HN
  • Static analysis or sandboxing of scripts is hard and not robust.

    From 3 comments
    • Very difficult to do in any kind of robust way. A script can run all kinds of things and use myriad forms of obfuscation, causing all kinds of obscure side effects.
      mlyle on HN
    • 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…
      dwohnitmok on HN
    • If you are happy with running it only once in the container, yes. But if you run it first in the container to see whether is does anything bad and then run it on the host (or a…
      usr1106 on HN

Requests

  • Analyse scripts first and report which files and network resources they touch.

    From 2 comments
    • 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…
      cookiengineer on HN
    • 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…
      lloeki on HN
  • Sandbox execution using overlayfs or containers.

    From 2 comments
    • I imagine this could be done by actually running the script in some sort of sandbox, having file changes written to overlayfs at first. This would still allow the script to steal…
      vanviegen on HN
    • You could do this by running your script pivot mounted into a namespace that mounts your "real" filesystem as readonly and layers with overlayfs to log changes. You can then…
      krageon on HN

Questions

  • Whether the tool can run itself.

    From 1 comment

Alternatives named

  • bashdb debugger

    From 1 comment
    • You can also do this with bashdb which is possibly also a more robust solution.
      opk on HN
  • Deno --prompt permission prompts

    From 1 comment
    • This is exactly what deno is useful for. Write your script in typescript and then run it with deno --prompt. I made a little demonstration script. ``` deno run --prompt…
      searchableguy on HN
  • Bash restricted shell (bash -r)

    From 1 comment
    • Possibly relevant, the bash restricted shell (bash -r): https://www.gnu.org/software/bash/manual/html_node/The-Restricted-Shell.html
      rhizome on HN
  • maybe (p-e-w) sandboxing tool

    From 1 comment
    • That sounds a lot like what maybe[1] does. [1] https://github.com/p-e-w/maybe
      mimimi31 on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/26812696)