From 2bfc7a0dcd5a825f71a4214398bc7a77d7e3788c Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Wed, 11 Nov 2020 17:25:41 +0100 Subject: [PATCH] Add CLI output option to MD_JAIL --- MD_JAIL.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MD_JAIL.php b/MD_JAIL.php index 6199214..b6a923b 100644 --- a/MD_JAIL.php +++ b/MD_JAIL.php @@ -106,6 +106,20 @@ final class MD_JAIL { */ public function enforce():void { + // Special instructions on CLI, so as to not disturb PHPUnit + if (PHP_SAPI === 'cli') { + + if (!isset($this->memory_limit)) { + throw new MDJailSecurityOptionNotSetException("It has not been specified, which memory limit the script should hold. Set MD_JAIL->memory_limit = string."); + } + if (!isset($this->max_execution_time)) { + throw new MDJailSecurityOptionNotSetException("It has not been specified, which maximum execution time the script should hold. Set MD_JAIL->max_execution_time = integer."); + } + + $this->_status = self::STATUS_SPECIFIED; + $this->__destruct(); + } + $this->_apply_memory_limit(); $this->_apply_time_limit();