Issues (8)

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/Wrapper.php (8 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 Gregoriohc\LaravelTrello;
4
5
use Illuminate\Config\Repository;
6
use Trello\Client;
7
use Trello\Manager;
8
9
class Wrapper
10
{
11
    /**
12
     * The config instance
13
     *
14
     * @var Repository
15
     */
16
    public $config;
17
18
    /**
19
     * The trello client instance
20
     *
21
     * @var \Trello\Client
22
     */
23
    private $client;
24
25
    /**
26
     * The trello manager instance
27
     *
28
     * @var \Trello\Manager
29
     */
30
    private $manager;
31
32
    /**
33
     * Client cache
34
     *
35
     * @var array
36
     */
37
    private $cache;
38
39
    /**
40
     * Client constructor
41
     *
42
     * @param Repository $config
43
     */
44
    public function __construct(Repository $config)
45
    {
46
        // Get the config data
47
        $this->config = $config;
48
49
        // Make the client instance
50
        $this->client = new Client();
51
        $this->client->authenticate($this->config->get('trello.api_key'), $this->config->get('trello.api_token'), Client::AUTH_URL_CLIENT_ID);
52
    }
53
54
    /**
55
     * Returns trello manager instance
56
     *
57
     * @return \Trello\Manager
58
     */
59
    public function manager()
60
    {
61
        if (!isset($this->manager)) {
62
            $this->manager = new Manager($this->client);
63
        }
64
65
        return $this->manager;
66
    }
67
68
    /**
69
     * Returns a trello object id by a given name
70
     *
71
     * @param string $type
72
     * @param string $name
73
     * @param array $options
74
     * @return bool|string
75
     */
76
    public function getObjectId($type, $name, $options = [])
77
    {
78
        switch ($type) {
79
            case 'organization':
80 View Code Duplication
                if (!isset($this->cache['organizations'])) {
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...
81
                    $this->cache['organizations'] = $this->api('member')->organizations()->all('me');
0 ignored issues
show
Documentation Bug introduced by
The method api does not exist on object<Gregoriohc\LaravelTrello\Wrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
82
                }
83
84
                foreach ($this->cache['organizations'] as $item) {
85
                    if ($name == $item['name']) {
86
                        return $item['id'];
87
                    }
88
                }
89
90
                break;
91
            case 'board':
92
                if (!isset($options['organization'])) {
93
                    $options['organization'] = $this->config->get('trello.organization');
94
                }
95
                $organizationId = $this->getObjectId('organization', $options['organization']);
96
97 View Code Duplication
                if (!isset($this->cache['boards'])) {
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...
98
                    $this->cache['boards'] = $this->api('member')->boards()->all('me');
0 ignored issues
show
Documentation Bug introduced by
The method api does not exist on object<Gregoriohc\LaravelTrello\Wrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
99
                }
100
101
                foreach ($this->cache['boards'] as $item) {
102
                    if ($name == $item['name'] && $organizationId == $item['idOrganization']) {
103
                        return $item['id'];
104
                    }
105
                }
106
107
                // Workaround for shared boards
108
                foreach ($this->cache['boards'] as $item) {
109
                    if ($name == $item['name']) {
110
                        return $item['id'];
111
                    }
112
                }
113
114
                break;
115 View Code Duplication
            case 'list':
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...
116
                if (!isset($options['organization'])) {
117
                    $options['organization'] = $this->config->get('trello.organization');
118
                }
119
                if (!isset($options['board'])) {
120
                    $options['board'] = $this->config->get('trello.board');
121
                }
122
123
                $boardId = $this->getObjectId('board', $options['board'], ['organization' => $options['organization']]);
124
                if (!isset($this->cache['lists'][$boardId])) {
125
                    $this->cache['lists'][$boardId] = $this->api('board')->lists()->all($boardId);
0 ignored issues
show
Documentation Bug introduced by
The method api does not exist on object<Gregoriohc\LaravelTrello\Wrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
126
                }
127
128
                foreach ($this->cache['lists'][$boardId] as $item) {
129
                    if ($name == $item['name']) {
130
                        return $item['id'];
131
                    }
132
                }
133
134
                break;
135 View Code Duplication
            case 'label':
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...
136
                if (!isset($options['organization'])) {
137
                    $options['organization'] = $this->config->get('trello.organization');
138
                }
139
                if (!isset($options['board'])) {
140
                    $options['board'] = $this->config->get('trello.board');
141
                }
142
143
                $boardId = $this->getObjectId('board', $options['board'], ['organization' => $options['organization']]);
144
                if (!isset($this->cache['labels'][$boardId])) {
145
                    $this->cache['labels'][$boardId] = $this->api('board')->labels()->all($boardId);
0 ignored issues
show
Documentation Bug introduced by
The method api does not exist on object<Gregoriohc\LaravelTrello\Wrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
146
                }
147
148
                foreach ($this->cache['labels'][$boardId] as $item) {
149
                    if ($name == $item['name']) {
150
                        return $item['id'];
151
                    }
152
                }
153
154
                break;
155
        }
156
157
        return false;
158
    }
159
160
    /**
161
     * Returns default organization id
162
     *
163
     * @return Manager
164
     */
165
    public function getDefaultOrganizationId()
166
    {
167
        return $this->getObjectId('organization', $this->config->get('trello.organization'));
168
    }
169
170
    /**
171
     * Returns default board id
172
     *
173
     * @return Manager
174
     */
175
    public function getDefaultBoardId()
176
    {
177
        return $this->getObjectId('board', $this->config->get('trello.board'));
178
    }
179
180
    /**
181
     * Returns default list id
182
     *
183
     * @return Manager
184
     */
185
    public function getDefaultListId()
186
    {
187
        return $this->getObjectId('list', $this->config->get('trello.list'));
188
    }
189
190
    /**
191
     * Handle dynamic calls to the client
192
     *
193
     * @param $name
194
     * @param $arguments
195
     *
196
     * @return mixed
197
     */
198
    public function __call($name, $arguments)
199
    {
200
        return call_user_func_array([$this->client, $name], $arguments);
201
    }
202
}