Issues (8)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/FixedFDirectory.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/******************************************************************************
3
 * An iterator interface over the Leagues flysystem.
4
 * Copyright (c) 2021, 2015 Richard Klees <[email protected]>
5
 *
6
 * This software is licensed under GPLv3. You should have received
7
 * a copy of the along with the code.
8
 */
9
10
namespace Lechimp\Flightcontrol;
11
12
abstract class FixedFDirectory /* a */ extends FSObject
13
{
14
    /**
15
     * See documentation of FDirectory.
16
     *
17
     * @return FDirectory<a>
0 ignored issues
show
The doc-type FDirectory<a> could not be parsed: Expected "|" or "end of type", but got "<" at position 10. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
18
     */
19
    abstract public function unfix() : FDirectory;
20
21
    /**
22
     * Get an iterator over the content of this directory.
23
     */
24 18
    public function iterateOn() : Iterator
25
    {
26 18
        return new DirectoryIterator($this);
27
    }
28
29
    /**
30
     * Get an recursor over the content of this directory.
31
     */
32 16
    public function recurseOn() : Recursor
33
    {
34 16
        return new Recursor($this);
35
    }
36
37
    /**
38
     * Get an object that can unfold a directory structure in this directory.
39
     *
40
     * @param   mixed   $start_value
41
     * @throws  \LogicException          If the directory is not empty.
42
     */
43 6
    public function unfold($start_value) : Unfolder
44
    {
45 6
        if (count($this->contents()) > 0) {
46 1
            throw new \LogicException("Can't unfold into non-empty directory '" . $this->path() . "'.");
47
        }
48 5
        return new Unfolder($this, $start_value);
0 ignored issues
show
$this of type object<Lechimp\Flightcontrol\FixedFDirectory> is not a sub-type of object<Lechimp\Flightcontrol\Directory>. It seems like you assume a child class of the class Lechimp\Flightcontrol\FixedFDirectory to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54 51
    public function isFile() : bool
55
    {
56 51
        return false;
57
    }
58
59
    /**
60
     * Only regard contents that match the predicate.
61
     *
62
     * @param   \Closure    $predicate  File|Directory -> bool
63
     */
64 20
    public function filter(\Closure $predicate) : FixedFDirectory
65
    {
66 20
        return new GenericFixedFDirectory(
67 20
            $this->unfix()->filter($predicate)
68
        );
69
    }
70
71
    /**
72
     * Map over the contents of this directory.
73
     *
74
     * @param   \Closure    $trans
75
     */
76 14
    public function map(\Closure $trans) : FixedFDirectory
77
    {
78 14
        return new GenericFixedFDirectory(
79 14
            $this->unfix()->fmap($trans)
80
        );
81
    }
82
83
    /**
84
     * Map the contents this directory.
85
     *
86
     * @param   \Closure    $trans
87
     */
88
    public function outer_map(\Closure $trans) : Directory
89
    {
90
        return new GenericFixedFDirectory(
91
            $this->unfix()->outer_fmap($trans)
92
        );
93
    }
94
95
    /**
96
     * Fold the contents of this directory with a function.
97
     *
98
     * Provide a start value that is fed together with the any content
99
     * of this directory to the function successively to get a new value.
100
     *
101
     * @param   \Closure    $iteration  a -> b -> a
102
     */
103 18
    public function fold($start_value, $iteration) : FixedFDirectory
104
    {
105 18
        return new GenericFixedFDirectory(
106 18
            $this->unfix()->fold($start_value, $iteration)
107
        );
108
    }
109
110
    /**
111
     * Get the the things inside this abstract directory.
112
     *
113
     * @return mixed
114
     */
115 24
    public function contents()
116
    {
117 24
        return $this->unfix()->fcontents();
118
    }
119
120
    /**
121
     * We could also use the catamorphism on this to do recursion, as we
122
     * have an unfix and an underlying fmap from the FDirectory.
123
     *
124
     * Supply a function $trans from File|FDirectory a to a that flattens
125
     * (folds) a directory. Will start the directories where only files are
126
     * included, folds them and then proceeds upwards.
127
     *
128
     * The return type should be 'a' (from the function $trans) instead
129
     * of mixed, but we can't express that fact correctly in the docstring
130
     * typing.
131
     *
132
     * @param   \Closure    $trans      File|FDirectory a -> a
133
     * @return  mixed
134
     */
135 16
    public function cata(\Closure $trans)
136
    {
137 16
        return $this->recurseOn()->cata($trans);
138
    }
139
140
    /**
141
     * Fold over all files in this directory and subjacent
142
     * directories.
143
     *
144
     * Start with an initial value of some type and a function from that type
145
     * and File to a new value of the type. Will successively feed all files
146
     * and the resulting values to that function.
147
     *
148
     * @param   mixed       $start_value
149
     * @param   \Closure    $fold_with      a -> File -> a
150
     * @return Recursor|array
151
     */
152 2
    public function foldFiles($start_value, \Closure $fold_with)
153
    {
154 2
        return $this->recurseOn()->foldFiles($start_value, $fold_with);
155
    }
156
157
    /**
158
     * As we have an unfix and an underlying fmap from FDirectory, we could
159
     * also implement the anamorphism.
160
     *
161
     * An anamorphism creates a structure from a start value and thus somehow
162
     * is the reverse of cata.
163
     *
164
     * You need to provide a function from a to File or FDirectory a. This
165
     * function then is recursively applied on the contents it produces,
166
     * starting with the start value.
167
     *
168
     * @param   \Closure    $unfolder   a -> File|FDirectory a
169
     * @param   mixed       $start_value
170
     */
171 5
    final public static function ana(\Closure $unfolder, $start_value) : FSObject
172
    {
173 5
        $unfolded = $unfolder($start_value);
174 5
        if ($unfolded->isFile()) {
175 5
            return $unfolded;
176
        }
177
178 4
        return new GenericFixedFDirectory(
179 4
            $unfolded->fmap(function ($value) use ($unfolder) {
180 4
                return self::ana($unfolder, $value);
181 4
            })
182
        );
183
    }
184
}
185