Issues (10)

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/Salesforce.php (4 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 Surge\LaravelSalesforce;
4
5
use GuzzleHttp\ClientInterface;
6
use Surge\LaravelSalesforce\Objects\BaseObject;
7
8
class Salesforce
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $objName;
14
15
    public $baseUrl;
16
17
    public $instanceUrl;
18
19
    public $client;
20
21
    /**
22
     * Salesforce constructor.
23
     *
24
     * @param ClientInterface $client
25
     * @param string          $url
26
     * @param string          $instanceUrl
27
     */
28
    public function __construct(ClientInterface $client, string $url, string $instanceUrl)
29
    {
30
        $this->client = $client;
31
        $this->baseUrl = $url;
32
        $this->instanceUrl = $instanceUrl;
33
    }
34
35
    /**
36
     * @param  string $method
37
     * @param  array  $args
38
     * @return bool|mixed|string
39
     */
40
    public function __call($method, $args)
41
    {
42
        if (starts_with($method, 'create')) {
43
            return $this->callCreateOnObject($method, $args);
44
        }
45
46
        if (starts_with($method, 'update')) {
47
            return $this->callUpdateOnObject($method, $args);
48
        }
49
50
        if (starts_with($method, 'delete')) {
51
            return $this->callDeleteOnObject($method, $args);
52
        }
53
54
        if (starts_with($method, 'get')) {
55
            return $this->callGetOnObject($method, $args);
56
        }
57
58
        if (starts_with($method, 'exists')) {
59
            return $this->callExistsOnObject($method, $args);
60
        }
61
62
        $class = new BaseObject($this);
63
64
        return call_user_func_array([$class, $method], $args);
65
    }
66
67
    /**
68
     * Create object dynamically
69
     *
70
     * @param $method
71
     * @param $args
72
     * @return bool
73
     */
74 View Code Duplication
    private function callCreateOnObject($method, $args)
0 ignored issues
show
This method seems to be duplicated in 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...
75
    {
76
        $type = substr($method, 6);
77
        $class = '\\Surge\\LaravelSalesforce\\Objects\\' . $type;
78
79
        if (class_exists($class)) {
80
            return (new $class($this))->create($args[0]);
81
        }
82
83
        return (new BaseObject($this, $type))->create($args[0]);
84
    }
85
86
    private function callUpdateOnObject($method, $args)
87
    {
88
        $type = substr($method, 6);
89
        $class = '\\Surge\\LaravelSalesforce\\Objects\\' . $type;
90
91
        if (class_exists($class)) {
92
            return (new $class($this))->update($args[0], $args[1]);
93
        }
94
95
        return (new BaseObject($this, $type))->update($type, $args[0]);
96
    }
97
98 View Code Duplication
    private function callDeleteOnObject($method, $args)
0 ignored issues
show
This method seems to be duplicated in 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...
99
    {
100
        $type = substr($method, 6);
101
        $class = '\\Surge\\LaravelSalesforce\\Objects\\' . $type;
102
103
        if (class_exists($class)) {
104
            return (new $class($this))->delete($args[0]);
105
        }
106
107
        return (new BaseObject($this, $type))->delete($args[0]);
108
    }
109
110
    private function callGetOnObject($method, $args)
111
    {
112
        $type = substr($method, 3);
113
        $class = '\\Surge\\LaravelSalesforce\\Objects\\' . $type;
114
115
        if (class_exists($class)) {
116
            return (new $class($this))->get($args[0]);
117
        }
118
119
        return (new BaseObject($this, $type))->get($args[0]);
120
    }
121
122
    private function callExistsOnObject($method, $args)
123
    {
124
        $type = substr($method, 6);
125
        $class = '\\Surge\\LaravelSalesforce\\Objects\\' . $type;
126
127
        if (class_exists($class)) {
128
            if (isset($args[1]) && isset($args[2])) { //second and third params are optional
129
                return (new $class($this))->exists($args[0], $args[1], $args[2]);
130
            } elseif (isset($args[1])) {
131
                return (new $class($this))->exists($args[0], $args[1]);
132
            } else {
133
                return (new $class($this))->exists($args[0]);
134
            }
135
        }
136
137
        return (new BaseObject($this, $type))->get($args[0]);
138
    }
139
140
    /**
141
     * Run query
142
     *
143
     * @param $query
144
     * @return mixed
145
     */
146
    public function runQuery($query)
147
    {
148
        $response = $this->query($query);
0 ignored issues
show
Documentation Bug introduced by
The method query does not exist on object<Surge\LaravelSalesforce\Salesforce>? 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...
149
150
        if ($response && $response->totalSize > 0) {
151
            return $response->records;
152
        }
153
154
        return false;
155
    }
156
157
    /**
158
     * Run report.
159
     *
160
     * @param string $id
161
     * @param bool   $includeDetails
162
     * @return mixed
163
     *
164
     */
165
    public function getReport(string $id, bool $includeDetails = true)
166
    {
167
        return $this->report($id, $includeDetails);
0 ignored issues
show
The method report() does not exist on Surge\LaravelSalesforce\Salesforce. Did you maybe mean getReport()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
168
    }
169
}
170