Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request from GHSA-qcmg-vr56-x9wf
v2.9 Backport
  • Loading branch information
nilmerg committed Mar 8, 2022
2 parents a06d915 + fda5a59 commit 6e989d0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
Expand Up @@ -89,7 +89,7 @@ protected function joinBaseTables()
[]
)->join(
['co' => $this->prefix . 'objects'],
'co.object_id = c.contact_object_id AND co.is_active = 1',
'co.object_id = c.contact_object_id AND co.is_active = 1 AND co.objecttype_id = 10',
[]
);

Expand Down Expand Up @@ -153,7 +153,7 @@ protected function joinHosts()
[]
)->joinLeft(
['ho' => $this->prefix . 'objects'],
'ho.object_id = h.host_object_id AND ho.is_active = 1',
'ho.object_id = h.host_object_id AND ho.is_active = 1 AND ho.objecttype_id = 1',
[]
);
}
Expand Down
Expand Up @@ -72,7 +72,7 @@ protected function joinBaseTables()
array()
)->join(
array('s' => $this->prefix . 'services'),
's.service_object_id = so.object_id AND so.is_active = 1',
's.service_object_id = so.object_id AND so.is_active = 1 AND so.objecttype_id = 2',
array()
);
$this->select->group('so.name1');
Expand Down
Expand Up @@ -1191,14 +1191,32 @@ protected function joinCustomvar($customvar)

$this->customVars[strtolower($customvar)] = $alias;

if ($this->hasJoinedVirtualTable('services')) {
$leftcol = 's.' . $type . '_object_id';
} elseif ($type === 'service') {
$this->requireVirtualTable('services');
$leftcol = 's.service_object_id';
} else {
$this->requireVirtualTable('hosts');
$leftcol = 'h.host_object_id';
if ($type === 'host') {
if (
$this instanceof HostserviceproblemsummaryQuery
|| $this instanceof ServicecommentQuery
|| $this instanceof ServicedowntimeQuery
|| $this instanceof ServicecommenthistoryQuery
|| $this instanceof ServicedowntimestarthistoryQuery
|| $this instanceof ServiceflappingstarthistoryQuery
|| $this instanceof ServicegroupQuery
|| $this instanceof ServicenotificationQuery
|| $this instanceof ServicestatehistoryQuery
|| $this instanceof ServicestatusQuery
) {
$this->requireVirtualTable('services');
$leftcol = 's.host_object_id';
} else {
$leftcol = 'ho.object_id';
if (! $this->hasJoinedTable('ho')) {
$this->requireVirtualTable('hosts');
}
}
} else { // $type === 'service'
$leftcol = 'so.object_id';
if (! $this->hasJoinedTable('so')) {
$this->requireVirtualTable('services');
}
}

$mapped = $this->getMappedField($leftcol);
Expand Down
Expand Up @@ -89,7 +89,7 @@ protected function joinBaseTables()
[]
)->join(
['co' => $this->prefix . 'objects'],
'co.object_id = c.contact_object_id AND co.is_active = 1',
'co.object_id = c.contact_object_id AND co.is_active = 1 AND co.objecttype_id = 10',
[]
);

Expand Down Expand Up @@ -163,7 +163,7 @@ protected function joinHosts()
[]
)->joinLeft(
['ho' => $this->prefix . 'objects'],
'ho.object_id = h.host_object_id AND ho.is_active = 1',
'ho.object_id = h.host_object_id AND ho.is_active = 1 AND ho.objecttype_id = 1',
[]
);
}
Expand Down

0 comments on commit 6e989d0

Please sign in to comment.