Issues (76)

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/Logging/JUnit/TestCase.php (2 issues)

Labels
Severity

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
declare(strict_types=1);
4
5
namespace ParaTest\Logging\JUnit;
6
7
/**
8
 * Class TestCase.
9
 *
10
 * A simple data structure for tracking
11
 * the results of a testcase node in a
12
 * JUnit xml document
13
 */
14
class TestCase
15
{
16
    /**
17
     * @var string
18
     */
19
    public $name;
20
21
    /**
22
     * @var string
23
     */
24
    public $class;
25
26
    /**
27
     * @var string
28
     */
29
    public $file;
30
31
    /**
32
     * @var int
33
     */
34
    public $line;
35
36
    /**
37
     * @var int
38
     */
39
    public $assertions;
40
41
    /**
42
     * @var string|float (a stringified float, from phpunit XML output)
43
     */
44
    public $time;
45
46
    /**
47
     * List of failures in this test case.
48
     *
49
     * @var array
50
     */
51
    public $failures = [];
52
53
    /**
54
     * List of errors in this test case.
55
     *
56
     * @var array
57
     */
58
    public $errors = [];
59
60
    /** @var array */
61
    public $skipped = [];
62
63
    /**
64
     * @param string $name
65
     * @param string $class
66
     * @param string $file
67
     * @param int    $line
68
     * @param int    $assertions
69
     * @param string $time
70
     */
71 55
    public function __construct(
72
        string $name,
73
        string $class,
74
        string $file,
75
        int $line,
76
        int $assertions,
77
        string $time
78
    ) {
79 55
        $this->name = $name;
80 55
        $this->class = $class;
81 55
        $this->file = $file;
82 55
        $this->line = $line;
83 55
        $this->assertions = $assertions;
84 55
        $this->time = $time;
85 55
    }
86
87
    /**
88
     * @param string $type
89
     * @param string $text
90
     */
91 49
    public function addFailure(string $type, string $text)
92
    {
93 49
        $this->addDefect('failures', $type, $text);
94 49
    }
95
96
    /**
97
     * @param string $type
98
     * @param string $text
99
     */
100 49
    public function addError(string $type, string $text)
101
    {
102 49
        $this->addDefect('errors', $type, $text);
103 49
    }
104
105
    /**
106
     * @param string $type
107
     * @param string $text
108
     */
109
    public function addSkipped(string $type, string $text)
110
    {
111
        $this->addDefect('skipped', $type, $text);
112
    }
113
114
    /**
115
     * Add a defect type (error or failure).
116
     *
117
     * @param string $collName the name of the collection to add to
118
     * @param $type
119
     * @param $text
120
     */
121 50
    protected function addDefect(string $collName, string $type, string $text)
122
    {
123 50
        $this->{$collName}[] = [
124 50
            'type' => $type,
125 50
            'text' => trim($text),
126
        ];
127 50
    }
128
129
    /**
130
     * Add systemOut result on test (if has failed or have error).
131
     *
132
     * @param mixed $node
133
     *
134
     * @return mixed
135
     */
136 55
    public static function addSystemOut(\SimpleXMLElement $node): \SimpleXMLElement
137
    {
138 55
        $sys = 'system-out';
139
140 55
        if (!empty($node->failure)) {
141 49
            $node->failure = (string) $node->failure . (string) $node->{$sys};
0 ignored issues
show
The property failure does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
142
        }
143
144 55
        if (!empty($node->error)) {
145 49
            $node->error = (string) $node->error . (string) $node->{$sys};
0 ignored issues
show
The property error does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
146
        }
147
148 55
        return $node;
149
    }
150
151
    /**
152
     * Factory method that creates a TestCase object
153
     * from a SimpleXMLElement.
154
     *
155
     * @param \SimpleXMLElement $node
156
     *
157
     * @return TestCase
158
     */
159 55
    public static function caseFromNode(\SimpleXMLElement $node): self
160
    {
161 55
        $case = new self(
162 55
            (string) $node['name'],
163 55
            (string) $node['class'],
164 55
            (string) $node['file'],
165 55
            (int) $node['line'],
166 55
            (int) $node['assertions'],
167 55
            (string) $node['time']
168
        );
169
170 55
        $node = self::addSystemOut($node);
171 55
        $failures = $node->xpath('failure');
172 55
        $skipped = $node->xpath('skipped');
173 55
        $errors = $node->xpath('error');
174
175 55
        foreach ($failures as $fail) {
176 49
            $case->addFailure((string) $fail['type'], (string) $fail);
177
        }
178
179 55
        foreach ($errors as $err) {
180 49
            $case->addError((string) $err['type'], (string) $err);
181
        }
182
183 55
        foreach ($skipped as $skip) {
184
            $case->addSkipped((string) $skip['type'], (string) $skip);
185
        }
186
187 55
        return $case;
188
    }
189
}
190