Issues (2)

Security Analysis    not enabled

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/Manager/GoalManager.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
namespace Acquia\LiftClient\Manager;
4
5
use Acquia\LiftClient\Entity\Entity;
6
use Acquia\LiftClient\Entity\Goal;
7
use Acquia\LiftClient\Entity\GoalAddResponse;
8
use Acquia\LiftClient\Exception\LiftSdkException;
9
use GuzzleHttp\Psr7\Request;
10
11
class GoalManager extends ManagerBase
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    protected $queryParameters = [
17
        'global' => null,
18
        'limit_by_site' => null,
19
    ];
20
21
    /**
22
     * @var array Valid boolean query strings.
23
     */
24
    private $validBooleanQueryStrings = [
25
        'true',
26
        'false',
27
    ];
28
29
    /**
30
     * Get a list of Goals.
31
     *
32
     * Example of how to structure the $options parameter:
33
     * <code>
34
     * $options = [
35
     *     'global'  => 'false',
36
     *     'limit_by_site'  => 'true',
37
     * ];
38
     * </code>
39
     * Note: the options "global" and "limit_by_site" work together to determine
40
     * what goals are coming back. Please see the truth table on following page.
41
     *
42
     * @see http://docs.decision-api.acquia.com/#goals_get
43
     *
44
     * @param array $options
45
     *
46
     * @throws \GuzzleHttp\Exception\RequestException
47
     *
48
     * @return \Acquia\LiftClient\Entity\Goal[]
49
     */
50 18 View Code Duplication
    public function query($options = [])
51
    {
52 12
        $url = '/goals';
53 18
        $url .= $this->getQueryString($options);
54
55
        // Now make the request.
56 6
        $request = new Request('GET', $url);
57 6
        $data = $this->getResponseJson($request);
58
59
        // Get them as Goal objects
60 3
        $goals = [];
61 3
        foreach ($data as $dataItem) {
62 3
            $goals[] = new Goal($dataItem);
63 2
        }
64
65 3
        return $goals;
66
    }
67
68
    /**
69
     * Get a specific goal.
70
     *
71
     * @see http://docs.decision-api.acquia.com/#goals__goal_id__get
72
     *
73
     * @param array $id
74
     *
75
     * @throws \GuzzleHttp\Exception\RequestException
76
     *
77
     * @return \Acquia\LiftClient\Entity\Goal
78
     */
79 6
    public function get($id)
80
    {
81 6
        $url = "/goals/{$id}";
82
83
        // Now make the request.
84 6
        $request = new Request('GET', $url);
85 6
        $data = $this->getResponseJson($request);
86
87 3
        return new Goal($data);
88
    }
89
90
    /**
91
     * Add a goal.
92
     *
93
     * @see http://docs.decision-api.acquia.com/#goals_post
94
     *
95
     * @param \Acquia\LiftClient\Entity\Goal $goal
96
     *
97
     * @throws \GuzzleHttp\Exception\RequestException
98
     *
99
     * @return \Acquia\LiftClient\Entity\GoalAddResponse
100
     */
101 9
    public function add(Goal $goal)
102
    {
103
        // goals only supports adding a list of goals
104
        // we do not want to support that in the SDK for consistency reasons, so
105
        // we convert it to an array here.
106 9
        $goals = new Entity([$goal->getArrayCopy()]);
107 9
        $body = $goals->json();
108 9
        $url = '/goals';
109 9
        $request = new Request('POST', $url, [], $body);
110 9
        $data = $this->getResponseJson($request);
111
112 6
        return new GoalAddResponse($data);
113
    }
114
115
    /**
116
     * Deletes a goal by ID.
117
     *
118
     * @see http://docs.decision-api.acquia.com/#goals__goal_id__delete
119
     *
120
     * @param string $id
121
     *
122
     * @throws \GuzzleHttp\Exception\RequestException
123
     *
124
     * @return bool
125
     */
126 6
    public function delete($id)
127
    {
128 6
        $url = "/goals/{$id}";
129 6
        $this->client->delete($url);
130
131 3
        return true;
132
    }
133
134
    /**
135
     * Get query string of using the options.
136
     *
137
     * @param $options The options
138
     *
139
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
140
     *
141
     * @return string  The query string
142
     */
143 12
    protected function getQueryString($options) {
144 12 View Code Duplication
        if (isset($options['global']) && !in_array($options['global'], $this->validBooleanQueryStrings)) {
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...
145 3
            throw new LiftSdkException('The "global" parameter must be a string value of "true" or "false", or absent.');
146
        }
147 9 View Code Duplication
        if (isset($options['limit_by_site']) && !in_array($options['limit_by_site'], $this->validBooleanQueryStrings)) {
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...
148 3
            throw new LiftSdkException('The "limit_by_site" parameter must be a string value of "true" or "false", or absent.');
149
        }
150
151 6
        return parent::getQueryString($options);
152
    }
153
}
154