Issues (39)

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.

Service/Credentials/CredentialsGenerator.php (1 issue)

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
 * This file is part of the FreshCentrifugoBundle.
4
 *
5
 * (c) Artem Henvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Fresh\CentrifugoBundle\Service\Credentials;
14
15
use Fresh\CentrifugoBundle\Service\Jwt\JwtGenerator;
16
use Fresh\CentrifugoBundle\Token\JwtPayload;
17
use Fresh\CentrifugoBundle\Token\JwtPayloadForPrivateChannel;
18
use Fresh\CentrifugoBundle\User\CentrifugoUserInterface;
19
use Fresh\DateTime\DateTimeHelper;
20
21
/**
22
 * CredentialsGenerator.
23
 *
24
 * @author Artem Henvald <[email protected]>
25
 */
26
class CredentialsGenerator
27
{
28
    private JwtGenerator $jwtGenerator;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
29
    private DateTimeHelper $dateTimeHelper;
30
    private ?int $centrifugoJwtTtl;
31
32
    /**
33
     * @param JwtGenerator   $jwtGenerator
34
     * @param DateTimeHelper $dateTimeHelper
35
     * @param int|null       $centrifugoJwtTtl
36
     */
37
    public function __construct(JwtGenerator $jwtGenerator, DateTimeHelper $dateTimeHelper, ?int $centrifugoJwtTtl = null)
38
    {
39
        $this->jwtGenerator = $jwtGenerator;
40
        $this->dateTimeHelper = $dateTimeHelper;
41
        $this->centrifugoJwtTtl = $centrifugoJwtTtl;
42
    }
43
44
    /**
45
     * @param CentrifugoUserInterface $user
46
     * @param string|null             $base64info
47
     * @param array                   $channels
48
     *
49
     * @return string
50
     */
51
    public function generateJwtTokenForUser(CentrifugoUserInterface $user, ?string $base64info = null, array $channels = []): string
52
    {
53
        $jwtPayload = new JwtPayload(
54
            $user->getCentrifugoSubject(),
55
            $user->getCentrifugoUserInfo(),
56
            $this->getExpirationTime(),
57
            $base64info,
58
            $channels
59
        );
60
61
        return $this->jwtGenerator->generateToken($jwtPayload);
62
    }
63
64
    /**
65
     * @param string|null $base64info
66
     * @param array       $channels
67
     *
68
     * @return string
69
     */
70
    public function generateJwtTokenForAnonymous(?string $base64info = null, array $channels = []): string
71
    {
72
        $jwtPayload = new JwtPayload(
73
            '',
74
            [],
75
            $this->getExpirationTime(),
76
            $base64info,
77
            $channels
78
        );
79
80
        return $this->jwtGenerator->generateToken($jwtPayload);
81
    }
82
83
    /**
84
     * @param string      $client
85
     * @param string      $channel
86
     * @param string|null $base64info
87
     * @param bool|null   $eto
88
     *
89
     * @return string
90
     */
91
    public function generateJwtTokenForPrivateChannel(string $client, string $channel, ?string $base64info = null, ?bool $eto = null): string
92
    {
93
        $jwtPayload = new JwtPayloadForPrivateChannel(
94
            $client,
95
            $channel,
96
            [],
97
            $this->getExpirationTime(),
98
            $base64info,
99
            $eto
100
        );
101
102
        return $this->jwtGenerator->generateToken($jwtPayload);
103
    }
104
105
    /**
106
     * @return int|null
107
     */
108
    private function getExpirationTime(): ?int
109
    {
110
        $expireAt = null;
111
112
        if (null !== $this->centrifugoJwtTtl) {
113
            $now = $this->dateTimeHelper->getCurrentDatetime();
114
            $now->add(new \DateInterval("PT{$this->centrifugoJwtTtl}S"));
115
            $expireAt = $now->getTimestamp();
116
        }
117
118
        return $expireAt;
119
    }
120
}
121