How it works
Set Environment to Production on a server or a group. Before a line runs there, Wardterm reads it. When it finds a risky command, it says what the command does and the safe move, and asks Run this on production?. The same check covers a paste, a saved command, a command from History and a command sent to several servers.
A red warning is for what cannot be undone: a wiped disk, a dropped database, a deleted server, a server you can no longer reach. The others ask for a second look.
What it catches
- Files: recursive deletes of system folders, homes and database data,
rm -rf "$DIR/"*with a variable that may be empty, moving or opening up system folders, overwriting/etc/passwdor/etc/fstab. - Disks:
dd,mkfs,wipefs, partition tables, LVM and ZFS,diskutil eraseDiskon macOS,Format-Volumeandcleanin diskpart on Windows servers. - Getting locked out: firewall rules that block SSH or drop everything, stopping the SSH server or restarting it without a test, editing
sshd_config, sudoers or PAM by hand, taking the network down, removingauthorized_keys, locking the account you use. - Power: shutdown, reboot, rescue mode,
Restart-Computer. - Databases:
DROP,TRUNCATE,DELETEandUPDATEwithoutWHERE, typed at a SQL prompt or sent withpsqlandmysql; MongoDB drops, RedisFLUSHALL, HTTPDELETErequests. - Containers and cloud: Docker volumes and prunes,
kubectl delete,helm uninstall,terraform destroy, deleting servers, buckets and projects with the AWS, Google Cloud, Azure and other cloud tools. - Git: force pushes, deleting remote branches,
reset --hard,clean -fdx. - Code from elsewhere: a download piped into a shell, such as
curl | shoriwr | iex, and encoded text run by a shell. - Windows servers:
Remove-Item -Recurse -Forceon system paths, shadow copies and recovery, machine registry keys, services and firewall.
It reads through sudo, ssh host '...', bash -c, xargs, find -exec, docker exec, powershell -Command and several commands on one line, with options written together or apart.
The safe move
Each warning says what can go wrong and what to do first. Before ufw enable with no rule for SSH, allow it:
ufw allow OpenSSH
Before restarting the SSH server after a change to its configuration, test it, and keep this session open while you try a new one:
sshd -t && systemctl restart sshd
Everyday commands stay quiet: rm file.txt, git push, DELETE ... WHERE id = 1 or systemctl restart nginx run without a question.
What it cannot see
Wardterm reads the line you send, not what the server does with it. These run without a warning:
- aliases, functions and scripts, such as
./cleanup.sh; - history shortcuts the shell expands, such as
!!; - names and paths built when the command runs, such as
$(echo rm)or a variable that holds a path; - encoded or compressed text that is not in the line itself;
- keys typed inside full-screen programs, such as an editor.
The warning gives you a second look. Backups and limited permissions on the server do the rest. More on the production safety page.