Documentation
¶
Overview ¶
Package composebundle carries a HyperFrames project between machines: Pack turns a project directory into a gzip-compressed tar, Extract unpacks one into a fresh directory, and Confine checks that the project only refers to files inside itself (ADR 0071).
A project is trusted code: HyperFrames' Chrome runs without a sandbox and executes the project's JavaScript. The fleet's project door (fleetnode compose-project) accepts one only from a holder of the fleet token, and these three functions are the rest of its defence:
- Extract writes regular files and directories only (no symlink, hard link, device or FIFO), never outside the target (no absolute path, drive letter, UNC path, `..`, backslash, NUL or colon in a name), and within caps on the entries (directories included), the files, each file and the total, counted on the bytes actually written, not on the headers, with the whole decompressed stream bounded too.
- Confine (confine.go) reads every reference the project's HTML, SVG and CSS make, and those of any file a composition attribute names whatever its extension (src, href, poster, srcset, data, xlink:href, data-composition-src/-file, CSS url(), @import and image-set strings, in a raw-text scan that does not depend on parsing HTML as the compiler's parser does), and refuses one that points outside the project: a root-relative, absolute, UNC or protocol-relative path, a relative path that climbs above the project root from its file or from the root (where HyperFrames' compiler resolves one that does not start with "../"), a file: or other non-web URL, or an http(s) URL to a host that is not public (loopback in any legacy numeric form, private, the shared 100.64/10 range the tailnet uses, link-local, a .ts.net, .local or .internal name, a name with no dot, or a non-ASCII name). HyperFrames' compiler copies an asset referenced outside the project into its output and reads a composition file by any path; those are how a project could read a file off the render node, and Confine is what closes them. JavaScript is not parsed: at render time the page can reach only the project and its compiled copy (HyperFrames' file server confines every path to them).
Index ¶
Constants ¶
const ( DefaultMaxFiles = 4096 DefaultMaxFileBytes = 256 << 20 DefaultMaxTotal = 512 << 20 )
Variables ¶
var ErrIO = errors.New("i/o")
ErrIO marks an Extract failure that is the target machine's own (a directory it could not create, a write that failed, a disk that filled), never the bundle's: a node answers it as its own failure, not as a refused bundle.
Functions ¶
func Confine ¶
Confine checks every reference the project's HTML, SVG and CSS make, and those of every file a composition attribute names whatever its extension, and returns one error listing each that points outside the project (file:line and why). entry is the composition the render starts from; it must be a regular file inside the project.
Types ¶
type Limits ¶
type Limits struct {
MaxFiles int // files in the bundle
MaxEntries int // entries of any kind, directories included (default: twice MaxFiles)
MaxFileBytes int64 // one file, uncompressed
MaxTotal int64 // all files, uncompressed
}
Limits bound a bundle. The zero value means the defaults below.