Skip to content

[18.0][FIX] spreadsheet_oca: restrict revisions to their spreadsheet's access - #154

Open
nimarosa wants to merge 2 commits into
OCA:18.0from
nimarosa:18.0-fix-spreadsheet_oca-revision-access
Open

nimarosa wants to merge 2 commits into
OCA:18.0from
nimarosa:18.0-fix-spreadsheet_oca-revision-access

Conversation

@nimarosa

Copy link
Copy Markdown

Fixes #153.

spreadsheet.oca.revision has full CRUD for base.group_user and no record rule, so any
internal user can read, create, change or delete the revisions of any spreadsheet or
dashboard through RPC, whatever the document's own rules say.

With this PR revisions follow the document they belong to (model/res_id), like
ir.attachment and mail.message do:

  • read needs read access to the spreadsheet; create, write and unlink need write access;
  • a revision can only point to a model inheriting spreadsheet.abstract;
  • _search adds one subquery per spreadsheet model (res_id in <readable documents>),
    _check_access checks the parent for the given records, and write re-checks when
    model/res_id change. Superuser is untouched.

I left the ACL on base.group_user on purpose: dashboard viewers are plain internal
users and read the revisions of the dashboards they can see. Restricting the ACL to
spreadsheet_oca.group_user would break that and still let a spreadsheet user read
sheets they are not allowed to open.

Second commit: a creator rule on the two transient wizards
(spreadsheet.spreadsheet.import, spreadsheet.to.dashboard), which in 18.0 are
readable across users.

Tests (failing on 18.0 before the change):

  • internal user, and spreadsheet user without access to the sheet: no search, read,
    create, write or unlink;
  • reader: reads revisions and opens the sheet read-only, cannot change them or send a
    revision;
  • owner: sends revisions, opens, creates/writes/unlinks, saving drops the revisions;
  • archived sheet keeps its revisions visible to the owner;
  • moving a revision to a sheet without write access, or attaching one to a non-spreadsheet
    record, is refused;
  • dashboard: manager edits, viewer reads but cannot change, a hidden dashboard's
    revisions stay hidden;
  • both wizards are private to their creator.

No migration needed: the change is code plus two record rules.

@OCA/spreadsheet-maintainers

spreadsheet.oca.revision had full CRUD for base.group_user and no record
rule, so any internal user could read, create, change or delete the
revisions of any spreadsheet or dashboard through RPC, regardless of the
owner/contributor/reader rules of the document itself.

Revisions now follow the record they belong to (model/res_id), as
attachments and messages do: reading one requires read access to its
spreadsheet, creating, changing or deleting one requires write access to
it, and a revision can only point to a model inheriting
spreadsheet.abstract. The ACL is unchanged, because dashboard viewers
(plain internal users) read revisions when they open a dashboard.

Also keep the import wizard private to its creator: transient records are
not isolated per user in 18.0.
Transient records are not isolated per user in 18.0, so any internal user
could read the "create dashboard from spreadsheet" wizards of the others.
Add a creator rule, and tests showing that dashboard revisions follow the
dashboard's access (viewers read, managers edit, hidden dashboards stay
hidden).
@OCA-git-bot OCA-git-bot added mod:spreadsheet_dashboard_oca Module spreadsheet_dashboard_oca mod:spreadsheet_oca Module spreadsheet_oca series:18.0 labels Nov 27, 2026
@pedrobaeza

Copy link
Copy Markdown
Member

@nimarosa

Copy link
Copy Markdown
Author

@pedrobaeza Hi Pedro, I think the PR don't have any AI Atribution i can see. I used AI to fix this permission bug I found in production.

Please tell me which part of the PR you think it's not okay and I modify it, I review the code before opening PRs but I automate a lot of CI / Tests with AI probably that's why you think it's AI slop.

@pedrobaeza

Copy link
Copy Markdown
Member

You have to disclose the AI usage, and there's things that you already know that shouldn't be put in the PR, like the manifest version change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:spreadsheet_dashboard_oca Module spreadsheet_dashboard_oca mod:spreadsheet_oca Module spreadsheet_oca series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants