NAME

Langertha::Raider::PathConfine - Internal keeper of the directories the file and search tools may reach

VERSION

version 0.504

SYNOPSIS

# Internal to Langertha-Raider -- no API promise.
my $confine = Langertha::Raider::PathConfine->new(
  root        => $real_root,                  # a real absolute directory
  extra_roots => sub { [ '/other/dir' ] },    # list, ArrayRef or CodeRef
  confine     => sub { 1 },                   # value or CodeRef
);
die "Path escapes root\n" unless $confine->allows($real_path);

DESCRIPTION

Internal module. Its interface may change without notice.

The one place that says which real paths Langertha::Raider::FileTools and Langertha::Raider::SearchTools may reach (ADR 0023): the root, the additional directories ("extra_roots") and whether the tools are confined at all ("confine"). Both tools used to carry their own copy.

root

The real absolute path of the root directory. Without one nothing is confined.

extra_roots

More directories besides "root": an ArrayRef, or a CodeRef returning the list (or one ArrayRef), asked on every call. One that cannot be resolved (realpath finds no existing parent) is left out; with "dirs_only" so is one that is not a directory.

confine

True by default. False (or a CodeRef answering false, asked on every call) lets every path through -- the Claude layout, where the permission gate asks.

dirs_only

True: an additional directory counts only when it is a directory.

confined

True when the tools are confined right now.

real_extra_roots

The additional directories as real absolute paths, read on every call.

allows

$confine->allows($real_path);

True when $real_path lies inside the root or an additional directory, or when nothing confines.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-raider/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

https://raudssus.de/