One small crate for the checks that must run before an archive or XML parser touches a file the app did not write, following craft-libs#126. - Budget/Exceeded: a named limit and a running total of real bytes, charged before allocating, reporting the name, limit and request on a breach. - zip::preflight: allocation-free validation of the end records and the central directory before ZipArchive::new indexes every entry. Exactly one end record must span the end of the file (ambiguous records are refused); the ZIP64 record and locator are checked against each other; entry count, directory size and name lengths are limited; the directory must fill its declared size and reach the end records. Single-disk only; malformed input is an error, never a panic. - zip::read_entry: bounds one entry against the per-entry limit, a fixed preallocation and the total budget, charges only bytes actually read, and reports a lying declared size or a decompression bomb as an overrun. - xml::check: one iterative linear pass that measures nesting (comments, CDATA, processing instructions and quoted values cannot fake a tag) and applies a DTD policy, so a recursive parser never sees input that would exhaust the stack. xml::Depth does the same for readers that count as they parse. Zero dependencies, no unsafe, no numbers of the crate's own. Tests cover bombs, lying declared sizes, entry-count and directory-size caps, lying EOCD counts, truncation, ZIP64 variants, DTD policies, quote/comment/CDATA confusion, the depth boundary and a 250k-deep hostile document.
3.4 KiB
Craft App Libraries
This repo contains libraries used by the various Craft Apps. It's a Rust monorepo workspace, and the libraries can be included by any Craft Apps that need them.
In the future this may grow to include non-Rust library code.
If any libraries grow beyond Craft App usage, eg. RAW format support, they may be promoted out and into their own libraries for the broader ecosystem to take advantage of.
Layout
A Cargo workspace (edition 2024, resolver 3). Each library is a crate under crates/<name>, named
craft-<name>, with version, edition, license and repository inherited from the workspace
(license.workspace = true, and so on) and [lints] workspace = true. Register each crate in
[workspace.dependencies] in the root Cargo.toml.
Apps depend on a crate by git:
craft-<name> = { git = "https://github.com/storytold/craft-libs", rev = "<commit>" }
Libraries
-
craft-atomic: Crash-safe atomic file writing and replacement with same-directory staging, directory fsync, AppleF_FULLFSYNCfallback, transient lock backoff, and fault injection for the Craft suite. -
craft-archive: parsing budgets for untrusted ZIP archives and XML: an allocation-free ZIP end-record/central-directory preflight, bounded entry reads with a shared byteBudget, and a one-pass XML nesting/DTD check that runs before recursive parsers. -
craft-cms: pure-Rust ICC v2/v4 colour management: profile parsing and writing, transforms, rendering intents, black point compensation, soft proofing, gamut checks, 3D LUTs and built-in profiles (sRGB, Display P3, synthetic coated CMYK and others). -
craft-print: PDF submission to CUPS and Windows, printer discovery, duplex/copies/colour and driver preferences. PDF generation stays in each app. -
craft-quit: native macOS quit, egui close handling and an optional app menu. Unsaved-document decisions and save prompts stay in each app. -
craft-settings:config.tomlsettings storage for every app: platform folders, portable mode and overrides, atomic saves while running, backup, damaged-file recovery and schema migrations. Policy in docs/settings-storage.md. -
craft-ui: SVG catalogs, icon buttons, tabs, pane controls, transactional docking, print settings and theme helpers for egui frontends; assets, themes, localization and command handling stay in each app. Requires Rust 1.95 or later. -
Shared UI component audit: source inventory, extraction priorities and compatibility boundaries across the Craft suite.
-
Theme infrastructure: eight-app comparison and the small shared widget-state styling boundary.
-
Panel docking: validated panel moves, floating groups, workspace adapters and an optional egui docking surface.
License and credits
craft-libs is dual-licensed under MIT or Apache-2.0, at your option. Copyright (c) 2026 ArtCraft Team and the craft-libs contributors. Required notices are in NOTICE.
Bundled fonts, icons, images and other assets keep their own open licenses; each one is listed with its author, source and license in ATTRIBUTION.md.