Issues (12)

Security Analysis    not enabled

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.

tests/LogViewer/LogServiceTest.php (4 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
namespace Spiral\Tests\LogViewer;
4
5
use Psr\Log\LogLevel;
6
use Spiral\Debug\Traits\LoggerTrait;
7
use Spiral\LogViewer\Entities\LogFile;
8
use Spiral\LogViewer\Services\LogService;
9
use Spiral\Tests\HttpTest;
10
11
class LogServiceTest extends HttpTest
12
{
13
    use LoggerTrait;
14
15
    /**
16
     * Can get all logs.
17
     */
18 View Code Duplication
    public function testGetLogs()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        /** @var LogService $service */
21
        $service = $this->container->get(LogService::class);
22
23
        $this->assertCount(0, $service->getLogs());
24
25
        $snapshot = $this->makeSnapshot('error', 123);
26
        $snapshot->report();
27
28
        $this->assertCount(1, $service->getLogs());
29
30
        $this->get('/controller/action');
31
        $this->assertCount(2, $service->getLogs());
32
33
        $log = current($service->getLogs()->iterate());
34
        $this->assertInstanceOf(LogFile::class, $log);
35
    }
36
37
    /**
38
     * Take really last log.
39
     */
40 View Code Duplication
    public function testLastLog()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        /** @var LogService $service */
43
        $service = $this->container->get(LogService::class);
44
45
        $this->assertEmpty($service->lastLog());
46
47
        $snapshot = $this->makeSnapshot('error', 123);
48
        $snapshot->report();
49
50
        /** @var LogFile $last */
51
        $last = $service->lastLog();
52
53
        $this->assertNotEmpty($last);
54
        $this->assertInstanceOf(LogFile::class, $last);
55
56
        sleep(1);
57
        $this->get('/controller/action');
58
59
        /** @var LogFile $last2 */
60
        $last2 = $service->lastLog();
61
        $this->assertNotEmpty($last2);
62
63
        $this->assertNotEquals($last->name(), $last2->name());
64
    }
65
66
    /**
67
     * Get log by name is really what we want
68
     */
69 View Code Duplication
    public function testGetLogByName()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
    {
71
        /** @var LogService $service */
72
        $service = $this->container->get(LogService::class);
73
74
        $snapshot = $this->makeSnapshot('error', 123);
75
        $snapshot->report();
76
77
        $this->assertEmpty($service->getLogByName('some-name'));
78
79
        /** @var LogFile $last */
80
        $last = $service->lastLog();
81
        $this->assertNotEmpty($last);
82
83
        $log = $service->getLogByName($last->name());
84
85
        $this->assertNotEmpty($log);
86
        $this->assertInstanceOf(LogFile::class, $log);
87
88
        $this->assertEquals($last->name(), $log->name());
89
    }
90
91
    /**
92
     * Remove all logs
93
     */
94 View Code Duplication
    public function testRemoveAll()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
95
    {
96
        /** @var LogService $service */
97
        $service = $this->container->get(LogService::class);
98
99
        $this->assertCount(0, $service->getLogs());
100
101
        $snapshot = $this->makeSnapshot('error', 123);
102
        $snapshot->report();
103
104
        $this->assertCount(1, $service->getLogs());
105
106
        $this->get('/controller/action');
107
        $this->assertCount(2, $service->getLogs());
108
109
        $service->removeAll();
110
111
        $this->assertEmpty($service->getLogs());
112
    }
113
114
    /**
115
     * Remove
116
     */
117
    public function testRemove()
118
    {
119
        /** @var LogService $service */
120
        $service = $this->container->get(LogService::class);
121
122
        $this->assertCount(0, $service->getLogs());
123
124
        $snapshot = $this->makeSnapshot('error', 123);
125
        $snapshot->report();
126
127
        $this->assertCount(1, $service->getLogs());
128
129
        /** @var LogFile $last */
130
        $last = $service->lastLog();
131
        $this->assertNotEmpty($last);
132
133
        $service->removeLog(new LogFile('some-name'));
134
135
        $this->assertCount(1, $service->getLogs());
136
137
        $service->removeLog($last);
138
139
        $this->assertEmpty($service->getLogs());
140
    }
141
}