News for hackers. Stuff that matters.
Re:Shellfirm: Intercept risky patterns at the command line by makeitdouble on Sunday July 31, 2022 @03:14AM (#32293871)
This kind of tool needs context awareness to be useful.

After the first 30~40 times you’re asked if you want to delete these pods, solving the question coming next becomes automatic. If you’re in a “I’m on my dev env, nothing bad can happen” mindset, that prompt won’t get you out of it, it will just be a tedious step, we’ve seen that time and time again.

It becomes a lot more interesting if it can ask “you’re going to delete from the cluster prod, do you really want to ?” and only do so for production.

Same for “rm -f” really, if it can confirm before you’re deleting a tree of thousands of file, and not when it’s 3 empty directories you created 3 min ago.

Re:Shellfirm: Intercept risky patterns at the command line by lamontcg on Sunday July 31, 2022 @09:33AM (#32295370)
This is the same logic as "sudo forces people to think about what they're typing", which it doesn't, it just makes you type sudo and your password really quickly and equally mindlessly.
Re:Shellfirm: Intercept risky patterns at the command line by iso1631 on Sunday July 31, 2022 @10:45AM (#32295848)
sudo sticks what you're doing in your auth.log file which is fired off to your syslog server, so you've got a chance of knowing how you messed up, or who else messed up
Re:Shellfirm: Intercept risky patterns at the command line by lamontcg on Sunday July 31, 2022 @07:51PM (#32300063)
we solved that at amazon by patching bash and tcsh to send logs to syslog (honeypot patches).
Re:Shellfirm: Intercept risky patterns at the command line by Kaze404 on Sunday July 31, 2022 @02:18PM (#32297441)
It does once you get past using sudo as second attempt at running a command that failed for a reason you don't understand.
Re:Shellfirm: Intercept risky patterns at the command line by lamontcg on Sunday July 31, 2022 @07:52PM (#32300071)
No it really doesn't, you just get quick at typing "sudo shutdown -r now" and typing your password quick and when do that it on prod it is just as mindless as "shutdown -r now". You can't make people think via extra steps.
Re:Shellfirm: Intercept risky patterns at the command line by Kaze404 on Sunday July 31, 2022 @09:24PM (#32300756)
Surely that's just your view on it? I've been using Linux since I was a kid and it's definitely not how I or the people I know use sudo. Lol
Re:Shellfirm: Intercept risky patterns at the command line by davedx on Sunday July 31, 2022 @04:27AM (#32294198)
When I used to admin Windows servers we had production’s desktop background set to red, that worked well, especially when you had multiple remote desktop sessions open. Wonder if that’s doable for non-GUI enabled Linux servers
Re:Shellfirm: Intercept risky patterns at the command line by t-3 on Sunday July 31, 2022 @05:11AM (#32294367)
The standard way is to set PS1 (the commandline prompt text) to indicate the environment. With escape codes, you can pretty trivially get some flashing red text telling you to be careful.
Re:Shellfirm: Intercept risky patterns at the command line by hobs on Sunday July 31, 2022 @07:55AM (#32294947)
If used properly the -Confirm parameter in powershell can also have you change the impact level in your environment and ask for confirmation on things that in dev would not be cared about.

Also its underused but the just in time access stuff where you can grant users subsets of permissions (again, per environment) is also pretty impressive.

Re:Shellfirm: Intercept risky patterns at the command line by formerly_proven on Sunday July 31, 2022 @05:45PM (#32299162)
A not-so standard way is to output a banner via shrc (instead of putting it in the motd, which the ssh daemon will only output for interactive sessions) - which incidentally will also break pretty much all tools using SSH as a transport (scp, rsync, among others).
Re:Shellfirm: Intercept risky patterns at the command line by qalmakka on Sunday July 31, 2022 @05:52AM (#32294482)
That was also the case in very old Linux distros when you logged on X as root. I clearly remember something like Fedora or Mandriva doing exactly that - note that graphically logging in as root on a Unix system is not a great idea though, most GUI software isn't designed for it.
Re:Shellfirm: Intercept risky patterns at the command line by NathanielK on Sunday July 31, 2022 @07:48AM (#32294924)
Other applications can do it too. I recall the Gnome file browser having a big red warning banner if you decided to launch it with gksudo.
Re:Shellfirm: Intercept risky patterns at the command line by 867-5309 on Sunday July 31, 2022 @05:57AM (#32294492)
the terminal background could be changed from black to red
Re:Shellfirm: Intercept risky patterns at the command line by detaro on Sunday July 31, 2022 @06:51AM (#32294714)
SuSE had bright red background with exclamation mark signs and bomb icons
Re:Shellfirm: Intercept risky patterns at the command line by orev on Sunday July 31, 2022 @09:58AM (#32295508)
It’s pretty easy to insert colors into to prompt using conditional logic in things like bashrc. You can also add them to other system tools like ‘screen’ and (I assume) ‘tmux’. People can override them if they want, but it’s a good starting default (and people rarely override defaults on a fleet of servers).
Re:Shellfirm: Intercept risky patterns at the command line by yencabulator on Sunday July 31, 2022 @01:22PM (#32297049)
My prompt only includes username if it's not the usual one, and it's on an orange-red background if it's root.

Similarly, my prompt doesn't include the host when I'm logged in normally, adds it when I'm in a shell via sudo/doas, and colors it when I'm logged in via SSH.

Re:Shellfirm: Intercept risky patterns at the command line by iso1631 on Sunday July 31, 2022 @10:48AM (#32295871)
20 years ago our live/test/dev solaris + linux environments had different coloured prompts (green/yellow/red)

Hasn't really been best practice in many workflows to connect to servers at all for a decade

Re:Shellfirm: Intercept risky patterns at the command line by linschn on Sunday July 31, 2022 @05:11AM (#32294369)
I use the color of tmux's bar to the same effect.
Re:Shellfirm: Intercept risky patterns at the command line by eladkaplan on Sunday July 31, 2022 @03:50AM (#32294011)
I agree that the context will be better and I'm planning to add it in the next releases.
Re:Shellfirm: Intercept risky patterns at the command line by a-dub on Sunday July 31, 2022 @11:39AM (#32296284)
i think a better approach might be to wrap destructive actions with preview functionality that is carefully tuned to summarize succinctly what is unique about resources that are going to be deleted along with the cardinality of the operation.
Re:Shellfirm: Intercept risky patterns at the command line by rootw0rm on Sunday July 31, 2022 @03:29AM (#32293919)
my main response to this HN submission was lolwtf. but your more measured response is valuable. this tool with context could actually be pretty cool.