Issues (28)

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/Core/Definitions.php (25 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
 * Main definition for Assertion. Define core methods and properties here.
4
 */
5
use Peridot\Leo\Assertion;
6
use Peridot\Leo\Matcher\EmptyMatcher;
7
use Peridot\Leo\Matcher\EqualMatcher;
8
use Peridot\Leo\Matcher\ExceptionMatcher;
9
use Peridot\Leo\Matcher\InclusionMatcher;
10
use Peridot\Leo\Matcher\InstanceofMatcher;
11
use Peridot\Leo\Matcher\KeysMatcher;
12
use Peridot\Leo\Matcher\LengthMatcher;
13
use Peridot\Leo\Matcher\NullMatcher;
14
use Peridot\Leo\Matcher\PatternMatcher;
15
use Peridot\Leo\Matcher\PredicateMatcher;
16
use Peridot\Leo\Matcher\PropertyMatcher;
17
use Peridot\Leo\Matcher\RangeMatcher;
18
use Peridot\Leo\Matcher\SameMatcher;
19
use Peridot\Leo\Matcher\SubStringMatcher;
20
use Peridot\Leo\Matcher\TrueMatcher;
21
use Peridot\Leo\Matcher\TruthyMatcher;
22
use Peridot\Leo\Matcher\TypeMatcher;
23
24
return function (Assertion $assertion) {
25
    /*
26
     * Default language chains.
27
     */
28
    $chains = [
29
        'to', 'be', 'been',
30
        'is', 'and', 'has',
31
        'have', 'with', 'that',
32
        'at', 'of', 'same',
33
        'an', 'a',
34
    ];
35
36
    foreach ($chains as $chain) {
37
        $assertion->addProperty($chain, function () {
38
            return $this;
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
39
        }, true);
40
    }
41
42
    $assertion->addProperty('not', function () {
43
        return $this->flag('not', true);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
44
    });
45
46
    $assertion->addMethod('with', function () {
47
        return $this->flag('arguments', func_get_args());
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
48
    });
49
50
    $assertion->addProperty('loosely', function () {
51
        return $this->flag('loosely', true);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
52
    });
53
54
    $assertion->addMethod('equal', function ($expected, $message = '') {
55
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
56
        if ($this->flag('loosely')) {
57
            return new EqualMatcher($expected);
58
        }
59
60
        return new SameMatcher($expected);
61
    });
62
63
    $assertion->addMethod('throw', function ($exceptionType, $exceptionMessage = '', $message = '') {
64
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
65
        $matcher = new ExceptionMatcher($exceptionType);
66
        $matcher->setExpectedMessage($exceptionMessage);
67
        $matcher->setArguments($this->flag('arguments') ?: []);
68
69
        return $matcher;
70
    });
71
72
    $type = function ($expected, $message = '') {
73
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
74
75
        return new TypeMatcher($expected);
76
    };
77
78
    $assertion
79
        ->addMethod('a', $type)
80
        ->addMethod('an', $type);
81
82
    $include = function ($expected, $message = '') {
83
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
84
85
        return new InclusionMatcher($expected);
86
    };
87
88
    $assertion
89
        ->addMethod('include', $include)
90
        ->addMethod('contain', $include);
91
92
    $contain = function () {
93
        return $this->flag('contain', true);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
94
    };
95
96
    $assertion
97
        ->addProperty('contain', $contain)
98
        ->addProperty('include', $contain);
99
100
    $truthy = function ($message = '') {
101
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
102
103
        return new TruthyMatcher();
104
    };
105
106
    $assertion
107
        ->addMethod('ok', $truthy)
108
        ->addProperty('ok', $truthy);
109
110
    $true = function ($message = '') {
111
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
112
113
        return new TrueMatcher();
114
    };
115
116
    $assertion
117
        ->addMethod('true', $true)
118
        ->addProperty('true', $true);
119
120
    $false = function ($message = '') {
121
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
122
        $matcher = new TrueMatcher();
123
124
        return $matcher->invert();
125
    };
126
127
    $assertion
128
        ->addMethod('false', $false)
129
        ->addProperty('false', $false);
130
131
    $null = function ($message = '') {
132
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
133
134
        return new NullMatcher();
135
    };
136
137
    $assertion
138
        ->addMethod('null', $null)
139
        ->addProperty('null', $null);
140
141
    $empty = function ($message = '') {
142
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
143
144
        return new EmptyMatcher();
145
    };
146
147
    $assertion
148
        ->addMethod('empty', $empty)
149
        ->addProperty('empty', $empty);
150
151
    $assertion->addProperty('length', function () {
152
        return $this->flag('length', $this->getActual());
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
153
    });
154
155
    /*
156
     * Define a helper for creating countable matchers. A countable
157
     * matcher is a matcher that matches against a single numeric
158
     * value, or a value that can be reduced to a single numeric value
159
     * via the count() function.
160
     *
161
     * @param $className
162
     * @return callable
163
     */
164
    $countable = function ($className) {
165
        return function ($expected, $message = '') use ($className) {
166
            $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
167
            $class = "Peridot\\Leo\\Matcher\\$className";
168
            $matcher = new $class($expected);
169
            if ($countable = $this->flag('length')) {
170
                $matcher->setCountable($countable);
171
            }
172
173
            return $matcher;
174
        };
175
    };
176
177
    $assertion->addMethod('above', $countable('GreaterThanMatcher'));
178
    $assertion->addMethod('least', $countable('GreaterThanOrEqualMatcher'));
179
    $assertion->addMethod('below', $countable('LessThanMatcher'));
180
    $assertion->addMethod('most', $countable('LessThanOrEqualMatcher'));
181
182
    $assertion->addMethod('within', function ($lower, $upper, $message = '') {
183
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
184
        $matcher = new RangeMatcher($lower, $upper);
185
        if ($countable = $this->flag('length')) {
186
            $matcher->setCountable($countable);
187
        }
188
189
        return $matcher;
190
    });
191
192
    $assertion->addMethod('instanceof', function ($expected, $message = '') {
193
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
194
195
        return new InstanceofMatcher($expected);
196
    });
197
198
    $assertion->addProperty('deep', function () {
199
        return $this->flag('deep', true);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
200
    });
201
202
    $assertion->addMethod('property', function ($name, $value = '', $message = '') {
203
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
204
        $matcher = new PropertyMatcher($name, $value);
205
        $matcher->setAssertion($this);
206
207
        return $matcher->setIsDeep($this->flag('deep'));
208
    });
209
210
    $assertion->addMethod('length', function ($expected, $message = '') {
211
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
212
213
        return new LengthMatcher($expected);
214
    });
215
216
    $assertion->addMethod('match', function ($pattern, $message = '') {
217
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
218
219
        return new PatternMatcher($pattern);
220
    });
221
222
    $assertion->addMethod('string', function ($expected, $message = '') {
223
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
224
225
        return new SubStringMatcher($expected);
226
    });
227
228
    $assertion->addMethod('keys', function (array $keys, $message = '') {
229
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
230
231
        return new KeysMatcher($keys);
232
    });
233
234
    $assertion->addMethod('satisfy', function (callable $predicate, $message = '') {
235
        $this->flag('message', $message);
0 ignored issues
show
The variable $this does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
236
237
        return new PredicateMatcher($predicate);
238
    });
239
};
240