Issues (13)

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/Publisher/Publisher.php (5 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
 * This file is part of Laravel Service Provider.
5
 *
6
 * (c) DraperStudio <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DraperStudio\ServiceProvider\Publisher;
13
14
use Illuminate\Filesystem\Filesystem;
15
16
abstract class Publisher
17
{
18
    /**
19
     * The filesystem instance.
20
     *
21
     * @var \Illuminate\Filesystem\Filesystem
22
     */
23
    protected $files;
24
25
    /**
26
     * The destination of the config files.
27
     *
28
     * @var string
29
     */
30
    protected $publishPath;
31
32
    /**
33
     * The path to the application's packages.
34
     *
35
     * @var string
36
     */
37
    protected $packagePath;
38
39
    /**
40
     * The destination paths for source files.
41
     *
42
     * @var string
43
     */
44
    protected $destinationPaths;
45
46
    /**
47
     * Create a new publisher instance.
48
     *
49
     * @param \Illuminate\Filesystem\Filesystem $files
50
     * @param string                            $publishPath
51
     */
52
    public function __construct(Filesystem $files, $publishPath)
53
    {
54
        $this->files = $files;
55
        $this->publishPath = $publishPath;
56
57
        $this->destinationPaths = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array('migrations' => da...%s'), 'routes' => null) of type array<string,string|null...ring","routes":"null"}> is incompatible with the declared type string of property $destinationPaths.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
58
            'migrations' => database_path('/migrations/%s_%s'),
59
            'seeds' => database_path('/seeds/%s'),
60
            'config' => config_path('%s'),
61
            'views' => base_path('resources/views/vendor/%s'),
62
            'translations' => base_path('resources/lang/%s'),
63
            'assets' => public_path('vendor/%s'),
64
            'routes' => null,
65
        ];
66
    }
67
68
    /**
69
     * Publish files from a given path.
70
     *
71
     * @param string $package
72
     * @param string $source
0 ignored issues
show
There is no parameter named $source. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
73
     *
74
     * @return bool
75
     */
76
    public function getFileList($package)
77
    {
78
        return $this->getSource($package, $this->packagePath);
0 ignored issues
show
The call to Publisher::getSource() has too many arguments starting with $this->packagePath.

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...
79
    }
80
81
    /**
82
     * Set the default package path.
83
     *
84
     * @param string $packagePath
85
     */
86
    public function setPackagePath($packagePath)
87
    {
88
        $this->packagePath = $packagePath;
89
    }
90
91
    /**
92
     * Set the default package name.
93
     *
94
     * @param string $packageName
95
     */
96
    public function setPackageName($packageName)
97
    {
98
        $this->packageName = $packageName;
0 ignored issues
show
The property packageName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
99
    }
100
101
    /**
102
     * Get the source directory to publish.
103
     *
104
     * @param string $packagePath
105
     *
106
     * @return string
107
     *
108
     * @throws \InvalidArgumentException
109
     */
110
    abstract protected function getSource($packagePath);
111
112
    /**
113
     * @param $file
114
     *
115
     * @return string
116
     */
117
    protected function getFileName($file)
118
    {
119
        $file = basename($file);
120
121
        if (!ends_with($file, '.php')) {
122
            $file = $file.'.php';
123
        }
124
125
        return $file;
126
    }
127
128
    /**
129
     * Get the target destination path for the files.
130
     *
131
     * @param string $package
0 ignored issues
show
There is no parameter named $package. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
132
     *
133
     * @return string
134
     */
135
    protected function getDestinationPath($type, $args)
136
    {
137
        return vsprintf($this->destinationPaths[$type], $args);
138
    }
139
140
    /**
141
     * @param $type
142
     * @param $files
143
     *
144
     * @return array
145
     */
146
    protected function getSourceFiles($path)
147
    {
148
        $files = [];
149
        foreach (glob($path.'/*.php') as $file) {
150
            $files[] = $file;
151
        }
152
153
        return $files;
154
    }
155
156
    /**
157
     * @param $path
158
     *
159
     * @return mixed
160
     */
161
    protected function getClassFromFile($path)
162
    {
163
        $count = count($tokens = token_get_all(file_get_contents($path)));
164
165
        for ($i = 2; $i < $count; ++$i) {
166
            if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) {
167
                return $tokens[$i][1];
168
            }
169
        }
170
    }
171
}
172