Repository navigation
[INFRA-1118] fix(security): make work item system fields read-only - #10048
Conversation
…rializers Add deleted_at to read_only_fields on the v1 IssueSerializer and the app IssueCreateSerializer, so PATCH cannot set it; deletion stays on DELETE. Also covers INFRA-1202. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Linked to Plane Work Item(s) References This comment was auto-generated by Plane |
Make archived_at and sequence_id read-only on the v1 and app work item serializers; archive/unarchive keep their dedicated endpoints. Co-Authored-By: Claude Opus 5.5 <[email protected]>
lovelace3
left a comment
There was a problem hiding this comment.
No blocking findings. One minor finding inline.
Verified
- Both new test modules pass (6/6). Falsified against the merge-base serializers: all 6 cases fail, so the tests guard the change.
- Write paths: app
IssueCreateSerializer(issue create/update, intake update, draft-to-issue) and v1IssueSerializer(work item PATCH, v1 intake PATCH) are the only serializers that writeIssue. The otherIssueserializers are read-only or never bound to request data. Archive/unarchive and delete still set the fields on the model directly. - Regression sweep (
plane/tests/contract+unit/serializers+unit/views): everything passes except the same 12 magic-link tests intest_authentication.py, which fail identically on all four of your heads #10048–#10051. This PR doesn't touch auth, so they're environmental, not regressions.
Test note (minor): both new tests need WEB_URL/APP_BASE_URL set. Without it the PATCH 500s in base_host() (ImproperlyConfigured) before the assertion. Other contract tests (test_issue_subresource_scope_app.py, unit/views/test_issue_link.py) patch base_host and the .delay tasks so they run in a bare env. Doing the same here would make these tests independent of a local .env.
| "updated_at", | ||
| "completed_at", | ||
| "deleted_at", | ||
| "archived_at", |
There was a problem hiding this comment.
Minor: an ignored archived_at still writes an "archived" activity. partial_update (and v1 patch) pass the raw request.data to issue_activity. ISSUE_ACTIVITY_MAPPER maps archived_at to track_archive_at, which compares the request value with current_instance. So a PATCH carrying archived_at now leaves the field unchanged, yet history records "Actor has archived the issue" (new_value=manual_archive) and the activity task runs with notification=True. Sending archived_at: null on an archived item gives a false "restored" entry the same way.
Probe on this head (member PATCH {"archived_at": "2020-01-01"}, then the activity task run on the captured kwargs): response 204, issue.archived_at stays None, and the activity rows are [('archived_at', 'manual_archive', 'Actor has archived the issue')].
Before this PR the entry matched a real change. Now it can be forged. Suggested fix: build requested_data from the keys the serializer accepted (e.g. drop serializer.Meta.read_only_fields from request.data), or have track_archive_at compare against the saved instance.
There was a problem hiding this comment.
Addressed in a442001 (ignored fields no longer recorded in activity).
|
Re the test note: the suite's documented runner ( |
- Leave the serializer's read-only fields out of the data passed to issue_activity and model_activity on work item PATCH (app and v1), so an ignored field such as archived_at no longer records activity or sends notifications and webhooks. - Tests assert the ignored field is absent from both payloads. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- is_draft is read-only when updating a work item through the app IssueCreateSerializer and the v1 IssueSerializer; create is unchanged - Intake updates (app and v1) and the v1 external-id upsert send only the writable fields to issue/model activity, via a shared writable_data helper also used by the existing work item updates - Tests: is_draft on work item PATCH (app and v1), intake updates with archived_at record no archive activity (app and v1) Co-Authored-By: Claude Opus 5.5 <[email protected]>
lovelace3
left a comment
There was a problem hiding this comment.
Follow-up on 852909e.
Earlier findings:
- Resolved: an ignored
archived_atproduced a forged archive/restore activity. Activity and webhook payloads now go throughwritable_data(serializer, data). That covers all five serializer-backed update paths that feedissue.activity.updatedwith request data: app issue PATCH, app intake PATCH, v1 work-item PATCH, the v1 external-id PUT upsert, and v1 intake PATCH. The otherissue.activity.updatedcallers (archive, sub-issue, date bulk update, estimate) build their own payloads. Every keyISSUE_ACTIVITY_MAPPERtracks, apart fromarchived_at, is still a writable field on both serializers, so real changes are still recorded. - Not resolved (minor, test hygiene): the new and changed tests still need
WEB_URL/APP_BASE_URL. The activity tasks are mocked now, butbase_host()is evaluated as an argument before the mock is reached. With those vars unset, 11 of the 14 cases fail withImproperlyConfigured.
New in 852909e: is_draft is read-only on update in both serializers and stays writable on create. Issue rows with is_draft=True are hidden by IssueManager, and 0077 moved the legacy drafts to DraftIssue. Workspace drafts in the web client use the draft endpoints, not this serializer, so I found no legitimate update flow that this breaks. No new findings.
Untested: the v1 PUT (external-id upsert) activity change. The code is the same two lines as on PATCH.
Tests: the 4 modules (api/test_intake_issue_update.py, api/test_issue_read_only_fields.py, app/test_intake_issue_read_only_fields_app.py, app/test_issue_read_only_fields_app.py) give 14 passed. Falsification: with the six changed source files reset to 53b5663 and utils/serializers.py removed, 10/14 fail. That includes every is_draft case and both intake no-archive-activity tests. The 4 that pass are the two create-writability checks and two intake tests that already passed before this change.
…10048) * [INFRA-1118] fix(security): make deleted_at read-only on work item serializers Add deleted_at to read_only_fields on the v1 IssueSerializer and the app IssueCreateSerializer, so PATCH cannot set it; deletion stays on DELETE. Also covers INFRA-1202. * [INFRA-1118] fix(security): address review Make archived_at and sequence_id read-only on the v1 and app work item serializers; archive/unarchive keep their dedicated endpoints. * [INFRA-1118] fix(security): address review feedback - Leave the serializer's read-only fields out of the data passed to issue_activity and model_activity on work item PATCH (app and v1), so an ignored field such as archived_at no longer records activity or sends notifications and webhooks. - Tests assert the ignored field is absent from both payloads. * [INFRA-1118] fix(security): address review feedback - is_draft is read-only when updating a work item through the app IssueCreateSerializer and the v1 IssueSerializer; create is unchanged - Intake updates (app and v1) and the v1 external-id upsert send only the writable fields to issue/model activity, via a shared writable_data helper also used by the existing work item updates - Tests: is_draft on work item PATCH (app and v1), intake updates with archived_at record no archive activity (app and v1)
…10048) * [INFRA-1118] fix(security): make deleted_at read-only on work item serializers Add deleted_at to read_only_fields on the v1 IssueSerializer and the app IssueCreateSerializer, so PATCH cannot set it; deletion stays on DELETE. Also covers INFRA-1202. * [INFRA-1118] fix(security): address review Make archived_at and sequence_id read-only on the v1 and app work item serializers; archive/unarchive keep their dedicated endpoints. * [INFRA-1118] fix(security): address review feedback - Leave the serializer's read-only fields out of the data passed to issue_activity and model_activity on work item PATCH (app and v1), so an ignored field such as archived_at no longer records activity or sends notifications and webhooks. - Tests assert the ignored field is absent from both payloads. * [INFRA-1118] fix(security): address review feedback - is_draft is read-only when updating a work item through the app IssueCreateSerializer and the v1 IssueSerializer; create is unchanged - Intake updates (app and v1) and the v1 external-id upsert send only the writable fields to issue/model activity, via a shared writable_data helper also used by the existing work item updates - Tests: is_draft on work item PATCH (app and v1), intake updates with archived_at record no archive activity (app and v1) (cherry picked from commit a00293e)
Description
deleted_atwas writable through the work item update serializers. It is now read-only, so removing a work item always goes through the delete endpoints and their role checks.plane/api/serializers/issue.py:IssueSerializer.Meta.read_only_fieldsnow includesdeleted_at(v1 work item PATCH and the v1 intake issue PATCH).plane/app/serializers/issue.py:IssueCreateSerializer.Meta.read_only_fieldsnow includesdeleted_at(app issue create/update/partial_update, intake issue update, draft-to-issue).deleted_atis still returned in responses. No client sends it in an update payload, and there is no restore flow that writes it through these serializers.archived_atandsequence_idare now read-only on both serializers too. Archive/unarchive keep using their dedicated endpoints, which setarchived_aton the model directly;sequence_idis always assigned byIssue.save()on create. No client inapps/web,apps/spaceorpackagessends either field in an issue create/update payload.is_draftis read-only when updating an existing work item through either serializer, and stays writable on create. The update endpoints only load work items that are not drafts, so no update path can legitimately change it. The web issue form may echo the currentis_draftvalue on update; that value is now ignored.issue_activityandmodel_activity(sharedplane.utils.serializers.writable_datahelper), so an ignored field does not record activity or send notifications or webhooks.created_byon the v1 serializer is left to [INFRA-772] fix(security): stop trusting body-supplied created_by/created_at on external API #9704, which already makes it read-only on the PATCH path. Both PRs edit the same v1read_only_fieldslist, so whichever lands second needs a small rebase that keeps all entries.Behaviour change:
deleted_at,archived_atorsequence_idin a create or update payload, oris_draftin an update payload, is ignored instead of being saved.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
PATCH /api/v1/workspaces/<slug>/projects/<id>/work-items/<id>/as a project member with{"name": ..., "deleted_at": ...}→ 200, name updated,deleted_atstays null.PATCH /api/workspaces/<slug>/projects/<id>/issues/<id>/as a project member with the same payload → 204, name updated,deleted_atstays null.archived_atorsequence_id→ name updated, the field is unchanged, and the field is absent from the activity and webhook payloads.is_draft: true→ the work item stays visible (is_draftunchanged);is_draftis still writable on create.{"issue": {"name": ..., "archived_at": ...}}→ name updated,archived_atstays null, no archive activity recorded.test_issue_read_only_fields.py(v1) andtest_issue_read_only_fields_app.py(app) are parametrized over all four fields; each case fails against the pre-PR serializers and passes with the change. The intake tests fail without the activity filtering.plane/tests: 777 passed.References
🤖 Generated with Claude Code
Summary by CodeRabbit