Issues (155)

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/Bowerphp/Package/Package.php (1 issue)

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 Bowerphp\Package;
4
5
use Bowerphp\Repository\RepositoryInterface;
6
7
/**
8
 * Package
9
 */
10
class Package implements PackageInterface
11
{
12
    protected $name;
13
14
    protected $repository;
15
16
    protected $requiredVersion;
17
18
    protected $version;
19
20
    protected $requires = [];
21
22
    protected $info = [];
23
24
    /**
25
     * All descendants' constructors should call this parent constructor
26
     *
27
     * @param string $name            The package's name
28
     * @param string $requiredVersion E.g. 1.*
29
     * @param string $version         E.g. 1.2.3
30
     * @param array  $requires        The package's dependencies
31
     * @param array  $info            Package info (e.g. info from bower.json)
32
     */
33
    public function __construct($name, $requiredVersion = null, $version = null, $requires = [], $info = [])
34
    {
35
        $this->name = $name;
36
        $this->requiredVersion = 'master' === $requiredVersion ? '*' : $requiredVersion;
37
        $this->version = $version;
38
        if (!empty($requires)) {
39
            $this->requires = $requires;
40
        }
41
        if (!empty($info)) {
42
            $this->info = $info;
43
        }
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getName()
50
    {
51
        return $this->name;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getVersion()
58
    {
59
        return $this->version;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function setVersion($version)
66
    {
67
        return $this->version = $version;
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function getRequiredVersion()
74
    {
75
        return $this->requiredVersion;
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function setRequiredVersion($version)
82
    {
83
        return $this->requiredVersion = $version;
84
    }
85
86
    /**
87
     * {@inheritdoc}
88
     */
89
    public function setRepository(RepositoryInterface $repository)
90
    {
91
        if ($this->repository && $repository !== $this->repository) {
92
            throw new \LogicException('A package can only be added to one repository');
93
        }
94
        $this->repository = $repository;
95
    }
96
97
    /**
98
     * Returns package unique name, constructed from name, version and release type.
99
     *
100
     * @return string
101
     */
102
    public function getUniqueName()
103
    {
104
        return $this->getName() . '-' . $this->getVersion();
105
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110
    public function setRequires(array $requires = null)
111
    {
112
        $this->requires = $requires;
0 ignored issues
show
Documentation Bug introduced by
It seems like $requires can be null. However, the property $requires is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

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

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118
    public function getRequires()
119
    {
120
        // see if there is some inside $this->info (e.g. from bower.json)
121
        if (empty($this->requires) && isset($this->info['dependencies'])) {
122
            $this->requires = $this->info['dependencies'];
123
        }
124
125
        return $this->requires;
126
    }
127
128
    /**
129
     * {@inheritdoc}
130
     */
131
    public function setInfo(array $info)
132
    {
133
        $this->info = $info;
134
    }
135
136
    /**
137
     * {@inheritdoc}
138
     */
139
    public function getInfo()
140
    {
141
        return $this->info;
142
    }
143
144
    /**
145
     * Converts the package into a readable and unique string
146
     *
147
     * @return string
148
     */
149
    public function __toString()
150
    {
151
        return $this->getUniqueName();
152
    }
153
}
154