frontendbundle

package
v1.0.526 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package frontendbundle validates a built admin-frontend tree before any byte of it is served (FE-1B §3/§15, ADR-FE-001; boundary in ADR-0050).

Validate reads a Vite production output through an fs.FS (index.html, manifest.json and assets/) and either returns the shell bytes and the exact set of assets that may be served, or an error. It fails closed: manifest strings are build output but are treated as hostile, so a compromised or inconsistent build is rejected here instead of reaching the serving layer. The checks are:

  • manifest.json parses, has no duplicate object key at any depth (encoding/json is last-value-wins) and has an entry chunk;
  • every referenced path is canonical, relative, under assets/, has an allowlisted extension and carries the content-hash suffix that the immutable Cache-Control header depends on;
  • every imports / dynamicImports value is an existing manifest key;
  • the manifest's reference set and the tree agree exactly, with no sourcemap, stray file, unexpected directory or case-only collision;
  • the shell references exactly the manifest entry's script and stylesheet set, and only validated /assets/ paths.

Package main (ui_frontend_v2.go) owns the embedded artifact, the CULVERT_EXPERIMENTAL_UI gate, the resolved-once state, the routes, the response headers and the /ready row. This package owns only the decision "is this tree safe to serve, and which files". It holds no mutable state, starts no goroutines, does no logging and performs no I/O beyond reading the fs.FS it is given. Its only non-stdlib import is internal/obs, for the CWE-117 sanitizer applied to manifest strings quoted in error text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(dist fs.FS) (shell []byte, assets map[string]Asset, err error)

Validate checks a built frontend tree (index.html, manifest.json, assets/) and returns the exact shell bytes plus the set of assets that may be served. It fails closed: any missing, ambiguous, unreferenced, mis-named or out-of-namespace file is an error, and the returned set is empty. The error text is safe to log (untrusted manifest strings are sanitized and quoted).

Types

type Asset

type Asset struct {
	ContentType string
	Size        int64
}

Asset is the bounded per-asset metadata Validate returns for each admitted file. Bodies stay in the caller's file system; no copy is held here.

type ManifestEntry

type ManifestEntry struct {
	File           string   `json:"file"`
	CSS            []string `json:"css"`
	Assets         []string `json:"assets"`
	IsEntry        bool     `json:"isEntry"`
	IsDynamicEntry bool     `json:"isDynamicEntry"`
	Imports        []string `json:"imports"`
	DynamicImports []string `json:"dynamicImports"`
}

ManifestEntry is the subset of the Vite ManifestChunk the validator reads. Imports/DynamicImports carry MANIFEST KEYS (not file paths) referring to other chunks; both are validated for existence.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL