| 1 |
<?php |
| 2 |
|
| 3 |
namespace Shellbox\Command; |
| 4 |
|
| 5 |
use Psr\Log\LoggerInterface; |
| 6 |
use Psr\Log\NullLogger; |
| 7 |
|
| 8 |
/** |
| 9 |
* Base class for wrappers that modify commands. Such wrappers are used by |
| 10 |
* UnboxedExecutor to implement restrictions. |
| 11 |
*/ |
| 12 |
abstract class Wrapper { |
| 13 |
/** @var LoggerInterface */ |
| 14 |
protected $logger; |
| 15 |
|
| 16 |
public function __construct() { |
| 17 |
$this->logger = new NullLogger; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Set the logger. |
| 22 |
* |
| 23 |
* @param LoggerInterface $logger |
| 24 |
*/ |
| 25 |
public function setLogger( LoggerInterface $logger ) { |
| 26 |
$this->logger = $logger; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Modify the command passed as a parameter |
| 31 |
* |
| 32 |
* @param Command $command |
| 33 |
*/ |
| 34 |
abstract public function wrap( Command $command ); |
| 35 |
|
| 36 |
/** |
| 37 |
* Get an integer priority level used to determine the order in which to |
| 38 |
* run multiple wrappers. Low numbers are innermost, high numbers are |
| 39 |
* outermost, run last. |
| 40 |
* |
| 41 |
* If you nest sandboxes, it makes sense to have the most privileged |
| 42 |
* hypervisor/wrapper at the outside, and the least privileged on the |
| 43 |
* inside. Suggested values: |
| 44 |
* |
| 45 |
* - 20: ulimit |
| 46 |
* - 40: chroot |
| 47 |
* - 60: system-level container |
| 48 |
* - 80: initial shell |
| 49 |
* |
| 50 |
* @return int |
| 51 |
*/ |
| 52 |
abstract public function getPriority(); |
| 53 |
} |