Skip to content

Commit d6f43b5

Browse files
Add locked field to feeds for sync user permission control
- Add database migration case 141 for feeds.locked field - Modify feed processing to set event locked status from feed config - Add locked checkbox to feed add/edit UI forms - Update controller to handle locked field in save operations Fixes sync user permission issue where users could pull feed events but not update them. Events from locked feeds can now be edited by sync users, while unlocked feeds remain local-only. Addresses GitHub issue MISP#10047 Co-Authored-By: Chris Horsley <chris.horsley@falconmouse.com>
1 parent fa9e98a commit d6f43b5

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

app/Controller/FeedsController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ public function add()
280280
if (empty($feed['Feed']['lookup_visible'])) {
281281
$feed['Feed']['lookup_visible'] = 0;
282282
}
283+
if (empty($feed['Feed']['locked'])) {
284+
$feed['Feed']['locked'] = 0;
285+
}
283286
if (empty($feed['Feed']['input_source'])) {
284287
$feed['Feed']['input_source'] = 'network';
285288
} else {
@@ -379,7 +382,8 @@ public function edit($feedId)
379382
'lookup_visible',
380383
'headers',
381384
'orgc_id',
382-
'fixed_event'
385+
'fixed_event',
386+
'locked'
383387
],
384388
'afterFind' => function (array $feed) {
385389
$feed['Feed']['settings'] = json_decode($feed['Feed']['settings'], true);

app/Model/AppModel.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,9 @@ public function updateDatabase($command)
24802480
case 140:
24812481
$sqlArray[] = "ALTER TABLE `taxii_servers` MODIFY `api_key` TEXT NOT NULL";
24822482
break;
2483+
case 141:
2484+
$sqlArray[] = "ALTER TABLE `feeds` ADD `locked` tinyint(1) NOT NULL DEFAULT 0;";
2485+
break;
24832486
case 'fixNonEmptySharingGroupID':
24842487
$sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';
24852488
$sqlArray[] = 'UPDATE `attributes` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';

app/Model/Feed.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ private function __prepareEvent($event, array $feed, $filterRules)
10611061
} else {
10621062
$event['Event']['distribution'] = $feed['Feed']['distribution'];
10631063
$event['Event']['sharing_group_id'] = $feed['Feed']['sharing_group_id'];
1064+
$event['Event']['locked'] = !empty($feed['Feed']['locked']) ? 1 : 0;
10641065
if ($feed['Feed']['sharing_group_id']) {
10651066
$sg = $this->SharingGroup->find('first', array(
10661067
'recursive' => -1,

app/View/Feeds/add.ctp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ echo $this->element('genericElements/Form/genericForm', [
3131
'label' => __('Unpublish events'),
3232
'type' => 'checkbox'
3333
],
34+
[
35+
'field' => 'locked',
36+
'label' => __('Lock events'),
37+
'title' => __('Lock events created from this feed (allows sync users to edit them)'),
38+
'type' => 'checkbox'
39+
],
3440
[
3541
'field' => 'name',
3642
'label' => __('Name'),

0 commit comments

Comments
 (0)