Issues (86)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Trucker/Finders/InstanceFinder.php (6 issues)

1
<?php
2
3
namespace Trucker\Finders;
4
5
use Illuminate\Container\Container;
6
use Trucker\Facades\AuthFactory;
7
use Trucker\Facades\Config;
8
use Trucker\Facades\RequestFactory;
9
use Trucker\Facades\ResponseInterpreterFactory;
10
use Trucker\Facades\UrlGenerator;
11
use Trucker\Resource\Model;
12
13
/**
14
 * Class for finding model instances over the remote API.
15
 *
16
 * @author Alessandro Manno <[email protected]>
17
 */
18
class InstanceFinder
19
{
20
    /**
21
     * The IoC Container.
22
     *
23
     * @var Container
24
     */
25
    protected $app;
26
27
    /**
28
     * Build a new InstanceFinder.
29
     *
30
     * @param Container $app
31
     */
32 1
    public function __construct(Container $app)
33
    {
34 1
        $this->app = $app;
35 1
    }
36
37
    /**
38
     * Function to find an instance of an Entity record.
39
     *
40
     * @param Model $model     model to use for URL generation etc
41
     * @param int   $id        The primary identifier value for the record
42
     * @param array $getParams Array of GET parameters to pass
43
     *
44
     * @return Model An instance of the entity requested
45
     */
46 2
    public function fetch($model, $id, array $getParams = [])
47
    {
48 2
        $instance = null;
0 ignored issues
show
The assignment to $instance is dead and can be removed.
Loading history...
49
50
        //get a request object
51 2
        $request = RequestFactory::build();
0 ignored issues
show
The method build() does not exist on Trucker\Facades\RequestFactory. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        /** @scrutinizer ignore-call */ 
52
        $request = RequestFactory::build();
Loading history...
52
53
        //init the request
54 2
        $request->createRequest(
55 2
            Config::get('request.base_uri'),
0 ignored issues
show
The method get() does not exist on Trucker\Facades\Config. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
            Config::/** @scrutinizer ignore-call */ 
56
                    get('request.base_uri'),
Loading history...
56 2
            UrlGenerator::getInstanceUri($model, [':id' => $id]),
0 ignored issues
show
The method getInstanceUri() does not exist on Trucker\Facades\UrlGenerator. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
            UrlGenerator::/** @scrutinizer ignore-call */ 
57
                          getInstanceUri($model, [':id' => $id]),
Loading history...
57 2
            'GET'
58
        );
59
60
        //add auth if it is needed
61 2
        if ($auth = AuthFactory::build()) {
0 ignored issues
show
The method build() does not exist on Trucker\Facades\AuthFactory. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
        if ($auth = AuthFactory::/** @scrutinizer ignore-call */ build()) {
Loading history...
62
            $request->authenticate($auth);
63
        }
64
65
        //set any get parameters on the request
66 2
        $request->setGetParameters($getParams);
67
68
        //actually send the request
69 2
        $response = $request->sendRequest();
70
71 2
        if (!ResponseInterpreterFactory::build()->success($response)) {
0 ignored issues
show
The method build() does not exist on Trucker\Facades\ResponseInterpreterFactory. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
        if (!ResponseInterpreterFactory::/** @scrutinizer ignore-call */ build()->success($response)) {
Loading history...
72
            return null;
73
        }
74
75
        //kraft the response into an object to return
76 2
        $data = $response->parseResponseToData();
77 2
        $instance = new $model($data);
78
79
        //inflate the ID property that should be guarded
80 2
        $id = $instance->getIdentityProperty();
81 2
        if (array_key_exists($id, $data)) {
82 2
            $instance->{$id} = $data[$id];
83
        }
84
85 2
        return $instance;
86
    }
87
}
88