Skip to main content

Module guard

Module guard 

Source
Expand description

The secret guard. Nothing leaves this machine for the remote without passing through here: command text, file contents written or edited, and every file an upload would send.

Two checks:

  • path: the local file’s name or any directory on its path marks it as credential material (.env, *.pem, ~/.ssh/..., agent configs that embed API keys, …);
  • content: the bytes contain something shaped like a credential (private-key blocks, well-known token prefixes, a key = "..." assignment whose value is a literal, not a variable name, and not a low-entropy placeholder).

The guard errs toward refusing. A false positive costs one retry with a clear message; a false negative puts a credential on a machine the user chose not to trust with it.

Structs§

Finding
Guard
StreamGuard
Checks an upload in the form it actually leaves in, chunk by chunk, so a file that changes after its first scan cannot send what that scan never saw. The last SCAN_OVERLAP bytes are held back until the next chunk has been scanned with them, so a secret spanning two chunks is seen whole before any of it is released — the same windows ensure_upload_file uses.