Skip to main content

Module util

Module util 

Source
Expand description

Small, I/O-free helpers shared across the workspace.

These were independently re-implemented in the monitors, fs, cli, napi and checks crates (RFC3339 time formatting, epoch-millis parsing, path.basename, the unix “group/other-accessible” permission test). Centralizing them here keeps one source of truth so the behaviors cannot drift apart.

Functions§

basename
Final path component - port of Node’s path.basename. Trailing slashes are trimmed first ("a/b/" -> "b"); a path with no separator returns itself.
is_group_or_other_accessible
True if a unix permission mode grants any group or other access (mode & 0o077 != 0) - the credential-permission red flag used by the checks, hardening and credential monitor. mode is the permission bits, already masked to 0o777 by the caller.
now_iso
Current UTC time as an RFC3339 string - the Rust equivalent of TS new Date().toISOString() (PRODUCT.md A.5 wire format). On the (impossible) formatting error, falls back to the epoch so an audit never aborts over a clock.
now_ms
Current UTC time as epoch milliseconds.
parse_ms
Parse an RFC3339 timestamp to epoch milliseconds. Returns None for unparseable input (callers exclude such entries, matching the TS tool).