Expand description
Module resolution and loading for rule files.
Rules are ES modules. They may import from lanekeep and from each other; nothing else
resolves. There is no node_modules lookup, no bare-specifier resolution, and no way to
reach a file outside the rules root.
§Confinement
The rules root is canonicalized once at construction, and every resolved module is
canonicalized and checked against it. Canonicalizing rather than comparing strings is
what makes the check hold against symlinks: a link inside the root pointing at
/etc/passwd resolves to a path outside the root and is rejected, where a lexical
comparison would see an innocent-looking relative path and allow it.
Traversal is also rejected lexically, before touching the filesystem, so ../../secrets
produces a message about escaping the root rather than a confusing “not found”.
Structs§
- Rule
Loader - Adapts
RuleRootto the engine’s loader interface. - Rule
Resolver - Adapts
RuleRootto the engine’s resolver interface. - Rule
Root - Where rule modules live, and what may be imported.
Enums§
- Resolve
Error - Why a module specifier could not be resolved.
Constants§
- HOST_
MODULE - The specifier that resolves to lanekeep’s own module.
Type Aliases§
- Builtin
Source - Resolves a built-in rule name to its embedded source.
- Loaded
Modules - Every module the loader read, with the source it read.