Issues (1)

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/Module.php (1 issue)

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
namespace mindplay\walkway;
4
5
use Closure;
6
7
/**
8
 * This class represents the root of an independent collection of Routes.
9
 *
10
 * @see Route
11
 */
12
class Module extends Route
13
{
14
    /**
15
     * A map of regular expression pattern substitutions to apply to every
16
     * pattern encountered, as a means fo pre-processing patterns. Provides a
17
     * useful means of adding your own custom patterns for convenient reuse.
18
     *
19
     * @var Closure[] map where full regular expression => substitution closure
20
     *
21
     * @see $symbols
22
     * @see preparePattern()
23
     * @see init()
24
     */
25
    public $substitutions = array();
26
27
    /**
28
     * Symbols used by the built-in standard substitution pattern, which provides
29
     * a convenient short-hand syntax for placeholder tokens. The built-in standard
30
     * symbols are:
31
     *
32
     * <pre>
33
     *     'int'  => '\d+'
34
     *     'slug' => '[a-z0-9-]+'
35
     * </pre>
36
     *
37
     * Which provides support for simplified named routes, such as:
38
     *
39
     * <pre>
40
     *     'user/<user_id:int>'
41
     *     'tags/<tag:slug>'
42
     * </pre>
43
     *
44
     * For which the resulting patterns would be:
45
     *
46
     * <pre>
47
     *     'user/(?<user_id:\d+>)'
48
     *     'tags/(?<slug:[a-z0-9-]>)'
49
     * </pre>
50
     *
51
     * @var string[] map where symbol name => partial regular expression
52
     *
53
     * @see init()
54
     */
55
    public $symbols = array();
56
57
    /**
58
     * @var Closure|null event-handler for diagnostic messages
59
     */
60
    public $onLog = null;
61
62
    /**
63
     * @var InvokerInterface
64
     */
65
    public $invoker;
66
67
    /**
68
     * @param InvokerInterface|null $invoker optional custom invoker
69
     */
70 1
    public function __construct(InvokerInterface $invoker = null)
71
    {
72 1
        $this->module = $this;
73 1
        $this->invoker = $invoker ?: $this->createDefaultInvoker();
74
75 1
        $this->init();
76 1
    }
77
78
    /**
79
     * Prepares a regular expression pattern by applying the patterns and callbacks
80
     * defined by {@link $substitutions} to it.
81
     *
82
     * @param string $pattern unprocessed pattern
83
     *
84
     * @return string pre-processed pattern
85
     *
86
     * @throws RoutingException if the regular expression fails to execute
87
     */
88 1
    public function preparePattern($pattern)
89
    {
90 1
        foreach ($this->substitutions as $subpattern => $fn) {
91 1
            $pattern = @preg_replace_callback($subpattern, $fn, $pattern);
92
93 1
            if ($pattern === null) {
94 1
                throw new RoutingException("invalid substitution pattern: {$subpattern}");
95
            }
96 1
        }
97
98 1
        return $pattern;
99
    }
100
101
    /**
102
     * Initialize the Module upon construction - override as needed.
103
     */
104 1
    protected function init()
105
    {
106 1
        $module = $this;
107
108 1
        $this->vars['route'] = $this;
109 1
        $this->vars['module'] = $this;
110
111
        // define a default pattern-substitution with support for some common symbols:
112
113 1
        $this->substitutions['/(?<!\(\?)<([^\:]+)\:([^>]+)>/'] = function ($matches) use ($module) {
114 1
            if (isset($module->symbols[$matches[2]])) {
115 1
                $matches[2] = $module->symbols[$matches[2]];
116 1
            }
117
118 1
            return "(?<{$matches[1]}>{$matches[2]})";
119
        };
120
121
        // define common symbols for the default pattern-substitution:
122
123 1
        $this->symbols = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array('int' => '\\d+', 'slug' => '[a-z0-9-]+') of type array<string,string,{"in...ring","slug":"string"}> is incompatible with the declared type array<integer,string> of property $symbols.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
124 1
            'int'  => '\d+',
125 1
            'slug' => '[a-z0-9-]+',
126
        );
127 1
    }
128
129
    /**
130
     * @return InvokerInterface
131
     */
132 1
    protected function createDefaultInvoker()
133
    {
134 1
        return new Invoker();
135
    }
136
}
137