Issues (73)

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.

ComponentManager/Command/ProjectAwareCommand.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
/**
4
 * Moodle component manager.
5
 *
6
 * @author Luke Carrier <[email protected]>
7
 * @copyright 2016 Luke Carrier
8
 * @license GPL-3.0+
9
 */
10
11
namespace ComponentManager\Command;
12
13
use ComponentManager\Moodle;
14
use ComponentManager\PackageFormat\PackageFormatFactory;
15
use ComponentManager\PackageRepository\PackageRepositoryFactory;
16
use ComponentManager\PackageSource\PackageSourceFactory;
17
use ComponentManager\Platform\Platform;
18
use ComponentManager\Project\Project;
19
use ComponentManager\Project\ProjectFile;
20
use ComponentManager\Project\ProjectLockFile;
21
use Psr\Log\LoggerInterface;
22
use Symfony\Component\Console\Command\Command;
23
use Symfony\Component\Filesystem\Filesystem;
24
25
/**
26
 * Project-aware command.
27
 *
28
 * Provides helpful utility methods for accessing the project in the current
29
 * working directory. Commands requiring interaction with the Moodle instance
30
 * being processed should extend this class.
31
 */
32
abstract class ProjectAwareCommand extends Command {
33
    /**
34
     * Project filename.
35
     *
36
     * @var string
37
     */
38
    const PROJECT_FILENAME = 'componentmgr.json';
39
40
    /**
41
     * Project lock filename.
42
     *
43
     * @var string
44
     */
45
    const PROJECT_LOCK_FILENAME = 'componentmgr.lock.json';
46
47
    /**
48
     * Filesystem.
49
     *
50
     * @var Filesystem
51
     */
52
    protected $filesystem;
53
54
    /**
55
     * Logger.
56
     *
57
     * @var LoggerInterface
58
     */
59
    protected $logger;
60
61
    /**
62
     * Moodle bridge.
63
     *
64
     * @var Moodle
65
     */
66
    protected $moodle;
67
68
    /**
69
     * Package format factory.
70
     *
71
     * @var PackageFormatFactory
72
     */
73
    protected $packageFormatFactory;
74
75
    /**
76
     * Package repository factory.
77
     *
78
     * @var PackageRepositoryFactory
79
     */
80
    protected $packageRepositoryFactory;
81
82
    /**
83
     * Package source factory.
84
     *
85
     * @var PackageSourceFactory
86
     */
87
    protected $packageSourceFactory;
88
89
    /**
90
     * Project.
91
     *
92
     * Lazily loaded -- be sure to call getProject() in order to ensure the
93
     * value is defined.
94
     *
95
     * @var Project
96
     */
97
    protected $project;
98
99
    /**
100
     * Platform support library.
101
     *
102
     * @var Platform
103
     */
104
    protected $platform;
105
106
    /**
107
     * Initialiser.
108
     *
109
     * @param PackageRepositoryFactory $packageRepositoryFactory
110
     * @param PackageSourceFactory     $packageSourceFactory
111
     * @param PackageFormatFactory     $packageFormatFactory
112
     * @param Platform                 $platform
113
     * @param Filesystem               $filesystem
114
     * @param LoggerInterface          $logger
115
     */
116
    public function __construct(PackageRepositoryFactory $packageRepositoryFactory,
117
                                PackageSourceFactory $packageSourceFactory,
118
                                PackageFormatFactory $packageFormatFactory,
119
                                Platform $platform, Filesystem $filesystem,
120
                                LoggerInterface $logger) {
121
        $this->packageRepositoryFactory = $packageRepositoryFactory;
122
        $this->packageSourceFactory     = $packageSourceFactory;
123
        $this->packageFormatFactory     = $packageFormatFactory;
124
125
        $this->filesystem = $filesystem;
126
        $this->platform   = $platform;
127
128
        $this->logger = $logger;
129
130
        parent::__construct();
131
    }
132
133
    /**
134
     * Get the Moodle bridge.
135
     *
136
     * @param string|null $moodleDirectory
137
     *
138
     * @return Moodle
139
     */
140
    protected function getMoodle($moodleDirectory=null) {
141
        if ($this->moodle === null) {
142
            $moodleDirectory = ($moodleDirectory === null)
143
                    ? $this->platform->getWorkingDirectory() : $moodleDirectory;
144
145
            $this->moodle = new Moodle($moodleDirectory, $this->platform);
146
        }
147
148
        return $this->moodle;
149
    }
150
151
    /**
152
     * Get project.
153
     *
154
     * @param string|null $projectFilename
155
     * @param string|null $projectLockFilename
156
     *
157
     * @return Project
158
     */
159
    protected function getProject($projectFilename=null, $projectLockFilename=null) {
160
        $workingDirectory = $this->platform->getWorkingDirectory();
161
162
        if ($this->project === null) {
163 View Code Duplication
            if ($projectFilename === null) {
0 ignored issues
show
This code seems to be duplicated across 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...
164
                $projectFilename = $this->platform->joinPaths([
165
                    $workingDirectory,
166
                    static::PROJECT_FILENAME,
167
                ]);
168
            } else {
169
                $projectFilename = $this->platform->expandPath(
170
                        $projectFilename);
171
            }
172
173 View Code Duplication
            if ($projectLockFilename === null) {
0 ignored issues
show
This code seems to be duplicated across 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...
174
                $projectLockFilename = $this->platform->joinPaths([
175
                    $workingDirectory,
176
                    static::PROJECT_LOCK_FILENAME,
177
                ]);
178
            } else {
179
                $projectLockFilename = $this->platform->expandPath(
180
                        $projectLockFilename);
181
            }
182
183
            $this->logger->info('Parsing project file', [
184
                'filename' => $projectFilename,
185
            ]);
186
            $this->project = new Project(
187
                    new ProjectFile($projectFilename),
188
                    new ProjectLockFile($projectLockFilename),
189
                    $this->packageRepositoryFactory,
190
                    $this->packageSourceFactory,
191
                    $this->packageFormatFactory);
192
        }
193
194
        return $this->project;
195
    }
196
}
197