Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core/ormlinkset.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ protected function GetArrayOfIndex()
{
$aRet = array();
$this->oOriginalSet->Rewind();
$this->oOriginalSet->OptimizeColumnLoad([$this->sClass => []]);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OptimizeColumnLoad() expects an array keyed by class alias (see DBObjectSet::OptimizeColumnLoad()), but this uses $this->sClass (class name). If the underlying filter alias was renamed (eg to Link in indirect linkedsets), this optimization won’t apply and the set may still load all columns. Use the original filter’s class alias (eg $this->oOriginalSet->GetFilter()->GetClassAlias()) as the key.

Suggested change
$this->oOriginalSet->OptimizeColumnLoad([$this->sClass => []]);
$oFilter = $this->oOriginalSet->GetFilter();
$sClassAlias = $oFilter->GetClassAlias();
$this->oOriginalSet->OptimizeColumnLoad([$sClassAlias => []]);

Copilot uses AI. Check for mistakes.
$iRow = 0;
while ($oObject = $this->oOriginalSet->Fetch())
{
Expand Down Expand Up @@ -321,8 +322,6 @@ public function Seek($iPosition): void
*/
public function Fetch()
{
$this->LoadOriginalIds();

$ret = $this->current();
if ($ret === false)
{
Expand Down Expand Up @@ -353,7 +352,7 @@ public function current()
if ($this->iCursor < $iPreservedCount)
{
$sId = key($this->aPreserved);
$oRet = MetaModel::GetObject($this->sClass, $sId);
$oRet = MetaModel::GetObject($this->sClass, $sId, true, true);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MetaModel::GetObject($this->sClass, $sId, true, true) sets $bAllowAllData=true, which bypasses user-rights filtering for every ormLinkSet iteration. As ormLinkSet is a core structure used outside the portal, this can expose objects/fields a user is not allowed to read. Instead, pass the AllowAllData flag from the original set/search (eg based on $this->oOriginalSet->GetFilter()->IsAllDataAllowed()), so ignoring silos only happens when the underlying query explicitly allows it.

Suggested change
$oRet = MetaModel::GetObject($this->sClass, $sId, true, true);
$bAllowAllData = false;
if ($this->oOriginalSet !== null)
{
$bAllowAllData = $this->oOriginalSet->GetFilter()->IsAllDataAllowed();
}
$oRet = MetaModel::GetObject($this->sClass, $sId, true, $bAllowAllData);

Copilot uses AI. Check for mistakes.
}
else
{
Expand Down
10 changes: 10 additions & 0 deletions sources/Core/AttributeDefinition/AttributeLinkedSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use CMDBSource;
use Combodo\iTop\Application\UI\Links\Set\BlockLinkSetDisplayAsProperty;
use Combodo\iTop\Form\Field\LinkedSetField;
use Combodo\iTop\Portal\Helper\ScopeValidatorHelper;
use Combodo\iTop\Renderer\Console\ConsoleBlockRenderer;
use Combodo\iTop\Service\Links\LinkSetModel;
use CoreException;
Expand All @@ -21,6 +22,7 @@
use ExceptionLog;
use IssueLog;
use MetaModel;
use ModuleDesign;
use ormLinkSet;
use ValueSetObjects;

Expand Down Expand Up @@ -154,6 +156,14 @@ public function GetDefaultValue(DBObject $oHostObject = null)
$oLinkSearch->AddCondition_PointingTo($oRemoteSearch, $this->GetExtKeyToRemote());
}
}
//Add silo in portal context
if (defined('PORTAL_ID'))
{
$oModuleDesign = new ModuleDesign(PORTAL_ID);
$oScopeValidatorHelper = new ScopeValidatorHelper($oModuleDesign, PORTAL_ID);
$oScopeValidatorHelper->AddScopeToQuery($oLinkSearch, $oLinkSearch->GetClass());
}

$oLinks = new DBObjectSet($oLinkSearch);
$oLinkSet = new ormLinkSet($this->GetHostClass(), $this->GetCode(), $oLinks);

Expand Down