Merge branch 'develop' of https://github.com/Pterodactyl/Panel into develop

This commit is contained in:
Dane Everitt 2020-10-17 14:23:06 -07:00
commit 9621f923f5
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 37 additions and 1 deletions

View file

@ -3,6 +3,7 @@
namespace Pterodactyl\Http\Controllers\Admin; namespace Pterodactyl\Http\Controllers\Admin;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\Nest; use Pterodactyl\Models\Nest;
use Pterodactyl\Models\Mount; use Pterodactyl\Models\Mount;
@ -101,7 +102,6 @@ class MountController extends Controller
*/ */
public function create(MountFormRequest $request) public function create(MountFormRequest $request)
{ {
/** @var \Pterodactyl\Models\Mount $mount */
$model = (new Mount())->fill($request->validated()); $model = (new Mount())->fill($request->validated());
$model->forceFill(['uuid' => Uuid::uuid4()->toString()]); $model->forceFill(['uuid' => Uuid::uuid4()->toString()]);

View file

@ -2,6 +2,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use Illuminate\Validation\Rules\NotIn;
/** /**
* @property int $id * @property int $id
* @property string $uuid * @property string $uuid
@ -63,6 +65,20 @@ class Mount extends Model
'user_mountable' => 'sometimes|boolean', 'user_mountable' => 'sometimes|boolean',
]; ];
/**
* Implement language verification by overriding Eloquence's gather
* rules function.
*/
public static function getRules()
{
$rules = parent::getRules();
$rules['source'][] = new NotIn(Mount::$invalidSourcePaths);
$rules['target'][] = new NotIn(Mount::$invalidTargetPaths);
return $rules;
}
/** /**
* Disable timestamps on this model. * Disable timestamps on this model.
* *
@ -70,6 +86,26 @@ class Mount extends Model
*/ */
public $timestamps = false; public $timestamps = false;
/**
* Blacklisted source paths
*
* @var string[]
*/
public static $invalidSourcePaths = [
'/etc/pterodactyl',
'/var/lib/pterodactyl/volumes',
'/srv/daemon-data',
];
/**
* Blacklisted target paths
*
* @var string[]
*/
public static $invalidTargetPaths = [
'/home/container',
];
/** /**
* Returns all eggs that have this mount assigned. * Returns all eggs that have this mount assigned.
* *