Issues (45)

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/FacebookAds/Enum/AbstractEnum.php (1 issue)

Severity

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
 * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
4
 *
5
 * You are hereby granted a non-exclusive, worldwide, royalty-free license to
6
 * use, copy, modify, and distribute this software in source code or binary
7
 * form for use in connection with the web services and APIs provided by
8
 * Facebook.
9
 *
10
 * As with any software that integrates with the Facebook platform, your use
11
 * of this software is subject to the Facebook Developer Principles and
12
 * Policies [http://developers.facebook.com/policy/]. This copyright notice
13
 * shall be included in all copies or substantial portions of the software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * DEALINGS IN THE SOFTWARE.
22
 *
23
 */
24
25
namespace FacebookAds\Enum;
26
27
abstract class AbstractEnum implements EnumInstanceInterface {
28
29
  /**
30
   * @var array|null
31
   */
32
  protected $map = null;
33
34
  /**
35
   * @var array|null
36
   */
37
  protected $names = null;
38
39
  /**
40
   * @var array|null
41
   */
42
  protected $values = null;
43
44
  /**
45
   * @var array|null
46
   */
47
  protected $valuesMap = null;
48
49
  /**
50
   * @var AbstractEnum[]
51
   */
52
  protected static $instances = array();
53
54
  /**
55
   * @return string
56
   */
57 2
  static function className() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
58 2
    return get_called_class();
59
  }
60
61
  /**
62
   * @return AbstractEnum
63
   */
64 30
  public static function getInstance() {
65 30
    $fqn = get_called_class();
66 30
    if (!array_key_exists($fqn, static::$instances)) {
67 2
      static::$instances[$fqn] = new static();
68 2
    }
69
70 30
    return static::$instances[$fqn];
71
  }
72
73
  /**
74
   * @return array
75
   */
76 4
  public function getArrayCopy() {
77 4
    if ($this->map === null) {
78 1
      $this->map = (new \ReflectionClass(get_called_class()))
79 1
        ->getConstants();
80 1
    }
81
82 4
    return $this->map;
83
  }
84
85
  /**
86
   * @return array
87
   */
88 2
  public function getNames() {
89 2
    if ($this->names === null) {
90 1
      $this->names = array_keys($this->getArrayCopy());
91 1
    }
92
93 2
    return $this->names;
94
  }
95
96
  /**
97
   * @return array
98
   */
99 2
  public function getValues() {
100 2
    if ($this->values === null) {
101 1
      $this->values = array_values($this->getArrayCopy());
102 1
    }
103
104 2
    return $this->values;
105
  }
106
107
  /**
108
   * @return array
109
   */
110 4
  public function getValuesMap() {
111 4
    if ($this->valuesMap === null) {
112 1
      $this->valuesMap = array_fill_keys($this->getValues(), null);
113 1
    }
114
115 4
    return $this->valuesMap;
116
  }
117
118
  /**
119
   * @param string|int|float $name
120
   * @return mixed
121
   */
122 2
  public function getValueForName($name) {
123 2
    $copy = $this->getArrayCopy();
124 2
    return array_key_exists($name, $copy)
125 2
      ? $copy[$name]
126 2
      : null;
127
  }
128
129
  /**
130
   * @param string|int|float $name
131
   * @return mixed
132
   * @throws \InvalidArgumentException
133
   */
134 1
  public function assureValueForName($name) {
135 1
    $value = $this->getValueForName($name);
136 1
    if ($value === null) {
137 1
      throw new \InvalidArgumentException(
138 1
        'Unknown name "'.$name.'" in '.static::className());
139
    }
140
141 1
    return $value;
142
  }
143
144
  /**
145
   * @param string|int|float $name
146
   * @return bool
147
   */
148 1
  public function isValid($name) {
149 1
    return array_key_exists($name, $this->getArrayCopy());
150
  }
151
152
  /**
153
   * @param string|int|float $name
154
   * @throws \InvalidArgumentException
155
   */
156 1
  public function assureIsValid($name) {
157 1
    if (!array_key_exists($name, $this->getArrayCopy())) {
158 1
      throw new \InvalidArgumentException(
159 1
        'Unknown name "'.$name.'" in '.static::className());
160
    }
161 1
  }
162
163
  /**
164
   * @param string|int|float $value
165
   * @return bool
166
   */
167 2
  public function isValidValue($value) {
168 2
    return array_key_exists($value, $this->getValuesMap());
169
  }
170
171
  /**
172
   * @param mixed $value
173
   * @throws \InvalidArgumentException
174
   */
175 1
  public function assureIsValidValue($value) {
176 1
    if (!$this->isValidValue($value)) {
177 1
      throw new \InvalidArgumentException(
178 1
        '"'.$value.'", not a valid value in '.static::className());
179
    }
180 1
  }
181
}
182