mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-26 11:02:31 +01:00
Merge branch 'develop' into patch-1
This commit is contained in:
commit
fd8259f33d
11
CHANGELOG.md
11
CHANGELOG.md
@ -3,6 +3,17 @@ This file is a running track of new features and fixes to each version of the pa
|
|||||||
|
|
||||||
This project follows [Semantic Versioning](http://semver.org) guidelines.
|
This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
|
|
||||||
|
## v1.4.0
|
||||||
|
### Fixed
|
||||||
|
* Removes the use of tagging when storing server resource usage in the cache. This addresses errors encountered when using the `file` driver.
|
||||||
|
* Fixes Wings response handling if Wings returns an error response with a 200-level status code that would improperly be passed back to the client as a successful request.
|
||||||
|
* Fixes use of JSON specific functions in SQL queries to better support MariaDB users.
|
||||||
|
* Fixes a migration that could fail on some MySQL/MariaDB setups when trying to encrypt node token values.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* Increases the maximum length allowed for a server name using the Rust egg.
|
||||||
|
* Updated server resource utilization API call to Wings to use new API response format used by `Wings@1.4.0`.
|
||||||
|
|
||||||
## v1.3.2
|
## v1.3.2
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fixes self-upgrade incorrectly executing the command to un-tar downloaded archives.
|
* Fixes self-upgrade incorrectly executing the command to un-tar downloaded archives.
|
||||||
|
@ -156,10 +156,6 @@ class ScheduleController extends ClientApiController
|
|||||||
*/
|
*/
|
||||||
public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule)
|
public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule)
|
||||||
{
|
{
|
||||||
if (!$schedule->is_active) {
|
|
||||||
throw new BadRequestHttpException('Cannot trigger schedule exection for a schedule that is not currently active.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->service->handle($schedule, true);
|
$this->service->handle($schedule, true);
|
||||||
|
|
||||||
return new JsonResponse([], JsonResponse::HTTP_ACCEPTED);
|
return new JsonResponse([], JsonResponse::HTTP_ACCEPTED);
|
||||||
|
@ -27,13 +27,19 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public $task;
|
public $task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $manualRun;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RunTaskJob constructor.
|
* RunTaskJob constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(Task $task)
|
public function __construct(Task $task, $manualRun = false)
|
||||||
{
|
{
|
||||||
$this->queue = config('pterodactyl.queues.standard');
|
$this->queue = config('pterodactyl.queues.standard');
|
||||||
$this->task = $task;
|
$this->task = $task;
|
||||||
|
$this->manualRun = $manualRun;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,8 +52,8 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||||||
InitiateBackupService $backupService,
|
InitiateBackupService $backupService,
|
||||||
DaemonPowerRepository $powerRepository
|
DaemonPowerRepository $powerRepository
|
||||||
) {
|
) {
|
||||||
// Do not process a task that is not set to active.
|
// Do not process a task that is not set to active, unless it's been manually triggered.
|
||||||
if (!$this->task->schedule->is_active) {
|
if (!$this->task->schedule->is_active && !$this->manualRun) {
|
||||||
$this->markTaskNotQueued();
|
$this->markTaskNotQueued();
|
||||||
$this->markScheduleComplete();
|
$this->markScheduleComplete();
|
||||||
|
|
||||||
@ -101,7 +107,7 @@ class RunTaskJob extends Job implements ShouldQueue
|
|||||||
|
|
||||||
$nextTask->update(['is_queued' => true]);
|
$nextTask->update(['is_queued' => true]);
|
||||||
|
|
||||||
$this->dispatch((new self($nextTask))->delay($nextTask->time_offset));
|
$this->dispatch((new self($nextTask, $this->manualRun))->delay($nextTask->time_offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ class ProcessScheduleService
|
|||||||
$task->update(['is_queued' => true]);
|
$task->update(['is_queued' => true]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$job = new RunTaskJob($task);
|
$job = new RunTaskJob($task, $now);
|
||||||
|
|
||||||
if (!$now) {
|
if (!$now) {
|
||||||
$this->dispatcher->dispatch($job->delay($task->time_offset));
|
$this->dispatcher->dispatch($job->delay($task->time_offset));
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Pterodactyl - Panel
|
|
||||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
||||||
*
|
|
||||||
* This software is licensed under the terms of the MIT license.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Pterodactyl\Traits\Commands;
|
namespace Pterodactyl\Traits\Commands;
|
||||||
|
|
||||||
@ -13,6 +6,20 @@ use Pterodactyl\Exceptions\PterodactylException;
|
|||||||
|
|
||||||
trait EnvironmentWriterTrait
|
trait EnvironmentWriterTrait
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Escapes an environment value by looking for any characters that could
|
||||||
|
* reasonablly cause environment parsing issues. Those values are then wrapped
|
||||||
|
* in quotes before being returned.
|
||||||
|
*/
|
||||||
|
public function escapeEnvironmentValue(string $value): string
|
||||||
|
{
|
||||||
|
if (!preg_match('/^\"(.*)\"$/', $value) && preg_match('/([^\w.\-+\/])+/', $value)) {
|
||||||
|
return sprintf('"%s"', addslashes($value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the .env file for the application using the passed in values.
|
* Update the .env file for the application using the passed in values.
|
||||||
*
|
*
|
||||||
@ -28,14 +35,7 @@ trait EnvironmentWriterTrait
|
|||||||
$saveContents = file_get_contents($path);
|
$saveContents = file_get_contents($path);
|
||||||
collect($values)->each(function ($value, $key) use (&$saveContents) {
|
collect($values)->each(function ($value, $key) use (&$saveContents) {
|
||||||
$key = strtoupper($key);
|
$key = strtoupper($key);
|
||||||
// If the key value is not sorrounded by quotation marks, and contains anything that could reasonably
|
$saveValue = sprintf('%s=%s', $key, $this->escapeEnvironmentValue($value));
|
||||||
// cause environment parsing issues, wrap it in quotes before writing it. This also adds slashes to the
|
|
||||||
// value to ensure quotes within it don't cause us issues.
|
|
||||||
if (!preg_match('/^\"(.*)\"$/', $value) && preg_match('/([^\w.\-+\/])+/', $value)) {
|
|
||||||
$value = sprintf('"%s"', addslashes($value));
|
|
||||||
}
|
|
||||||
|
|
||||||
$saveValue = sprintf('%s=%s', $key, $value);
|
|
||||||
|
|
||||||
if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) {
|
if (preg_match_all('/^' . $key . '=(.*)$/m', $saveContents) < 1) {
|
||||||
$saveContents = $saveContents . PHP_EOL . $saveValue;
|
$saveContents = $saveContents . PHP_EOL . $saveValue;
|
||||||
|
@ -161,7 +161,7 @@ export default () => {
|
|||||||
onDeleted={() => history.push(`/server/${id}/schedules`)}
|
onDeleted={() => history.push(`/server/${id}/schedules`)}
|
||||||
/>
|
/>
|
||||||
</Can>
|
</Can>
|
||||||
{schedule.isActive && schedule.tasks.length > 0 &&
|
{schedule.tasks.length > 0 &&
|
||||||
<Can action={'schedule.update'}>
|
<Can action={'schedule.update'}>
|
||||||
<RunScheduleButton schedule={schedule}/>
|
<RunScheduleButton schedule={schedule}/>
|
||||||
</Can>
|
</Can>
|
||||||
|
@ -51,26 +51,6 @@ class ExecuteScheduleTest extends ClientApiIntegrationTestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test that the schedule is not executed if it is not currently active.
|
|
||||||
*/
|
|
||||||
public function testScheduleIsNotExecutedIfNotActive()
|
|
||||||
{
|
|
||||||
[$user, $server] = $this->generateTestAccount();
|
|
||||||
|
|
||||||
/** @var \Pterodactyl\Models\Schedule $schedule */
|
|
||||||
$schedule = Schedule::factory()->create([
|
|
||||||
'server_id' => $server->id,
|
|
||||||
'is_active' => false,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = $this->actingAs($user)->postJson($this->link($schedule, '/execute'));
|
|
||||||
|
|
||||||
$response->assertStatus(Response::HTTP_BAD_REQUEST);
|
|
||||||
$response->assertJsonPath('errors.0.code', 'BadRequestHttpException');
|
|
||||||
$response->assertJsonPath('errors.0.detail', 'Cannot trigger schedule exection for a schedule that is not currently active.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that a user without the schedule update permission cannot execute it.
|
* Test that a user without the schedule update permission cannot execute it.
|
||||||
*/
|
*/
|
||||||
|
43
tests/Unit/Helpers/EnvironmentWriterTraitTest.php
Normal file
43
tests/Unit/Helpers/EnvironmentWriterTraitTest.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Pterodactyl\Tests\Unit\Helpers;
|
||||||
|
|
||||||
|
use Pterodactyl\Tests\TestCase;
|
||||||
|
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
|
||||||
|
|
||||||
|
class EnvironmentWriterTraitTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider variableDataProvider
|
||||||
|
*/
|
||||||
|
public function testVariableIsEscapedProperly($input, $expected)
|
||||||
|
{
|
||||||
|
$output = (new FooClass())->escapeEnvironmentValue($input);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function variableDataProvider(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['foo', 'foo'],
|
||||||
|
['abc123', 'abc123'],
|
||||||
|
['val"ue', '"val\"ue"'],
|
||||||
|
['my test value', '"my test value"'],
|
||||||
|
['mysql_p@assword', '"mysql_p@assword"'],
|
||||||
|
['mysql_p#assword', '"mysql_p#assword"'],
|
||||||
|
['mysql p@$$word', '"mysql p@$$word"'],
|
||||||
|
['mysql p%word', '"mysql p%word"'],
|
||||||
|
['mysql p#word', '"mysql p#word"'],
|
||||||
|
['abc_@#test', '"abc_@#test"'],
|
||||||
|
['test 123 $$$', '"test 123 $$$"'],
|
||||||
|
['#password%', '"#password%"'],
|
||||||
|
['$pass ', '"$pass "'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FooClass
|
||||||
|
{
|
||||||
|
use EnvironmentWriterTrait;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user