Skip to content

fix(api): hide staff comment fields on public reads - #951

Merged
danieltruong merged 1 commit into
developfrom
fix-item-schema-match
Oct 14, 2026
Merged

danieltruong merged 1 commit into
developfrom
fix-item-schema-match

Conversation

@danieltruong

Copy link
Copy Markdown
Collaborator

Item reads matched by id only, so a comment could be read through another model's public view, along with its staff fields.

Changes:

  • Item reads match on _schemaName as well as _id.
  • Public reads return only an allow-list of comment fields (COMMENT_PUBLIC_FIELDS in api/helpers/constants.js). The author stays hidden on anonymous comments.
  • Public comment routes and the public Item path return a comment only when its comment period is readable. A comment with no period, or whose period is gone, is hidden.
  • Public comment sortBy accepts only commentId and dateAdded, so hidden fields cannot leak through sort order.
  • Log lines carry ids and counts only.

Tests: unit and DB tests added for the schema match, the field allow-list, the period gate and the sort limit.

Item reads matched by id only, so a comment could be read through
another model's public view, with its staff fields.

- Match Item reads on _schemaName as well as _id.
- Return only an allow-list of comment fields on public reads
  (COMMENT_PUBLIC_FIELDS). The author stays hidden on anonymous
  comments.
- Public comment routes and the public Item path return a comment
  only when its period is readable. A comment with no period, or
  whose period is gone, is hidden.
- Limit public comment sortBy to commentId and dateAdded, so hidden
  fields cannot leak through sort order.
- Log ids and counts only.
@danieltruong
danieltruong merged commit 632ebda into develop Oct 14, 2026
4 checks passed
@danieltruong
danieltruong deleted the fix-item-schema-match branch October 14, 2026 01:49
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.

1 participant