Secure version of IO::Path.child
Perl6
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/IO/Path
logotype
t
.gitignore
.travis.yml
LICENSE
META6.json
README.md

README.md

Build Status

NAME

IO::Path::ChildSecure -Secure version of IO::Path.child

SYNOPSIS

    use IO::Path::ChildSecure;

    # good; you get IO::Path
    "foo".IO.&child-secure: 'meow';

    # still good if 'foo/meow/foo/bar/../' exists; Failure if it doesn't
    "foo".IO.&child-secure: 'meow/foo/bar/../meow';

    # bad; path isn't a child; you get Failure
    "foo".IO.&child-secure: '../';

DESCRIPTION

In 6.c Perl 6 language, IO::Path.child isn't secure, in a sense that it does no checks for whether the resultant path is actually a child of the original path. It will be made secure in 6.d language, but in the meantime you can use another method provided by this module!

EXPORTED SUBROUTINES

&child-secure

    "foo".IO.&child-secure: 'meow'; # good; you get IO::Path
    "foo".IO.&child-secure: 'meow/foo/bar/../meow'; # still good
    "foo".IO.&child-secure: '../';  # bad; path isn't a child; you get Failure

    child-secure "foo".IO, '../';  # can also use as a proper sub

Appends the given path chunk to the invocant and ensures the resultant path is, in fact, a child of the invocant, by accessing the filesystem and fully-resolving the path. The last chunk of the resultant path does not have to exist for the resolution to succeed.

Will fail with X::IO::Resolve if failed to fully resolve the resultant path or with X::IO::NotAChild if the resultant path is not a child of the invocant.

SPECIAL NOTES

  • Module requires Rakudo 2017.04 or newer and will die on earlier versions (more specifically, anything earlier than dev version v2017.03.292.g.0.b.5.a.41.ba.8)
  • If you don't need to ensure secureness, use the much-faster core IO::Path.add method

REPOSITORY

Fork this module on GitHub: https://github.com/zoffixznet/perl6-IO-Path-ChildSecure

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/perl6-IO-Path-ChildSecure/issues

AUTHOR

Zoffix Znet (http://perl6.party/)

LICENSE

You can use and distribute this module under the terms of the The Artistic License 2.0. See the LICENSE file included in this distribution for complete details.

The META6.json file of this distribution may be distributed and modified without restrictions or attribution.