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/Git.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\Plugin;
6
7
/**
8
 * Git plugin.
9
 *
10
 * @author Ricardo Sierra <[email protected]>
11
 */
12
class Git extends Plugin
13
{
14
    protected $actions = [];
15
16
    /**
17
     * @return string
18
     */
19
    public static function pluginName()
20
    {
21
        return 'git';
22
    }
23
    
24
    /**
25
     * Run the Git plugin.
26
     *
27
     * @return bool
28
     */
29
    public function execute()
30
    {
31
        // Check if there are any actions to be run for the branch we're running on:
32
        if (!array_key_exists($this->build->getBranch(), $this->actions)) {
33
            return true;
34
        }
35
36
        $success = true;
37
        foreach ($this->actions[$this->build->getBranch()] as $action => $options) {
38
            if (!$this->runAction($action, $options)) {
39
                $success = false;
40
                break;
41
            }
42
        }
43
44
        return $success;
45
    }
46
47
    /**
48
     * Determine which action to run, and run it.
49
     *
50
     * @param  $action
51
     * @param  array $options
52
     * @return bool
53
     */
54
    protected function runAction($action, array $options = [])
55
    {
56
        switch ($action) {
57
        case 'merge':
58
            return $this->runMergeAction($options);
59
60
        case 'tag':
61
            return $this->runTagAction($options);
62
63
        case 'pull':
64
            return $this->runPullAction($options);
65
66
        case 'push':
67
            return $this->runPushAction($options);
68
        }
69
70
71
        return false;
72
    }
73
74
    /**
75
     * Handle a merge action.
76
     *
77
     * @param  $options
78
     * @return bool
79
     */
80
    protected function runMergeAction($options)
81
    {
82
        if (array_key_exists('branch', $options)) {
83
            $cmd = 'cd "%s" && git checkout %s && git merge "%s"';
84
            $path = $this->builder->buildPath;
85
            return $this->builder->executeCommand($cmd, $path, $options['branch'], $this->build->getBranch());
86
        }
87
    }
88
89
    /**
90
     * Handle a tag action.
91
     *
92
     * @param  $options
93
     * @return bool
94
     */
95
    protected function runTagAction($options)
96
    {
97
        $tagName = date('Ymd-His');
98
        $message = sprintf('Tag created by PHP Censor: %s', date('Y-m-d H:i:s'));
99
100
        if (array_key_exists('name', $options)) {
101
            $tagName = $this->builder->interpolate($options['name']);
102
        }
103
104
        if (array_key_exists('message', $options)) {
105
            $message = $this->builder->interpolate($options['message']);
106
        }
107
108
        $cmd = 'git tag %s -m "%s"';
109
        return $this->builder->executeCommand($cmd, $tagName, $message);
110
    }
111
112
    /**
113
     * Handle a pull action.
114
     *
115
     * @param  $options
116
     * @return bool
117
     */
118 View Code Duplication
    protected function runPullAction($options)
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...
119
    {
120
        $branch = $this->build->getBranch();
121
        $remote = 'origin';
122
123
        if (array_key_exists('branch', $options)) {
124
            $branch = $this->builder->interpolate($options['branch']);
125
        }
126
127
        if (array_key_exists('remote', $options)) {
128
            $remote = $this->builder->interpolate($options['remote']);
129
        }
130
131
        return $this->builder->executeCommand('git pull %s %s', $remote, $branch);
132
    }
133
134
    /**
135
     * Handle a push action.
136
     *
137
     * @param  $options
138
     * @return bool
139
     */
140 View Code Duplication
    protected function runPushAction($options)
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...
141
    {
142
        $branch = $this->build->getBranch();
143
        $remote = 'origin';
144
145
        if (array_key_exists('branch', $options)) {
146
            $branch = $this->builder->interpolate($options['branch']);
147
        }
148
149
        if (array_key_exists('remote', $options)) {
150
            $remote = $this->builder->interpolate($options['remote']);
151
        }
152
153
        return $this->builder->executeCommand('git push %s %s', $remote, $branch);
154
    }
155
}
156