module

Smith::Web::Guard

Keeps web_fetch from being turned into a probe of the machine it runs on.

Constants

ALLOWED_SCHEMES = ["http", "https"] of ::String

Class methods

check(uri : URI, allow_private : Bool = false) : String | Nil

Returns the reason to refuse, or nil to proceed.

The address check happens after DNS resolution on purpose. Checking the hostname would be theatre: a name with an A record pointing at 169.254.169.254 walks straight past it, which is the classic way to read cloud instance metadata through someone else's fetcher.

Source
normalize(uri : URI, allow_private : Bool = false) : URI

Plain http is upgraded rather than refused: the request would otherwise travel in the clear, and nearly every public host that answers http answers https too.

Not when private targets are allowed, though. That setting exists for local development, and a dev server on loopback almost never speaks TLS — upgrading would make the option useless for the one case it is for.

Source