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.

tests/SlackLoggerTest.php (1 issue)

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
namespace DominionEnterprisesTest\Psr\Log;
4
5
use DominionEnterprises\Psr\Log\SlackLogger;
6
use Psr\Log\LogLevel;
7
8
/**
9
 * @coversDefaultClass \DominionEnterprises\Psr\Log\SlackLogger
10
 * @covers ::__construct
11
 * @covers ::<private>
12
 */
13
final class SlackLoggerTest extends \PHPUnit\Framework\TestCase
14
{
15
    /**
16
     * @var string
17
     */
18
    private $webHookUrl = 'http://localhost/';
19
20
    /**
21
     * Verify behavior of log() when level is not included when constructed.
22
     *
23
     * @test
24
     * @covers ::log
25
     *
26
     * @return void
27
     */
28
    public function logIgnoredLevel()
29
    {
30
        $mock = $this->getMockBuilder('\\GuzzleHttp\\ClientInterface')->getMock();
31
        $mock->method('post')->will(
32
            $this->throwException(new \Exception('post() should not have been called.'))
33
        );
34
        $logger = $this->getLogger($mock);
35
        $this->assertNull($logger->log(LogLevel::INFO, 'test message'));
36
    }
37
38
    /**
39
     * Verify behavior of log() without an execption.
40
     *
41
     * @test
42
     * @covers ::log
43
     *
44
     * @return void
45
     */
46
    public function logWithoutException()
47
    {
48
        $text = '*[emergency]* test message';
49
        $logger = $this->getLogger($this->getGuzzleClientMock($text));
50
        $logger->log(LogLevel::EMERGENCY, 'test message');
51
    }
52
53
    /**
54
     * Verify behavior of log() with Throwable.
55
     *
56
     * @param \Throwable $throwable The exception or error to be logged in the test.
57
     *
58
     * @test
59
     * @covers ::log
60
     * @dataProvider provideThrowables
61
     *
62
     * @return void
63
     */
64
    public function logThrowable(\Throwable $throwable)
65
    {
66
        $text = $this->buildExpectedPayloadText($throwable);
67
        $logger = $this->getLogger($this->getGuzzleClientMock($text));
68
        $logger->log(LogLevel::EMERGENCY, 'test message', ['exception' => $throwable]);
69
    }
70
71
    /**
72
     * Data provider for ensure all types of exceptions can be logged.
73
     *
74
     * @return array
75
     */
76
    public function provideThrowables() : array
77
    {
78
        return [
79
            'runtimeException' => [new \RuntimeException('a runtime exception')],
80
            'typeError' => [new \TypeError('a type error')],
0 ignored issues
show
The call to TypeError::__construct() has too many arguments starting with 'a type error'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
81
        ];
82
    }
83
84
    private function buildExpectedPayloadText(\Throwable $throwable) : string
85
    {
86
        $class = get_class($throwable);
87
        return "*[emergency]* test message\n*Exception:* {$class}\n*Message:* {$throwable->getMessage()}\n*File:*"
88
            . " {$throwable->getFile()}\n*Line:* {$throwable->getLine()}";
89
    }
90
91
    private function getGuzzleClientMock(string $expectedPayloadText)
92
    {
93
        $body = ['payload' => json_encode(['text' => $expectedPayloadText, 'mrkdwn' => true])];
94
        $mock = $this->getMockBuilder('\\GuzzleHttp\\ClientInterface')->getMock();
95
        $mock->expects($this->once())->method('post')->with(
96
            $this->equalTo($this->webHookUrl),
97
            $this->equalTo(['body' => $body])
98
        );
99
100
        return $mock;
101
    }
102
103
    private function getLogger(\GuzzleHttp\ClientInterface $client) : SlackLogger
104
    {
105
        return new SlackLogger($client, $this->webHookUrl);
106
    }
107
}
108