[ZBX-11261] Audit on create/update item is broken Created: 2016 Sep 23 Updated: 2017 May 30 Resolved: 2016 Sep 26 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Frontend (F) |
Affects Version/s: | 3.2.0 |
Fix Version/s: | None |
Type: | Incident report | Priority: | Minor |
Reporter: | Andrey Denisov | Assignee: | Unassigned |
Resolution: | Duplicate | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Issue Links: |
|
Comments |
Comment by Andrey Denisov [ 2016 Sep 23 ] |
Create/update item has been moved in API in 3.2.0, but there are no audit actions in API functions for such actions. I propose to modify CItem.php the following way, see //<<== - like comments: protected function updateReal(array $items) { $itemids = []; $updItems = []; // <<== add audit logging. Getting updated items data //<<== add audit logging. Getting old items data DB::update('items', $data); $itemApplications = []; $applicationids[] = $item['itemid']; foreach ($item['applications'] as $appid) { $itemApplications[] = [ 'applicationid' => $appid, 'itemid' => $item['itemid'] ]; } } if (!empty($applicationids)) { DB::delete('items_applications', ['itemid' => $applicationids]); DB::insert('items_applications', $itemApplications); } $itemHosts = $this->get([ 'output' => ['name'], 'itemids' => $itemids, 'selectHosts' => ['name'], 'nopermissions' => true ]); foreach ($itemHosts as $item) { $host = reset($item['hosts']); info(_s('Updated: Item "%1$s" on "%2$s".', $item['name'], $host['name'])); } //<<== add audit logging. Write to audit foreach ($oldItems as $item) { add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM, $item['itemid'], $host['name'].NAME_DELIMITER.$item['name'], 'items', $item, $updItems[$item['itemid']]); } //<<========================================= } protected function createReal(array &$items) { $itemids = DB::insert('items', $items); $itemApplications = []; foreach ($items as $key => $item) { $items[$key]['itemid'] = $itemids[$key]; if (!isset($item['applications'])) { continue; } foreach ($item['applications'] as $appid) { $itemApplications[] = [ $itemHosts = $this->get([ $hosts=[];//<<== collecting hosts //<<== write to audit //<<================================= |
Comment by richlv [ 2016 Sep 23 ] |
duplicate of |
Comment by Aleksandrs Saveljevs [ 2016 Sep 26 ] |
Closing as a duplicate. |