Issues (220)

Security Analysis    no request data  

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/Console/Commands/PublishDeploymentScript.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 Acacha\ForgePublish\Commands;
4
5
use Acacha\ForgePublish\Commands\Traits\ChecksEnv;
6
use Acacha\ForgePublish\Commands\Traits\DiesIfEnvVariableIsnotInstalled;
7
use GuzzleHttp\Client;
8
use Illuminate\Console\Command;
9
use Illuminate\Support\Facades\File;
10
11
/**
12
 * Class PublishDeploymentScript.
13
 *
14
 * @package Acacha\ForgePublish\Commands
15
 */
16
class PublishDeploymentScript extends Command
17
{
18
    use ChecksEnv, DiesIfEnvVariableIsnotInstalled;
19
20
    /**
21
     * The name and signature of the console command.
22
     *
23
     * @var string
24
     */
25
    protected $signature = 'publish:deployment_script {file?} {--server=} {--site=}';
26
27
    /**
28
     * The console command description.
29
     *
30
     * @var string
31
     */
32
    protected $description = 'Deployment script on Laravel Forge site';
33
34
    /**
35
     * Server forge id.
36
     *
37
     * @var string
38
     */
39
    protected $server;
40
41
    /**
42
     * Laravel forge site id.
43
     *
44
     * @var string
45
     */
46
    protected $site;
47
48
49
    /**
50
     * File with new script content.
51
     *
52
     * @var string
53
     */
54
    protected $file;
55
56
    /**
57
     * Guzzle http client.
58
     *
59
     * @var Client
60
     */
61
    protected $http;
62
63
    /**
64
     * Create a new command instance.
65
     *
66
     */
67
    public function __construct(Client $http)
68
    {
69
        parent::__construct();
70
        $this->http = $http;
71
    }
72
73
    /**
74
     * Execute the console command.
75
     *
76
     */
77
    public function handle()
78
    {
79
        $this->abortCommandExecution();
80
81
        if ($this->file = $this->argument('file')) {
82
            $this->updateDeploymentScript();
83
        } else {
84
            $this->showDeploymentScript();
85
        }
86
    }
87
88
    protected function showDeploymentScript()
89
    {
90
        $this->info('Deployment script for site ' . $this->site . ':');
91
92
        $this->url = $this->obtainAPIURLEndpoint('show_deployment_script_uri');
93
94
        $script = $this->http->get($this->url, [
95
                'headers' => [
96
                    'X-Requested-With' => 'XMLHttpRequest',
97
                    'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
98
                ]
99
            ]
100
        );
101
102
        $this->info('');
103
        $this->line($script->getBody()->getContents());
104
    }
105
106
    /**
107
     * Update deployment script.
108
     */
109 View Code Duplication
    protected function updateDeploymentScript()
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...
110
    {
111
        $this->info('Updating deployment script for site ' . $this->site . '...');
112
113
        $this->url = $this->obtainAPIURLEndpoint('update_deployment_script_uri');
114
115
        if (! File::exists($this->file)) {
116
            $this->error("File " . $this->file . " doesn't exists");
117
            die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method updateDeploymentScript() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
118
        }
119
120
        $this->http->put($this->url, [
121
                'form_params' => [
122
                    'content' => file_get_contents($this->file)
123
                ],
124
                'headers' => [
125
                    'X-Requested-With' => 'XMLHttpRequest',
126
                    'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
127
                ]
128
            ]
129
        );
130
    }
131
132
    /**
133
     * Obtain API URL endpoint.
134
     *
135
     * @return string
136
     */
137
    protected function obtainAPIURLEndpoint($type)
138
    {
139
        $uri = str_replace('{forgeserver}', $this->server, config('forge-publish.' . $type));
140
        $uri = str_replace('{forgesite}', $this->site, $uri);
141
        return config('forge-publish.url') . $uri;
142
    }
143
144
    /**
145
     * Abort command execution.
146
     */
147
    protected function abortCommandExecution()
148
    {
149
        $this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
150
        $this->site = $this->checkEnv('site', 'ACACHA_FORGE_SITE');
151
        $this->dieIfEnvVarIsNotInstalled('ACACHA_FORGE_ACCESS_TOKEN');
152
    }
153
}
154