From 04732691322ddbdcac86a2fc38a17ee92d94d472 Mon Sep 17 00:00:00 2001 From: bruno DA SILVA Date: Thu, 28 Nov 2019 16:31:12 +0100 Subject: [PATCH] =?UTF-8?q?n=C2=B01617=20-=20iTop=20Fence=20=20-=20iTop=20?= =?UTF-8?q?Fence=20now=20lock=20user=20fetch/creation=20per=20login=20to?= =?UTF-8?q?=20prevent=20duplicates=20=20-=20iTop=20now=20provide=20a=20mea?= =?UTF-8?q?n=20to=20create=20safe=20lock=20when=20used=20untrusted=20strin?= =?UTF-8?q?gs=20=20-=20better=20log=20message=20&=20function=20names=20=20?= =?UTF-8?q?-=20reduced=20cyclomatic=20complexity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (thanks @piRGoif) --- core/mutex.class.inc.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/mutex.class.inc.php b/core/mutex.class.inc.php index 2243eb3a0..b743dcaf9 100644 --- a/core/mutex.class.inc.php +++ b/core/mutex.class.inc.php @@ -88,6 +88,25 @@ class iTopMutex $this->InitMySQLSession(); } + /** + * Get instance of self but with an escaped $sName + * + * this is meant to be used with non trusted string such as user inputs. + * + * @param mixed ...$aArgs smae as __construct() + * + * @return \iTopMutex + * @since 2.7.0 + * + */ + public static function GetInstanceFromUserInput(...$aArgs) + { + $aArgs[0] = \CMDBSource::Quote($aArgs[0]); + + return new iTopMutex(...$aArgs); + } + + public function __destruct() { if ($this->bLocked)