Issues (7)

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.

Command/LoggerStateChannelCommand.php (3 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 Itkg\DelayEventBundle\Command;
4
5
use DateInterval;
6
use Itkg\DelayEventBundle\Document\Lock;
7
use Itkg\DelayEventBundle\Handler\LockHandlerInterface;
8
use Itkg\DelayEventBundle\Notifier\NotifierInterface;
9
use Itkg\DelayEventBundle\Repository\EventRepository;
10
use Itkg\DelayEventBundle\Repository\LockRepository;
11
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
12
use Symfony\Component\Console\Input\InputArgument;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
use Symfony\Component\Filesystem\LockHandler;
16
17
/**
18
 * Class LoggerStateChannelCommand
19
 */
20
class LoggerStateChannelCommand extends ContainerAwareCommand
21
{
22
23
    /**
24
     * @var array
25
     */
26
    private $channels;
27
28
    /**
29
     * @var LockRepository
30
     */
31
    private $lockRepository;
32
33
    /**
34
     * @var NotifierInterface
35
     */
36
    private $notifier;
37
38
    /**
39
     * @var integer
40
     */
41
    private $timeLimit;
0 ignored issues
show
The property $timeLimit is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
42
43
    /**
44
     * @var string
45
     */
46
    private $channelName;
0 ignored issues
show
The property $channelName is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
47
48
    /**
49
     * @var integer
50
     */
51
    private $extraTime;
52
53
54
    /**
55
     * @param LockRepository    $lockRepository
56
     * @param NotifierInterface $notifier
57
     * @param array             $channels
58
     * @param null              $name
59
     */
60
    public function __construct(
61
        LockRepository $lockRepository,
62
        NotifierInterface $notifier,
63
        array $channels = [],
64
        $name = null
65
    ) {
66
        $this->lockRepository = $lockRepository;
67
        $this->notifier = $notifier;
68
        $this->channels = $channels;
69
70
        parent::__construct($name);
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76
    protected function configure()
77
    {
78
        $this
79
            ->setName('itkg_delay_event:logger')
80
            ->setDescription('Log state channel')
81
            ->addArgument(
82
                'time',
83
                InputArgument::REQUIRED,
84
                'extra time for detect lock'
85
            );
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91
    protected function execute(InputInterface $input, OutputInterface $output)
92
    {
93
        $this->extraTime = $input->getArgument('time');
94
95
        if (!isset($this->extraTime)) {
96
            $output->writeln(
97
                sprintf(
98
                    '<info>Argument time %s is required.</info>',
99
                    $this->extraTime
100
                )
101
            );
102
        }
103
104
        $locks = $this->lockRepository->findAll();
105
106
        /** @var Lock $lock */
107
        foreach ($locks as $lock) {
108
            if ($lock->isCommandLocked()) {
109
                foreach ($this->channels as $key => $channel) {
110
                    if ($this->isLockedChannelInfomation($key, $lock, $channel, $output)) {
0 ignored issues
show
The call to LoggerStateChannelComman...ckedChannelInfomation() has too many arguments starting with $output.

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...
111
112
                        $dateWithMaxTime = $lock->getLockedAt();
113
114
                        $time = $channel['duration_limit_per_run'] + $this->extraTime;
115
                        $dateWithMaxTime->add(
116
                            new DateInterval('PT' . $time . 'S')
117
                        );
118
                        if (new \DateTime() > ($dateWithMaxTime)) {
119
                            $this->notifier->process($key);
120
                        }
121
122
                        break;
123
                    }
124
                }
125
126
127
            }
128
        }
129
    }
130
131
    /**
132
     * @param      $key
133
     * @param Lock $lock
134
     * @param      $channel
135
     * @return bool
136
     */
137
    private function isLockedChannelInfomation($key, Lock $lock, $channel)
138
    {
139
140
        if (preg_match(sprintf('/^%s/', $key), $lock->getChannel()) && true === $channel['dynamic'] || $key == $lock->getChannel() && false === $channel['dynamic']) {
141
142
            return true;
143
        }
144
145
        return false;
146
    }
147
}
148