Commit graph jw-pkg/test/unit/python/jw/pkg/lib/FileContext
Author SHA1 Message Date
c2c8db2737
lib.FileContext: Limit accessible addresses
Allow to attach a default path filter to a FileContext, given in the
constructor as default_path_filter, or in the URI query as "path-filter".
Passing False as default_path_filter will make the FileContext ignore any
path-filter in the query.

The filter is created lazily on first use through PathFilter.create(), so a
string spec is loaded from the lib.pf module like any other filter.

Every path based action evaluates the filter before it is carried out.
An IGNORE verdict is logged and the action is skipped: reads and stats
raise FileNotFoundError, writes, unlinks, erases, renames, and mkdirs are
no-ops, and readdir() drops the filtered entries. An ABORT verdict raises
PermissionError.

Every path-driven method also takes a flag parameter, "filtered",
defaulting to True, so a caller that must work regardless of the context's
filter can opt out of the check.

Add a unit test that exercises the verdicts, the filtered bypass, and the
distribution probe on a Local context.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
2026-11-07 16:49:24 +01:00