[{"data":1,"prerenderedAt":414},["ShallowReactive",2],{"project-26812696":3},{"id":4,"name":5,"line":5,"line_source":6,"title":7,"url":8,"domain":9,"maker":10,"posted_at":11,"year":12,"points":13,"comments":14,"rank_in_year":15,"shown_in_year":16,"top":17,"tier":18,"category":19,"subcategory":20,"format":21,"keywords":22,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":34,"aspects":35,"strip":40,"post_text":43,"what":44,"said":56,"maker_in_thread":169,"shape":177,"grid":182,"attempts":376,"same_week":377,"maker_shows":41,"maker_hidden":406,"reader_version":407,"card":408},"26812696","Run unknown shell script with a line-by-line confirmation prompt","title","Show HN: Run unknown shell script with a line-by-line confirmation prompt","https:\u002F\u002Fgist.github.com\u002Fwlib\u002F093f8b8f670016813073a4c4f8b28e81","gist.github.com","wlib",1618432513,2021,158,82,304,2533,13,"notable","dev_tools","shell script safety","cli",[23,24,25,26],"shell script","bash","confirmation prompt","script safety","curious",-0.288,{"positive":30,"neutral":31,"mixed":32,"critical":33},3,23,0,14,40,{"execution":36,"idea":37,"design":39},{"positive":32,"critical":30},{"positive":30,"critical":38},11,{"positive":32,"critical":32},[41,41,41,30,41,41,41,30,30,41,32,30,30,41,41,41,32,30,30,30,30,30,32,30,30,41,32,32,32,32,32,32,32,30,42,32,32,32,32,30],1,5,null,{"problem":43,"audience":43,"pricing":43,"motivation":43,"time_to_build":43,"stack":45,"openness":55,"stage":55,"team_size":55},[46],{"value":24,"source":47,"evidence":48},"inferred",[49,52],{"id":50,"by":10,"text":51},"26814404","I updated to fix that, thanks for pointing it out. It had to do with echo printing the command with your backspace characters escaped. See if you can break it now, it's…",{"id":53,"by":10,"text":54},"26814642","Yup, at that point it's within the scope of bash's debugger. It shows the command that is actually being run, so it expands globs, shows the command within if predicates, and so…","unknown",{"praise":57,"objections":70,"requests":109,"questions":132,"alternatives":140},[58],{"value":59,"source":60,"evidence":61},"Useful for running your own legacy scripts with a review step.","commenter",[62,66],{"id":63,"by":64,"text":65},"26815021","GauntletWizard","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…",{"id":67,"by":68,"text":69},"26815099","dumpsterdiver","> 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.",[71,84,94],{"value":72,"source":60,"evidence":73},"Reading a script before running it is safer than a prompt tool.",[74,78,81],{"id":75,"by":76,"text":77},"26813314","barbazoo","> Useful for running unknown scripts Or just, you know, read them before you run them.",{"id":79,"by":68,"text":80},"26814986","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.…",{"id":82,"by":68,"text":83},"26815352","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…",{"value":85,"source":60,"evidence":86},"Prompts can be fooled by obfuscation, heredocs and backspace tricks.",[87,91],{"id":88,"by":89,"text":90},"26814016","tyingq","You can fool it with ^H (Insert with ^V^H in vim) ``` #!\u002Fbin\u002Fsh rm not ^H^H^H^H expected ``` Gives: ``` -> rm expected Run command? [Y\u002Fn] rm: cannot remove 'not': No such file or…",{"id":92,"by":89,"text":93},"26814532","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…",{"value":95,"source":60,"evidence":96},"Static analysis or sandboxing of scripts is hard and not robust.",[97,101,105],{"id":98,"by":99,"text":100},"26815772","mlyle","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.",{"id":102,"by":103,"text":104},"26816435","dwohnitmok","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…",{"id":106,"by":107,"text":108},"26816804","usr1106","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…",[110,121],{"value":111,"source":60,"evidence":112},"Analyse scripts first and report which files and network resources they touch.",[113,117],{"id":114,"by":115,"text":116},"26815693","cookiengineer","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…",{"id":118,"by":119,"text":120},"26817361","lloeki","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…",{"value":122,"source":60,"evidence":123},"Sandbox execution using overlayfs or containers.",[124,128],{"id":125,"by":126,"text":127},"26816262","vanviegen","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…",{"id":129,"by":130,"text":131},"26818078","krageon","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…",[133],{"value":134,"source":60,"evidence":135},"Whether the tool can run itself.",[136],{"id":137,"by":138,"text":139},"26813452","jdeaton","Can I use it to run itself?",[141,148,155,162],{"value":142,"source":60,"evidence":143},"bashdb debugger",[144],{"id":145,"by":146,"text":147},"26812873","opk","You can also do this with bashdb which is possibly also a more robust solution.",{"value":149,"source":60,"evidence":150},"Deno --prompt permission prompts",[151],{"id":152,"by":153,"text":154},"26817090","searchableguy","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…",{"value":156,"source":60,"evidence":157},"Bash restricted shell (bash -r)",[158],{"id":159,"by":160,"text":161},"26813820","rhizome","Possibly relevant, the bash restricted shell (bash -r): https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Fbash\u002Fmanual\u002Fhtml_node\u002FThe-Restricted-Shell.html",{"value":163,"source":60,"evidence":164},"maybe (p-e-w) sandboxing tool",[165],{"id":166,"by":167,"text":168},"26816836","mimimi31","That sounds a lot like what maybe[1] does. [1] https:\u002F\u002Fgithub.com\u002Fp-e-w\u002Fmaybe",{"comments":30,"answered":170,"key":171},2,[172,173,174],{"id":50,"text":51},{"id":53,"text":54},{"id":175,"text":176},"26813636","Not without some modifications, which I did not make because the complexity would get crazy with shell scripting",{"commenters":178,"max_depth":179,"maker_replies":30,"first_comment_mins":180,"lifespan_hours":181},53,9,15,131,[183,185,187,188,189,191,193,195,196,198,200,203,205,207,208,211,212,215,218,219,223,225,228,230,233,234,236,237,240,243,247,248,252,256,259,260,263,265,267,271,274,277,281,284,287,289,292,296,298,299,301,304,306,309,312,314,317,320,322,324,326,329,332,334,336,339,342,345,346,348,349,352,355,356,358,361,364,366,368,370,372,374],[88,32,41,184,89,32],"project\u002Fcritical\u002Fexecution",[50,32,32,186,10,41],"maker\u002Fneutral\u002Fexecution",[92,32,41,184,89,32],[53,32,32,186,10,41],[114,41,30,190,115,32],"project\u002Fneutral\u002Fidea",[98,41,41,192,99,32],"project\u002Fcritical\u002Fidea",[194,41,30,190,115,32],"26815816",[125,41,30,190,126,32],[197,41,41,192,103,32],"26816474",[199,41,30,190,126,32],"26816656",[201,41,41,192,202,32],"26818568","joosters",[204,41,30,190,126,32],"26821667",[206,41,30,190,99,32],"26824419",[102,41,41,192,103,32],[209,41,30,190,210,32],"26817265","qqii",[118,41,30,190,119,32],[213,41,30,190,214,32],"26818966","harperlee",[216,41,30,190,217,32],"26816747","imhoguy",[106,41,41,192,107,32],[220,41,32,221,222,32],"26816873","other\u002Fneutral\u002Fnone","aroulin",[224,41,32,221,107,32],"26816910",[226,41,32,221,227,32],"26817076","rgoulter",[229,41,32,221,107,32],"26817280",[231,41,30,190,232,32],"26816782","totetsu",[166,41,30,190,167,32],[235,41,32,221,115,32],"26829244",[129,41,30,190,130,32],[238,41,41,192,239,32],"26839791","breakingcups",[241,170,41,184,242,32],"26814387","scintill76",[244,170,30,245,246,32],"26814449","project\u002Fneutral\u002Fdesign","macintux",[152,30,41,192,153,32],[249,250,41,192,251,32],"26813825",4,"eurasiantiger",[253,250,32,254,255,32],"26813894","commenter\u002Fneutral\u002Fnone","LinuxBender",[257,250,32,254,258,32],"26815168","cratermoon",[159,42,30,190,160,32],[261,42,30,190,262,32],"26814988","comboy",[264,42,32,254,160,32],"26871587",[145,266,30,190,146,32],6,[268,266,30,269,270,32],"26813217","project\u002Fneutral\u002Fexecution","e40",[272,266,32,221,273,32],"26815792","qiqitori",[275,266,32,221,276,32],"26817908","tessellated",[278,279,30,190,280,32],"26814136",7,"protomyth",[282,279,30,190,283,32],"26815454","Skunkleton",[285,279,30,190,286,32],"26818954","kevincox",[288,279,32,254,283,32],"26825727",[290,279,32,221,291,32],"26815868","slaymaker1907",[293,294,32,221,295,32],"26813405",8,"m463",[137,179,30,297,138,32],"project\u002Fneutral\u002Fnone",[175,179,32,186,10,41],[300,179,30,190,258,32],"26815176",[302,179,32,254,303,32],"26815502","aufhebung",[75,305,41,192,76,32],10,[307,305,32,254,308,32],"26814312","klyrs",[310,305,32,254,311,32],"26814570","jjnoakes",[313,305,32,254,308,32],"26814615",[315,305,32,254,316,32],"26815431","junon",[318,305,32,254,319,32],"26816470","ipsin",[321,305,32,254,316,32],"26816968",[323,305,32,254,308,32],"26817213",[325,305,32,254,130,32],"26818131",[327,305,32,221,328,32],"26815626","renewiltord",[330,305,32,254,331,32],"26816264","MereInterest",[333,305,32,254,328,32],"26816309",[335,305,32,254,286,32],"26818978",[337,305,32,254,338,32],"26815075","amlib",[340,305,32,254,341,32],"26816076","scaladev",[343,305,32,254,344,32],"26816432","dang",[79,38,41,192,68,32],[63,38,42,347,64,32],"project\u002Fpositive\u002Fidea",[67,38,42,347,68,32],[350,38,32,254,351,32],"26815131","martinald",[353,38,32,254,354,32],"26815256","dataflow",[82,38,32,254,68,32],[357,38,32,254,76,32],"26815553",[359,38,32,254,360,32],"26816153","carlhjerpe",[362,38,32,254,363,32],"26815372","Waterluvian",[365,38,32,254,68,32],"26815383",[367,38,32,254,283,32],"26815401",[369,38,32,254,68,32],"26815449",[371,38,32,254,283,32],"26815474",[373,38,41,192,68,32],"26815510",[375,38,42,347,328,32],"26815654",[],[378,383,388,393,398,402],{"id":379,"name":380,"points":381,"category":382},"26805702","Lofi.cafe",1192,"creative",{"id":384,"name":385,"points":386,"category":387},"26791582","DeepHN",324,"data",{"id":389,"name":390,"points":391,"category":392},"26741611","I Wish There Was an App",272,"productivity",{"id":394,"name":395,"points":396,"category":397},"26790486","I made a 5-key keyboard",221,"hardware",{"id":399,"name":400,"points":401,"category":19},"26806797","Encore",182,{"id":403,"name":404,"points":405,"category":392},"26781451","PMS (Personal Data Management Dashboard)",176,false,"v2",{"id":409,"name":5,"line":5,"ai":406,"cat":19,"year":12,"points":13,"comments":14,"rec":27,"s":410,"top":17,"kw":411,"maker":10,"domain":9,"tier":18,"attempts":32,"strip":412,"url":8,"mix":413,"praise":59,"objection":72,"sub":20},26812696,-0.29,[23,24,25,26],"1113111331033111033333033100000003500003",[30,31,32,33],1794036605689]