Issues (1490)

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.

src/Tools/Plugin/Lint.php (2 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 Fabrica\Tools\Plugin;
4
5
use Fabrica\Tools;
6
use Fabrica\Tools\Builder;
7
use Fabrica\Models\Infra\Ci\Build;
8
use Fabrica\Tools\Plugin;
9
10
/**
11
 * PHP Lint Plugin - Provides access to PHP lint functionality.
12
 *
13
 * @author Ricardo Sierra <[email protected]>
14
 */
15
class Lint extends Plugin
16
{
17
    protected $directories;
18
    protected $recursive = true;
19
20
    /**
21
     * @return string
22
     */
23
    public static function pluginName()
24
    {
25
        return 'lint';
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function __construct(Builder $builder, Build $build, array $options = [])
32
    {
33
        parent::__construct($builder, $build, $options);
34
35
        $this->directories = [
36
            $this->directory,
37
        ];
38
39
        if (!empty($options['directories']) && is_array($options['directories'])) {
40
            foreach ($options['directories'] as $index => $directory) {
41
                $relativePath = preg_replace(
42
                    '#^(\./|/)?(.*)$#',
43
                    '$2',
44
                    $options['directories'][$index]
45
                );
46
                $relativePath = rtrim($relativePath, "\//");
47
48
                $this->directories[] = $this->builder->buildPath . $relativePath . '/';
49
            }
50
        }
51
52
        if (array_key_exists('recursive', $options)) {
53
            $this->recursive = $options['recursive'];
54
        }
55
    }
56
57
    /**
58
     * Executes parallel lint
59
     */
60
    public function execute()
61
    {
62
        $success = true;
63
64
        $php = $this->findBinary('php');
65
66
        foreach ($this->directories as $dir) {
67
            if (!$this->lintDirectory($php, $dir)) {
68
                $success = false;
69
            }
70
        }
71
72
        return $success;
73
    }
74
75
    /**
76
     * Lint an item (file or directory) by calling the appropriate method.
77
     *
78
     * @param  $php
79
     * @param  $item
80
     * @param  $itemPath
81
     * @return bool
82
     */
83
    protected function lintItem($php, $item, $itemPath)
84
    {
85
        $success = true;
86
87
        if ($item->isFile() && $item->getExtension() == 'php' && !$this->lintFile($php, $itemPath)) {
88
            $success = false;
89 View Code Duplication
        } elseif ($item->isDir() 
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...
90
            && $this->recursive 
91
            && !$this->lintDirectory($php, ($itemPath . '/'))
92
        ) {
93
            $success = false;
94
        }
95
96
        return $success;
97
    }
98
99
    /**
100
     * Run php -l against a directory of files.
101
     *
102
     * @param  $php
103
     * @param  $path
104
     * @return bool
105
     */
106 View Code Duplication
    protected function lintDirectory($php, $path)
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...
107
    {
108
        $success = true;
109
        $directory = new \DirectoryIterator($this->builder->buildPath . $path);
110
111
        foreach ($directory as $item) {
112
            if ($item->isDot()) {
113
                continue;
114
            }
115
116
            $itemPath = $path . $item->getFilename();
117
118
            if (in_array($itemPath, $this->ignore)) {
119
                continue;
120
            }
121
122
            if (!$this->lintItem($php, $item, $itemPath)) {
123
                $success = false;
124
            }
125
        }
126
127
        return $success;
128
    }
129
130
    /**
131
     * Run php -l against a specific file.
132
     *
133
     * @param  $php
134
     * @param  $path
135
     * @return bool
136
     */
137
    protected function lintFile($php, $path)
138
    {
139
        $success = true;
140
141
        if (!$this->builder->executeCommand($php . ' -l "%s"', $this->builder->buildPath . $path)) {
142
            $this->builder->logFailure($path);
143
            $success = false;
144
        }
145
146
        return $success;
147
    }
148
}
149