Issues (5)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Infrastructure/RedisLockerStore.php (2 issues)

1
<?php
2
/**
3
 * This file is part of the LockerManager package.
4
 *
5
 * (c) Mauro Cassani<https://github.com/mauretto78>
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
namespace LockerManager\Infrastructure;
12
13
use Cocur\Slugify\Slugify;
14
use LockerManager\Domain\Lock;
15
use LockerManager\Infrastructure\Exception\ExistingKeyException;
16
use LockerManager\Infrastructure\Exception\NotExistingKeyException;
17
use Predis\Client;
18
19
class RedisLockerStore implements LockerStoreInterface
20
{
21
    const LOCK_LIST_NAME = 'lock-list';
22
23
    /**
24
     * @var Client
25
     */
26
    private $redis;
27
28
    /**
29
     * RedisLockerStore constructor.
30
     * @param Client $redis
31
     */
32
    public function __construct(Client $redis)
33
    {
34
        $this->redis = $redis;
35
    }
36
37
    /**
38
     * @param Lock $lock
39
     * @throws ExistingKeyException
40
     */
41
    public function acquire(Lock $lock)
42
    {
43
        $key = $lock->key();
44
45
        if ($this->redis->hget(self::LOCK_LIST_NAME, $key)) {
46
            throw new ExistingKeyException(sprintf('The key "%s" already exists.', $key));
47
        }
48
49
        $this->saveLock(
50
            $key,
51
            $lock
52
        );
53
    }
54
55
    /**
56
     * @param $key
57
     * @return string
58
     */
59
    private function getLockPath($key)
60
    {
61
        return (new Slugify())->slugify($key);
62
    }
63
64
    /**
65
     * @param $key
66
     * @param Lock $lock
67
     */
68
    private function saveLock($key, Lock $lock)
69
    {
70
        $this->redis->hset(
71
            self::LOCK_LIST_NAME,
72
            $this->getLockPath($key),
73
            serialize($lock)
74
        );
75
    }
76
77
    /**
78
     * clear all locks
79
     */
80
    public function clear()
81
    {
82
        $this->redis->del([self::LOCK_LIST_NAME]);
83
    }
84
85
    /**
86
     * @param $key
87
     * @throws NotExistingKeyException
88
     */
89 View Code Duplication
    public function delete($key)
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...
90
    {
91
        if (!$this->exists($key)) {
92
            throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key));
93
        }
94
95
        $this->redis->hdel(self::LOCK_LIST_NAME, $this->getLockPath($key));
96
    }
97
98
    /**
99
     * @param $key
100
     * @return bool
101
     */
102
    public function exists($key)
103
    {
104
        return ($this->redis->hget(self::LOCK_LIST_NAME, $this->getLockPath($key))) ? true : false;
105
    }
106
107
    /**
108
     * @param $key
109
     * @return mixed
110
     * @throws NotExistingKeyException
111
     */
112 View Code Duplication
    public function get($key)
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...
113
    {
114
        if (!$this->exists($key)) {
115
            throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key));
116
        }
117
118
        return unserialize($this->redis->hget(self::LOCK_LIST_NAME, $this->getLockPath($key)));
119
    }
120
121
    /**
122
     * @return array
123
     */
124
    public function getAll()
125
    {
126
        return $this->redis->hgetall(self::LOCK_LIST_NAME);
127
    }
128
129
    /**
130
     * @param $key
131
     * @param $payload
132
     * @throws NotExistingKeyException
133
     */
134
    public function update($key, $payload)
135
    {
136
        if (!$this->redis->hget(self::LOCK_LIST_NAME, $this->getLockPath($key))) {
137
            throw new NotExistingKeyException(sprintf('The key "%s" does not exists.', $key));
138
        }
139
140
        /** @var Lock $lock */
141
        $lock = $this->get($key);
142
        $lock->update($payload);
143
144
        $this->saveLock(
145
            $key,
146
            $lock
147
        );
148
    }
149
}
150