Provided by: lintian_2.48.0_all bug

NAME

       Lintian::Info::Package - Lintian base interface to binary and source package data
       collection

SYNOPSIS

           use Lintian::Processable;
           my $processable = Lintian::Processable::Binary->new;

DESCRIPTION

       Lintian::Info::Package provides an interface to package data for source and binary
       packages.  It implements data collection methods specific to packages that can be unpacked
       (or can contain files)

INSTANCE METHODS

       unpacked ([FILE])
           Returns the path to the directory in which the package has been unpacked.  FILE must
           be either a Lintian::Path object (>= 2.5.13~) or a string denoting the requested path.
           In the latter case, the path must be relative to the root of the package and should be
           normalized.

           It is not permitted for FILE to be "undef".  If the "root" dir is desired either
           invoke this method without any arguments at all, pass it the correct Lintian::Path or
           the empty string.

           If FILE is not in the package, it returns the path to a non-existent file entry.

           The path returned is not guaranteed to be inside the Lintian Lab as the package may
           have been unpacked outside the Lab (e.g. as optimization).

           Caveat with symlinks: Package is extracted as is and the path returned by this method
           points to the extracted file object.  If this is a symlink, it may "escape the root"
           and point to a file outside the lab (and a path traversal).

           The following code may be helpful in checking for path traversal:

            use Lintian::Util qw(is_ancestor_of);

            my $collect = ... ;
            my $file = '../../../etc/passwd';
            my $uroot = $collect->unpacked;
            my $ufile = $collect->unpacked($file);
            # $uroot will exist, but $ufile might not.
            if ( -e $ufile && is_ancestor_of($uroot, $ufile)) {
               # has not escaped $uroot
               do_stuff($ufile);
            } elsif ( -e $ufile) {
               # escaped $uroot
               die "Possibly path traversal ($file)";
            } else {
               # Does not exists
            }

           Alternatively one can use normalize_pkg_path in Lintian::Util or link_normalized.

           To get a list of entries in the package or the file meta data of the entries (as path
           objects), see "sorted_index" and "index (FILE)".

           Needs-Info requirements for using unpacked: unpacked

       sorted_index
           Returns a sorted array of file names listed in the package.  The names will not have a
           leading slash (or "./") and can be passed to "unpacked ([FILE])" or "index (FILE)" as
           is.

           The array will not contain the entry for the "root" of the package.

           NB: For source packages, please see the "index"-caveat.

           Needs-Info requirements for using sorted_index: Same as index

       index_resolved_path(PATH)
           Resolve PATH (relative to the root of the package) and return the entry denoting the
           resolved path.

           The resolution is done using resolve_path.

           NB: For source packages, please see the "index"-caveat.

           Needs-Info requirements for using index_resolved_path: Same as index

AUTHOR

       Originally written by Niels Thykier <niels@thykier.net> for Lintian.

SEE ALSO

       lintian(1), Lintian::Collect, Lintian::Collect::Binary, Lintian::Collect::Source