Compare commits

...

4 Commits

Author SHA1 Message Date
Stephen Abello
c3cf07efc9 Inverted comparison 2026-02-19 16:27:42 +01:00
Stephen Abello
829bc3bf42 Also update legacy code in case it's used 2026-02-19 16:25:10 +01:00
Stephen Abello
504ecf42a5 Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-19 16:20:06 +01:00
Stephen Abello
4ac5269b7c N°8549 - Update inline images secret 2026-02-19 16:07:10 +01:00
2 changed files with 3 additions and 4 deletions

View File

@@ -362,8 +362,7 @@ class ormDocument
throw new Exception("Invalid id ($id) for class '$sClass' - the object does not exist or you are not allowed to view it");
}
}
if (($sSecretField != null) && ($oObj->Get($sSecretField) != $sSecretValue)) {
usleep(200);
if (($sSecretField != null) && !hash_equals($oObj->Get($sSecretField), $sSecretValue)) {
throw new Exception("Invalid secret for class '$sClass' - the object does not exist or you are not allowed to view it");
}
/** @var \ormDocument $oDocument */

View File

@@ -2136,7 +2136,7 @@ EOF
$oAttachment->Set('item_class', $sObjClass);
$oAttachment->SetDefaultOrgId();
$oAttachment->Set('contents', $oDoc);
$oAttachment->Set('secret', sprintf('%06x', mt_rand(0, 0xFFFFFF))); // something not easy to guess
$oAttachment->Set('secret', bin2hex(random_bytes(16))); // 128 bits of entropy, cryptographically secure
$iAttId = $oAttachment->DBInsert();
$aResult['uploaded'] = 1;
@@ -2194,7 +2194,7 @@ EOF
$oAttachment->Set('item_class', $sObjClass);
$oAttachment->SetDefaultOrgId();
$oAttachment->Set('contents', $oDoc);
$oAttachment->Set('secret', sprintf('%06x', mt_rand(0, 0xFFFFFF))); // something not easy to guess
$oAttachment->Set('secret', bin2hex(random_bytes(16))); // 128 bits of entropy, cryptographically secure
$iAttId = $oAttachment->DBInsert();
IssueLog::Trace('InlineImage created', LogChannels::INLINE_IMAGE, [