Add internal support for file denylist on eggs; closes #569
This commit is contained in:
parent
ff21d83e2d
commit
239984f92c
7 changed files with 64 additions and 2 deletions
|
@ -22,6 +22,7 @@ class EggFormRequest extends AdminFormRequest
|
||||||
'name' => 'required|string|max:191',
|
'name' => 'required|string|max:191',
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
'docker_images' => 'required|string',
|
'docker_images' => 'required|string',
|
||||||
|
'file_denylist' => 'string',
|
||||||
'startup' => 'required|string',
|
'startup' => 'required|string',
|
||||||
'config_from' => 'sometimes|bail|nullable|numeric',
|
'config_from' => 'sometimes|bail|nullable|numeric',
|
||||||
'config_stop' => 'required_without:config_from|nullable|string|max:191',
|
'config_stop' => 'required_without:config_from|nullable|string|max:191',
|
||||||
|
@ -43,7 +44,7 @@ class EggFormRequest extends AdminFormRequest
|
||||||
public function withValidator($validator)
|
public function withValidator($validator)
|
||||||
{
|
{
|
||||||
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
||||||
return (int) $this->input('config_from') !== 0;
|
return (int)$this->input('config_from') !== 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Pterodactyl\Models;
|
||||||
* @property string $docker_image -- deprecated, use $docker_images
|
* @property string $docker_image -- deprecated, use $docker_images
|
||||||
* @property string $update_url
|
* @property string $update_url
|
||||||
* @property array $docker_images
|
* @property array $docker_images
|
||||||
|
* @property string $file_denylist
|
||||||
* @property string|null $config_files
|
* @property string|null $config_files
|
||||||
* @property string|null $config_startup
|
* @property string|null $config_startup
|
||||||
* @property string|null $config_logs
|
* @property string|null $config_logs
|
||||||
|
@ -34,6 +35,7 @@ namespace Pterodactyl\Models;
|
||||||
* @property string|null $inherit_config_startup
|
* @property string|null $inherit_config_startup
|
||||||
* @property string|null $inherit_config_logs
|
* @property string|null $inherit_config_logs
|
||||||
* @property string|null $inherit_config_stop
|
* @property string|null $inherit_config_stop
|
||||||
|
* @property string $inherit_file_denylist
|
||||||
* @property array|null $inherit_features
|
* @property array|null $inherit_features
|
||||||
*
|
*
|
||||||
* @property \Pterodactyl\Models\Nest $nest
|
* @property \Pterodactyl\Models\Nest $nest
|
||||||
|
@ -79,6 +81,7 @@ class Egg extends Model
|
||||||
'description',
|
'description',
|
||||||
'features',
|
'features',
|
||||||
'docker_images',
|
'docker_images',
|
||||||
|
'file_denylist',
|
||||||
'config_files',
|
'config_files',
|
||||||
'config_startup',
|
'config_startup',
|
||||||
'config_logs',
|
'config_logs',
|
||||||
|
@ -255,6 +258,21 @@ class Egg extends Model
|
||||||
return $this->configFrom->features;
|
return $this->configFrom->features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the features available to this egg from the parent configuration if there are
|
||||||
|
* no features defined for this egg specifically and there is a parent egg configured.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getInheritFileDenylistAttribute()
|
||||||
|
{
|
||||||
|
if (is_null($this->config_from)) {
|
||||||
|
return $this->file_denylist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->configFrom->file_denylist;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets nest associated with an egg.
|
* Gets nest associated with an egg.
|
||||||
*
|
*
|
||||||
|
|
|
@ -46,6 +46,7 @@ class EggExporterService
|
||||||
'description' => $egg->description,
|
'description' => $egg->description,
|
||||||
'features' => $egg->features,
|
'features' => $egg->features,
|
||||||
'images' => $egg->docker_images,
|
'images' => $egg->docker_images,
|
||||||
|
'file_denylist' => $egg->inherit_file_denylist,
|
||||||
'startup' => $egg->startup,
|
'startup' => $egg->startup,
|
||||||
'config' => [
|
'config' => [
|
||||||
'files' => $egg->inherit_config_files,
|
'files' => $egg->inherit_config_files,
|
||||||
|
|
|
@ -105,6 +105,7 @@ class EggImporterService
|
||||||
// Maintain backwards compatability for eggs that are still using the old single image
|
// Maintain backwards compatability for eggs that are still using the old single image
|
||||||
// string format. New eggs can provide an array of Docker images that can be used.
|
// string format. New eggs can provide an array of Docker images that can be used.
|
||||||
'docker_images' => object_get($parsed, 'images') ?? [object_get($parsed, 'image')],
|
'docker_images' => object_get($parsed, 'images') ?? [object_get($parsed, 'image')],
|
||||||
|
'file_denylist' => implode(PHP_EOL, object_get($parsed, 'file_denylist') ?? []),
|
||||||
'update_url' => object_get($parsed, 'meta.update_url'),
|
'update_url' => object_get($parsed, 'meta.update_url'),
|
||||||
'config_files' => object_get($parsed, 'config.files'),
|
'config_files' => object_get($parsed, 'config.files'),
|
||||||
'config_startup' => object_get($parsed, 'config.startup'),
|
'config_startup' => object_get($parsed, 'config.startup'),
|
||||||
|
@ -118,7 +119,7 @@ class EggImporterService
|
||||||
], true, true);
|
], true, true);
|
||||||
|
|
||||||
collect($parsed->variables)->each(function ($variable) use ($egg) {
|
collect($parsed->variables)->each(function ($variable) use ($egg) {
|
||||||
$this->eggVariableRepository->create(array_merge((array) $variable, [
|
$this->eggVariableRepository->create(array_merge((array)$variable, [
|
||||||
'egg_id' => $egg->id,
|
'egg_id' => $egg->id,
|
||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,6 +91,14 @@ class ServerConfigurationStructureService
|
||||||
'read_only' => $mount->read_only,
|
'read_only' => $mount->read_only,
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
|
'egg' => [
|
||||||
|
'id' => $server->egg->uuid,
|
||||||
|
'file_denylist' => [
|
||||||
|
'config.yml',
|
||||||
|
'**/*.json'
|
||||||
|
]
|
||||||
|
// 'file_denylist' => explode(PHP_EOL, $server->egg->inherit_file_denylist),
|
||||||
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ class EggTransformer extends BaseTransformer
|
||||||
'startup' => json_decode($model->config_startup, true),
|
'startup' => json_decode($model->config_startup, true),
|
||||||
'stop' => $model->config_stop,
|
'stop' => $model->config_stop,
|
||||||
'logs' => json_decode($model->config_logs, true),
|
'logs' => json_decode($model->config_logs, true),
|
||||||
|
'file_denylist' => explode(PHP_EOL, $model->file_denylist),
|
||||||
'extends' => $model->config_from,
|
'extends' => $model->config_from,
|
||||||
],
|
],
|
||||||
'startup' => $model->startup,
|
'startup' => $model->startup,
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddFileDenylistToEggConfigs extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('eggs', function (Blueprint $table) {
|
||||||
|
$table->text('file_denylist')->after('docker_images');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('eggs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('file_denylist');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue