Skip to content

Add locked field to feeds for sync user permission control#3

Open
chorsley wants to merge 5 commits into
2.5from
origin/devin/1753682268-feed-locked-field
Open

Add locked field to feeds for sync user permission control#3
chorsley wants to merge 5 commits into
2.5from
origin/devin/1753682268-feed-locked-field

Conversation

@chorsley

Copy link
Copy Markdown
  • 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

Generic requirements in order to contribute to MISP:

  • One Pull Request per fix/feature/change/...
  • Keep the amount of commits per PR as small as possible: if for any reason, you need to fix your commit after the pull request, please squash the changes in one single commit (or tell us why not)
  • Always make sure it is mergeable in the default branch (as of today 2020-05-05: branch 2.4)
  • Please make sure Travis CI works on this request, or update the test cases if needed
  • Any major changes adding a functionality should be disabled by default in the config

What does it do?

If it fixes an existing issue, please use github syntax: #<IssueID>

Questions

  • Does it require a DB change?
  • Are you using it in production?
  • Does it require a change in the API (PyMISP for example)?

devin-ai-integration Bot and others added 5 commits July 28, 2025 06:01
- 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>
microblag pushed a commit that referenced this pull request May 15, 2026
Decision recorded: events created from a template will NOT carry the
originating template's uuid + version on the event row. Once the event
is created, the template is no longer load-bearing for any v1 flow.
The audit-log row written when an event is instantiated (Phase 4 #4)
captures the template uuid + version for the rare audit need.

Rationale documented in the tracker. Avoids:
  - tag pollution (would need a `misp-galaxy:template_uuid="…"` or
    custom tag on every event from a template),
  - a migration on `events` (would need column adds + REST/sync
    contract change + care around event_reports payloads),
  - the "event note" middle ground (clean for humans, opaque to
    queries — gains us little if we don't actually query it).

If a future analytics or index-filter use case demands persistence,
it can be added at that time without breaking existing data — anything
we add later attaches only to events created after the change.

PRD: docs/dev/event-templating-prd.md §5.3 F3.4 (audit log behaviour
unchanged; only the on-event persistence is dropped)
Task: docs/dev/event-templating-progress.md — Phase 4 / Events created from a template record template_uuid + template_version in event metadata

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
microblag pushed a commit that referenced this pull request May 15, 2026
Phase 4 #4 (PRD §5.3 F3.4). When an event is created from a template,
the instantiator now writes a post-commit audit-log row that ties
the new event back to its source template:

    action     : 'instantiate' (new constant, see below)
    model      : 'EventTemplate'
    model_id   : <template id>
    model_title: <template name>
    event_id   : <new event id>
    change     : {
        event_template_id, event_template_uuid,
        event_template_version, event_template_name,
        event_uuid
    }

This is the canonical record of "user X created event Y from
template Z (uuid+version)" — Phase 4 #3 already decided we will not
persist the originating template on the event row itself; this audit
row carries the metadata for any future audit need without polluting
the event payload.

Audit failures (e.g. AuditLog disabled, brotli unavailable, transient
DB error) are demoted to a CakeLog warning so they never affect the
already-committed event.

Files:

  - app/Model/AuditLog.php — add `ACTION_INSTANTIATE = 'instantiate'`
    to the action enum. Single-line additive change to a shared model;
    needed because the existing constants do not capture the semantic
    "event was instantiated from this template" cleanly. Reusing
    ACTION_ADD would have produced misleading "Added EventTemplate #N"
    titles in the audit log view.

  - app/Controller/AuditLogsController.php — add the new constant to
    both action label maps (the per-row `action_human` mapping at
    line 89-105, and the filter dropdown at line 153-164). Without
    this, any audit-log view that paginates over an instantiate row
    throws an undefined-index notice on `$this->actions[...]`, and
    the action filter would have no entry for it.

  - app/Lib/Tools/EventTemplateInstantiator.php — `writeInstantiationAuditRow()`
    helper, called after `$db->commit()` and the post-add count
    verification. Wraps `AuditLog::insert(...)` in a try/Throwable
    so any failure is swallowed with a warning rather than affecting
    the live event. Skips the row entirely when `$options['template']`
    is absent — useful for tests and programmatic callers that don't
    want the audit row.

  - app/Controller/EventTemplatesController.php — `instantiate()` now
    passes `$options['template'] = {id, uuid, version, name}` to the
    instantiator, drawn from the `$source['EventTemplate']` row that
    was already fetched for read-auth.

Verified live: template 463 → event 6699 → audit row 5295774. The
test event + audit row were cleaned up after verification. Existing
7 EventTemplateInstantiator unit tests still pass (the audit-row
write is skipped when no template metadata is supplied, which is
the case in the unit suite).

PRD: docs/dev/event-templating-prd.md §5.3 F3.4
Task: docs/dev/event-templating-progress.md — Phase 4 / Audit log entry on "event created from template"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants