Issues (258)

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.

Ship/core/Abstracts/Repositories/Repository.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
namespace Apiato\Core\Abstracts\Repositories;
4
5
use Illuminate\Support\Facades\Config;
6
use Prettus\Repository\Contracts\CacheableInterface as PrettusCacheable;
7
use Prettus\Repository\Criteria\RequestCriteria as PrettusRequestCriteria;
8
use Prettus\Repository\Eloquent\BaseRepository as PrettusRepository;
9
use Prettus\Repository\Traits\CacheableRepository as PrettusCacheableRepository;
10
use Request;
11
12
/**
13
 * Class Repository.
14
 *
15
 * @author  Mahmoud Zalt <[email protected]>
16
 */
17
abstract class Repository extends PrettusRepository implements PrettusCacheable
18
{
19
20
    use PrettusCacheableRepository;
21
    
22
    /**
23
     * Define the maximum amount of entries per page that is returned. 
24
     * Set to 0 to "disable" this feature
25
     */
26
    protected $maxPaginationLimit = 0;
27
28
    /**
29
     * This function relies on strict conventions.
30
     * Conventions:
31
     *    - Repository name should be same like it's model name (model: Foo -> repository: FooRepository).
32
     *    - If the container contains Models with names different than the container name, the repository class must
33
     *          set `$container='ContainerName'` property for this function to work properly
34
     * Specify Model class name.
35
     *
36
     * @return string
37
     */
38
    public function model()
39
    {
40
        // 1_ get the full namespace of the child class who's extending this class.
41
        // 2_ remove the namespace and keep the class name
42
        // 3_ remove the word Repository from the class name
43
        // 4_ check if the container name is set on the repository to indicate that the
44
        //    model has different name than the container holding it
45
        // 5_ build the namespace of the Model based on the conventions
46
47
        $fullName = get_called_class();
48
        $className = substr($fullName, strrpos($fullName, '\\') + 1);
49
        $classOnly = str_replace('Repository', '', $className);
50
        $modelNamespace = 'App\Containers\\' . $this->getCurrentContainer() . '\\Models\\' . $classOnly;
51
52
        return $modelNamespace;
53
    }
54
55
    /**
56
     * Boot up the repository, pushing criteria.
57
     */
58
    public function boot()
59
    {
60
        // only apply the RequestCriteria if config flag is set!
61
        if (Config::get('apiato.requests.automatically-apply-request-criteria', true)) {
62
            $this->pushCriteria(app(PrettusRequestCriteria::class));
63
        }
64
    }
65
66
    /**
67
     * Paginate the response
68
     *
69
     * Apply pagination to the response. Use ?limit= to specify the amount of entities in the response.
70
     * The client can request all data (skipping pagination) by applying ?limit=0 to the request, if
71
     * PAGINATION_SKIP is set to true.
72
     *
73
     * @param null   $limit
74
     * @param array  $columns
75
     * @param string $method
76
     *
77
     * @return  mixed
78
     */
79
    public function paginate($limit = null, $columns = ['*'], $method = "paginate")
80
    {
81
        // the priority is for the function parameter, if not available then take
82
        // it from the request if available and if not keep it null.
83
        $limit = $limit ?: Request::get('limit');
84
85
        // check, if skipping pagination is allowed and the requested by the user
86
        if (Config::get('repository.pagination.skip') && $limit == "0") {
87
            return parent::all($columns);
0 ignored issues
show
Comprehensibility Bug introduced by Mahmoud Zalt
It seems like you call parent on a different method (all() instead of paginate()). Are you sure this is correct? If so, you might want to change this to $this->all().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
88
        }
89
90
        // check for the maximum entries per pagination
91
        if (   is_int($this->maxPaginationLimit) 
92
            && $this->maxPaginationLimit > 0 
93
            && $limit > $this->maxPaginationLimit
94
        ) {
95
            $limit = $this->maxPaginationLimit;
96
        }
97
98
        return parent::paginate($limit, $columns, $method);
99
    }
100
101
    private function getCurrentContainer(): string
102
    {
103
        return substr(str_replace("App\\Containers\\", "", get_called_class()), 0, strpos(str_replace("App\\Containers\\", "", get_called_class()), '\\'));
104
    }
105
106
}
107