From 3d9f656cfcebc0eebee073d11d0e3d05063731e9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 25 Nov 2013 14:55:25 -0800 Subject: [PATCH] Timeout `interpreter {{{ ... }}}` blocks after 15 seconds Summary: Fixes T4149. This could be a little cleaner (configurable time limits, explicit timeout errors) but stop the major case of looping/infinite commands. Test Plan: Added `sleep 5 &&` and set timeout to 1, saw an error + kill. Reviewers: btrahan, skyronic Reviewed By: btrahan CC: aran Maniphest Tasks: T4149 Differential Revision: https://secure.phabricator.com/D7651 --- .../PhabricatorRemarkupBlockInterpreterCowsay.php | 1 + .../PhabricatorRemarkupBlockInterpreterFiglet.php | 1 + .../PhabricatorRemarkupBlockInterpreterGraphviz.php | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterCowsay.php b/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterCowsay.php index 07e6ca611b..e4c5be4c30 100644 --- a/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterCowsay.php +++ b/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterCowsay.php @@ -29,6 +29,7 @@ final class PhabricatorRemarkupBlockInterpreterCowsay $tongue, $cow); + $future->setTimeout(15); $future->write($content); list($err, $stdout, $stderr) = $future->resolve(); diff --git a/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterFiglet.php b/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterFiglet.php index 35370e2aa2..aae99d7dd5 100644 --- a/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterFiglet.php +++ b/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterFiglet.php @@ -14,6 +14,7 @@ final class PhabricatorRemarkupBlockInterpreterFiglet } $future = id(new ExecFuture('figlet')) + ->setTimeout(15) ->write(trim($content, "\n")); list($err, $stdout, $stderr) = $future->resolve(); diff --git a/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterGraphviz.php b/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterGraphviz.php index 79ec668f8c..e165f17532 100644 --- a/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterGraphviz.php +++ b/src/infrastructure/markup/interpreter/PhabricatorRemarkupBlockInterpreterGraphviz.php @@ -14,6 +14,7 @@ final class PhabricatorRemarkupBlockInterpreterGraphviz } $future = id(new ExecFuture('dot -T%s', 'png')) + ->setTimeout(15) ->write(trim($content)); list($err, $stdout, $stderr) = $future->resolve(); @@ -21,7 +22,9 @@ final class PhabricatorRemarkupBlockInterpreterGraphviz if ($err) { return $this->markupError( pht( - 'Execution of `dot` failed, check your syntax: %s', $stderr)); + 'Execution of `dot` failed (#%d), check your syntax: %s', + $err, + $stderr)); } $file = PhabricatorFile::buildFromFileDataOrHash(