Issues (32)

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.

Manager/TokenManager.php (1 issue)

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 Yokai\SecurityTokenBundle\Manager;
4
5
use DateTime;
6
use Yokai\SecurityTokenBundle\Entity\Token;
7
use Yokai\SecurityTokenBundle\EventDispatcher;
8
use Yokai\SecurityTokenBundle\Exception\TokenExpiredException;
9
use Yokai\SecurityTokenBundle\Exception\TokenNotFoundException;
10
use Yokai\SecurityTokenBundle\Exception\TokenConsumedException;
11
use Yokai\SecurityTokenBundle\Factory\TokenFactoryInterface;
12
use Yokai\SecurityTokenBundle\InformationGuesser\InformationGuesserInterface;
13
use Yokai\SecurityTokenBundle\Repository\TokenRepositoryInterface;
14
15
/**
16
 * @author Yann Eugoné <[email protected]>
17
 */
18
class TokenManager implements TokenManagerInterface
19
{
20
    /**
21
     * @var TokenFactoryInterface
22
     */
23
    private $factory;
24
25
    /**
26
     * @var TokenRepositoryInterface
27
     */
28
    private $repository;
29
30
    /**
31
     * @var InformationGuesserInterface
32
     */
33
    private $informationGuesser;
34
35
    /**
36
     * @var UserManagerInterface
37
     */
38
    private $userManager;
39
40
    /**
41
     * @var EventDispatcher
42
     */
43
    private $eventDispatcher;
44
45
    /**
46
     * @param TokenFactoryInterface       $factory            The token factory
47
     * @param TokenRepositoryInterface    $repository         The token repository
48
     * @param InformationGuesserInterface $informationGuesser The information guesser
49
     * @param UserManagerInterface        $userManager        The user manager
50
     * @param EventDispatcher             $eventDispatcher    The event dispatcher
51
     */
52 7
    public function __construct(
53
        TokenFactoryInterface $factory,
54
        TokenRepositoryInterface $repository,
55
        InformationGuesserInterface $informationGuesser,
56
        UserManagerInterface $userManager,
57
        EventDispatcher $eventDispatcher
58
    ) {
59 7
        $this->factory = $factory;
60 7
        $this->repository = $repository;
61 7
        $this->informationGuesser = $informationGuesser;
62 7
        $this->userManager = $userManager;
63 7
        $this->eventDispatcher = $eventDispatcher;
64 7
    }
65
66
    /**
67
     * @inheritdoc
68
     */
69 4
    public function get($purpose, $value)
70
    {
71
        try {
72 4
            $token = $this->repository->get($value, $purpose);
73 3
        } catch (TokenNotFoundException $exception) {
74 1
            $this->eventDispatcher->tokenNotFound($purpose, $value);
75
76 1
            throw $exception;
77 2
        } catch (TokenExpiredException $exception) {
78 1
            $this->eventDispatcher->tokenExpired($purpose, $value);
79
80 1
            throw $exception;
81 1
        } catch (TokenConsumedException $exception) {
82 1
            $this->eventDispatcher->tokenAlreadyConsumed($purpose, $value);
83
84 1
            throw $exception;
85
        }
86
87 1
        $this->eventDispatcher->tokenRetrieved($token);
88
89 1
        return $token;
90
    }
91
92
    /**
93
     * @inheritdoc
94
     */
95 1
    public function create($purpose, $user, array $payload = [])
96
    {
97 1
        $event = $this->eventDispatcher->createToken($purpose, $user, $payload);
98
99 1
        $token = $this->factory->create($user, $purpose, $event->getPayload());
100
101 1
        $this->repository->create($token);
102
103 1
        $this->eventDispatcher->tokenCreated($token);
104
105 1
        return $token;
106
    }
107
108
    /**
109
     * @inheritdoc
110
     */
111
    public function setUsed(Token $token, DateTime $at = null)
112
    {
113
        @trigger_error(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
114
            'The '.__METHOD__
115
            .' method is deprecated since version 2.2 and will be removed in 3.0. Use the consume() method instead.',
116
            E_USER_DEPRECATED
117
        );
118
119
        $this->consume($token, $at);
120
    }
121
122
    /**
123
     * @inheritDoc
124
     */
125 1
    public function consume(Token $token, DateTime $at = null)
126
    {
127 1
        $event = $this->eventDispatcher->consumeToken($token, $at, $this->informationGuesser->get());
128
129 1
        $token->consume($event->getInformation(), $at);
130
131 1
        $this->repository->update($token);
132
133 1
        $this->eventDispatcher->tokenConsumed($token);
134 1
        if ($token->isConsumed()) {
135 1
            $this->eventDispatcher->tokenTotallyConsumed($token);
136
        }
137 1
    }
138
139
    /**
140
     * @inheritdoc
141
     */
142 1
    public function getUser(Token $token)
143
    {
144 1
        return $this->userManager->get($token->getUserClass(), $token->getUserId());
145
    }
146
}
147