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.

  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.

src/CommandBuilder/SysVinitCommandBuilder.php (2 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
 * This file is part of RoboSystemService.
4
 *
5
 * @author      Aitor García Martínez (Falc) <[email protected]>
6
 * @copyright   2016 Aitor García Martínez (Falc) <[email protected]>
7
 *
8
 * @author      Polyvaniy Oleksii (alexndlm) <[email protected]>
9
 * @copyright   2016 Polyvaniy Oleksii (alexndlm) <[email protected]>
10
 *
11
 * @license     MIT
12
 */
13
14
namespace Falc\Robo\Service\CommandBuilder;
15
16
/**
17
 * SysVinit command builder.
18
 */
19
abstract class SysVinitCommandBuilder implements CommandBuilderInterface
20
{
21
    /**
22
     * Command name.
23
     *
24
     * @var string
25
     */
26
    protected $cmd;
27
28
    /**
29
     * Command action.
30
     *
31
     * @var string
32
     */
33
    protected $action;
34
35
    /**
36
     * Whether the command should be quiet or not.
37
     *
38
     * @var boolean
39
     */
40
    protected $quiet = false;
41
42
    /**
43
     * Service.
44
     *
45
     * @var string
46
     */
47
    protected $service;
48
49
    /**
50
     * Option list.
51
     *
52
     * @var string[]
53
     */
54
    protected $options = [];
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 6
    public function start($service)
60
    {
61 6
        if (empty($service)) {
62 2
            throw new \InvalidArgumentException('No service selected to be started');
63
        }
64
65 4
        $this->cmd = '/etc/init.d';
66 4
        $this->service = $service;
67 4
        $this->action = 'start';
68
69 4
        return $this;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75 4 View Code Duplication
    public function stop($service)
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...
76
    {
77 4
        if (empty($service)) {
78 2
            throw new \InvalidArgumentException('No service selected to be stopped');
79
        }
80
81 2
        $this->cmd = '/etc/init.d';
82 2
        $this->service = $service;
83 2
        $this->action = 'stop';
84
85 2
        return $this;
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91 4
    public function restart($service)
92
    {
93 4
        if (empty($service)) {
94 2
            throw new \InvalidArgumentException('No service selected to be restarted');
95
        }
96
97 2
        $this->cmd = '/etc/init.d';
98 2
        $this->service = $service;
99 2
        $this->action = 'restart';
100
101 2
        return $this;
102
    }
103
104
    /**
105
     * {@inheritdoc}
106
     */
107 4 View Code Duplication
    public function reload($service)
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...
108
    {
109 4
        if (empty($service)) {
110 2
            throw new \InvalidArgumentException('No service selected to be reloaded');
111
        }
112
113 2
        $this->cmd = '/etc/init.d';
114 2
        $this->service = $service;
115 2
        $this->action = 'reload';
116
117 2
        return $this;
118
    }
119
120
    /**
121
     * {@inheritdoc}
122
     */
123
    abstract public function enable($service);
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    abstract public function disable($service);
129
130
    /**
131
     * {@inheritdoc}
132
     *
133
     * @throws \BadMethodCallException
134
     */
135 2
    public function daemonReload()
136
    {
137 2
        throw new \BadMethodCallException('Action "daemon-reload" not supported for SysVinit');
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     */
143 2
    public function quiet()
144
    {
145 2
        $this->quiet = true;
146
147 2
        return $this;
148
    }
149
150
    /**
151
     * {@inheritdoc}
152
     */
153 14
    public function getCommand()
154
    {
155 14
        $options = implode(' ', array_unique($this->options));
156
157 14
        $command = "{$this->cmd}/{$this->service} {$this->action} {$options}";
158
159 14
        if (!in_array($this->action, ['start', 'stop', 'restart', 'reload'])) {
160 4
            $command = "{$this->cmd} {$options} {$this->service} {$this->action}";
161 4
        }
162
163 14
        if ($this->quiet === true) {
164 2
            $command = "{$command} > /dev/null";
165 2
        }
166
167
        // Remove extra whitespaces
168 14
        $command = preg_replace('/\s+/', ' ', trim($command));
169
170 14
        return $command;
171
    }
172
}
173