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.

app/Ship/core/Loaders/SeederLoaderTrait.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\Loaders;
4
5
use Apiato\Core\Foundation\Facades\Apiato;
6
use File;
7
use Illuminate\Support\Collection;
8
9
/**
10
 * Class SeederLoaderTrait.
11
 *
12
 * This Class has inverted dependency :( you must extend this class from the default
13
 * seeder class provided by the framework (database/seeds/DatabaseSeeder.php)
14
 *
15
 * @author  Mahmoud Zalt <[email protected]>
16
 */
17
trait SeederLoaderTrait
18
{
19
20
    /**
21
     * Default seeders directory for containers and port
22
     *
23
     * @var  string
24
     */
25
    protected $seedersPath = '/Data/Seeders';
26
27
    /**
28
     * runLoadingSeeders
29
     */
30
    public function runLoadingSeeders()
31
    {
32
        $this->loadSeedersFromContainers();
33
        $this->loadSeedersFromShip();
34
    }
35
36
    /**
37
     * loadSeedersFromContainers
38
     */
39
    private function loadSeedersFromContainers()
40
    {
41
        $seedersClasses = new Collection();
42
43
        $containersDirectories = [];
44
45
        foreach (Apiato::getContainersNames() as $containerName) {
46
47
            $containersDirectories[] = base_path('app/Containers/' . $containerName . $this->seedersPath);
48
49
        }
50
51
        $seedersClasses = $this->findSeedersClasses($containersDirectories, $seedersClasses);
52
        $orderedSeederClasses = $this->sortSeeders($seedersClasses);
53
54
        $this->loadSeeders($orderedSeederClasses);
55
    }
56
57
    /**
58
     * loadSeedersFromShip
59
     */
60
    private function loadSeedersFromShip()
61
    {
62
//        $seedersClasses = new Collection();
63
//
64
//        // it has to do it's own loop for now
65
//        foreach (Apiato::getShipFoldersNames() as $portFolderName) {
66
//
67
//            // Need to Loop over that Directory and load the any Seeder file there.
68
//            $containersDirectories[] = base_path('app/Ship/Seeders/Tests');
69
//        }
70
//
71
//        $seedersClasses = $this->findSeedersClasses($containersDirectories, $seedersClasses);
72
//        $orderedSeederClasses = $this->sortSeeders($seedersClasses);
73
//
74
//        $this->loadSeeders($orderedSeederClasses);
75
    }
76
77
    /**
78
     * @param array $directories
79
     * @param       $seedersClasses
80
     *
81
     * @return  mixed
82
     */
83
    private function findSeedersClasses(array $directories, $seedersClasses)
84
    {
85 View Code Duplication
        foreach ($directories as $directory) {
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...
86
87
            if (File::isDirectory($directory)) {
88
89
                $files = File::allFiles($directory);
90
91
                foreach ($files as $seederClass) {
92
93
                    if (File::isFile($seederClass)) {
94
95
                        // do not seed the classes now, just store them in a collection and w
96
                        $seedersClasses->push(
97
                            Apiato::getClassFullNameFromFile(
98
                                $seederClass->getPathname())
99
                        );
100
                    }
101
                }
102
            }
103
        }
104
105
        return $seedersClasses;
106
    }
107
108
    /**
109
     * @param $seedersClasses
110
     *
111
     * @return  \Illuminate\Support\Collection
112
     */
113
    private function sortSeeders($seedersClasses)
114
    {
115
        $orderedSeederClasses = new Collection();
116
117
        if ($seedersClasses->isEmpty()) {
118
            return $orderedSeederClasses;
119
        }
120
121
        foreach ($seedersClasses as $key => $seederFullClassName) {
122
            // if the class full namespace contain "_" it means it needs to be seeded in order
123
            if (preg_match('/_/', $seederFullClassName)) {
124
                // move all the seeder classes that needs to be seeded in order to their own Collection
125
                $orderedSeederClasses->push($seederFullClassName);
126
                // delete the moved classes from the original collection
127
                $seedersClasses->forget($key);
128
            }
129
        }
130
131
        // sort the classes that needed to be ordered
132
        $orderedSeederClasses = $orderedSeederClasses->sortBy(function ($seederFullClassName) {
133
            // get the order number form the end of each class name
134
            $orderNumber = substr($seederFullClassName, strpos($seederFullClassName, "_") + 1);
135
136
            return $orderNumber;
137
        });
138
139
        // append the randomly ordered seeder classes to the end of the ordered seeder classes
140
        foreach ($seedersClasses as $seederClass) {
141
            $orderedSeederClasses->push($seederClass);
142
        }
143
144
        return $orderedSeederClasses;
145
    }
146
147
    /**
148
     * @param $seedersClasses
149
     */
150
    private function loadSeeders($seedersClasses)
151
    {
152
        foreach ($seedersClasses as $seeder) {
153
            // seed it with call
154
            $this->call($seeder);
155
        }
156
    }
157
158
}
159