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/Object/CustomAudienceMultiKey.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
 * 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\Object;
26
27
use FacebookAds\Http\RequestInterface;
28
use FacebookAds\Object\Values\CustomAudienceTypes;
29
use FacebookAds\Object\Fields\CustomAudienceFields;
30
use FacebookAds\Object\CustomAudienceNormalizers\HashNormalizer;
31
use FacebookAds\Object\Fields\CustomAudienceMultikeySchemaFields;
32
33
class CustomAudienceMultiKey extends AbstractCrudObject {
34
35
  /**
36
   * @var string
37
   */
38
  const HASH_TYPE_SHA256 = 'sha256';
39
40
  /**
41
  * @var \ArrayObject
42
  */
43
  protected $normalizers;
44
45
  /**
46
   * @deprecated getEndpoint function is deprecated
47
   * @return string
48
   */
49
  protected function getEndpoint() {
50
    return 'customaudiences';
51
  }
52
53
  /**
54
   * @return CustomAudienceFields
55
   */
56
  public static function getFieldsEnum() {
57
    return CustomAudienceFields::getInstance();
58
  }
59
60
  /**
61
   * @return \ArrayObject
62
   */
63
  public function getNormalizers() {
64
    if ($this->normalizers === null) {
65
      $this->normalizers = new \ArrayObject(array(
66
        new CustomAudienceNormalizers\EmailNormalizer(),
67
        new CustomAudienceNormalizers\PhoneNormalizer(),
68
        new CustomAudienceNormalizers\MadidNormalizer(),
69
        new CustomAudienceNormalizers\GenderNormalizer(),
70
        new CustomAudienceNormalizers\BirthYearNormalizer(),
71
        new CustomAudienceNormalizers\DateNormalizer(),
72
        new CustomAudienceNormalizers\FirstNameNormalizer(),
73
        new CustomAudienceNormalizers\LastNameNormalizer(),
74
        new CustomAudienceNormalizers\FirstNameInitialNormalizer(),
75
        new CustomAudienceNormalizers\StateNormalizer(),
76
        new CustomAudienceNormalizers\CityNormalizer(),
77
        new CustomAudienceNormalizers\ZipNormalizer(),
78
        new CustomAudienceNormalizers\CountryNormalizer(),
79
      ));
80
    }
81
    return $this->normalizers;
82
  }
83
84
  /**
85
   * Add users to the AdCustomAudiences. There is no max on the total number of
86
   * users that can be added to an audience, but up to 10000 users can be added
87
   * at a given time.
88
   *
89
   * @param array $users
90
   * @param array $types
91
   * @param bool $is_hashed
92
   * @param bool $is_normalized
93
   * @return array
94
   */
95
  public function addUsers(
96
    array $users,
97
    array $types,
98
    $is_hashed = false,
99
    $is_normalized = false) {
100
101
    $params = $this->formatParams($users, $types, $is_hashed, $is_normalized);
102
    return $this->getApi()->call(
103
      '/'.$this->assureId().'/users',
104
      RequestInterface::METHOD_POST,
105
      $params)->getContent();
106
  }
107
108
  /**
109
   * Delete users from AdCustomAudiences
110
   *
111
   * @param array $users
112
   * @param array $types
113
   * @param bool $is_hashed
114
   * @param bool $is_normalized
115
   * @return array
116
   */
117
  public function removeUsers(
118
    array $users,
119
    array $types,
120
    $is_hashed = false,
121
    $is_normalized = false) {
122
123
    $params = $this->formatParams($users, $types, $is_hashed, $is_normalized);
124
    return $this->getApi()->call(
125
      '/'.$this->assureId().'/users',
126
      RequestInterface::METHOD_DELETE,
127
      $params)->getContent();
128
  }
129
130
  /**
131
   * Take users and format them correctly for the request
132
   *
133
   * @param array $users
134
   * @param array $types
135
   * @param bool $is_hashed
136
   * @param bool $is_normalized
137
   * @return array
138
   */
139
  protected function formatParams(
140
    array $users,
141
    array $types,
142
    $is_hashed = false,
143
    $is_normalized = false) {
144
145
    if (!$is_hashed) {
146
      if ($is_normalized) {
147
        $normalizers = new \ArrayObject(array(
148
          new HashNormalizer()
149
        ));
150
      }
151
      else {
152
        $normalizers = clone $this->getNormalizers();
153
        $normalizers->append(new HashNormalizer());
154
      }
155
      foreach ($users as &$user) {
156
        if (count($types) != count($user)) {
157
          throw new \InvalidArgumentException(
158
            "Number of keys in each list in the data should ".
159
            "match the number of keys specified in scheme");
160
          break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
161
        }
162
        foreach ($user as $index => &$key_value) {
163
          $key = $types[$index];
164
          foreach ($normalizers as $normalizer) {
165
            if ($key_value &&
166
                $key !== CustomAudienceMultikeySchemaFields::EXTERN_ID &&
167
                $normalizer->shouldNormalize($key, $key_value)) {
168
              $key_value = $normalizer->normalize($key, $key_value);
169
            }
170
          }
171
        }
172
      }
173
    }
174
175
    $payload = array(
176
      'schema' => $types,
177
      'data' => $users,
178
    );
179
180
    return array('payload' => $payload);
181
  }
182
}
183