Skip to content
Valakes docs
Menu

Command check

What this is for: The command check

Last updated

On this page

Valakes reads the command you typed before it runs. A command that can do real damage stops on a card that says why. Everything else goes through without a word, so the check stays out of your way when you are doing ordinary work.

The check is mistake prevention. It guards your own hand against a typo or a wrong host, and it does not defend against a compromised window. The Security FAQ says so in the same words.

The check works on the parsed command, not on a search through the text. A rule looks at the program, its flags and its arguments, so echo "rm -rf /" does not raise an alarm, while sudo rm -rf x and find . -delete do. The rules are YAML files shipped with Valakes, and each one carries examples that must match and examples that must not.

A command has one of three levels.

Level Examples What you see
High rm -rf, dd writing to a disk device, mkfs, shutdown and reboot, iptables -F, curl … | sh, git push --force, DROP DATABASE or TRUNCATE given to psql, mysql or mongosh, find … -delete, a recursive chmod that makes files world-writable The risk card, “High risk”. The command waits for you.
Medium rm -r without -f, restarting or stopping a service, kill -9, removing packages, docker rm, overwriting a file with >, sed -i, a recursive chown, git push --force-with-lease, adding a firewall rule A line under the composer. The command is not stopped.
Low Everything else Nothing, unless the mode is Explain all

Settings, Command check chooses how much the check says.

  • Off never asks and shows no hint.
  • Dangerous only asks before a High command and shows a line under the composer for a Medium one. This is the default.
  • Explain all also explains every command in one line. Those notes never stop a command and never change its level.

You can also set Command check on this host in the host editor, and Don’t ask on this host on the card turns the card off for one host after a native confirmation.

A High command opens the card. It gives the reason in plain words and, for deletes and recursive permission changes, a count of what would be affected, such as “Blast radius: 3 files”.

  • Cancel has the focus, so pressing Enter does not run the command.
  • On a production host the card carries the red PROD badge, and Run anyway stays disabled until you type the host name.
  • Elsewhere Run anyway is ready at once.

An agent never gets the Run anyway button. For an agent, a High command is approve or deny, and the decision is yours. See Agents for the approval queue.

To count files, Valakes uses a second hidden channel on the same SSH connection, the one that tab completion also uses. It sends a fixed script and quotes every argument as data, so nothing you typed is ever evaluated by a shell on that channel. The count has a short limit of its own: a query that takes more than about two seconds is dropped. Nothing is typed into your terminal for it.

Some commands cannot be counted. rm -rf "$HOME/x" still asks, but the path depends on shell expansion, so the card shows no count. A server that refuses exec (a forced command or a restricted shell) gets no counts and no completion on that connection.

A host marked production changes the check: a Medium command is raised to High and asks too. Pasting more than one line on a production host shows the lines numbered, and nothing is sent until you confirm. Settings, Command check has a choice to ask on every host instead of only on production. A multi-line paste into a full-screen program gets a review overlay, and pasted or dropped text is filtered for terminal escape codes first. See Hosts and production marking.

The check reads the line you typed in the composer. It does not see:

  • inside a script (sh x.sh), a remote alias or function, or SQL that comes from a file;
  • the order of PATH;
  • anything a program does after it starts;
  • commands typed in Raw mode, in a full-screen program or in a nested shell such as sudo -i, because those never reach it. Read Composer and Raw mode for when the composer steps aside.

The count of affected files assumes the default shell options. Off, and Don’t ask on this host, switch the check off by your choice. The typed host name and Run anyway guard your own hand. They are not a defence against a compromised window.