Skip to content

fix(project): drop REPLAY_HOOKS from default everyone perms - #2879

Open
shikanime wants to merge 2 commits into
mainfrom
fix/everyone-perms-no-replay
Open

shikanime wants to merge 2 commits into
mainfrom
fix/everyone-perms-no-replay

Conversation

@shikanime

Copy link
Copy Markdown
Member

Pourquoi

À la création d'un projet, le défaut Prisma everyonePerms = 896 accorde la permission « Reprovisionner le projet » (REPLAY_HOOKS, bit 128) au rôle « Tout le monde » : tout utilisateur authentifié peut donc reprovisionner un projet sans y détenir aucun rôle. #2878

Quoi

  • Défaut du schéma 896 → 768 (REPLAY_HOOKS | LIST_ENVIRONMENTS | LIST_REPOSITORIES → LIST_ENVIRONMENTS | LIST_REPOSITORIES) dans les deux arbres prisma.
  • Migration 20261019120000_drop_replay_hooks_from_everyone_perms retirant le bit 128 d'everyonePerms sur les projets existants, mirroirée dans les deux arbres.
  • Usines de tests et fixtures alignées sur 768.

Le bouton de reprovisionnement reste accessible aux propriétaires et administrateurs via MANAGE ; un admin souhaitant rétablir le comportement peut re-cocher la permission dans l'écran des rôles du projet.

Références

The Prisma default everyonePerms = 896 = REPLAY_HOOKS |
LIST_ENVIRONMENTS | LIST_REPOSITORIES granted project reprovisioning
to every authenticated user by default. Keep only the two list
permissions (768) and realign existing rows through a migration
mirrored in both prisma trees. Admins who genuinely want
everyone-replay can re-grant the permission from the project roles
screen.

Design: schema default 896 -> 768, UPDATE clearing bit 128 on
existing projects, test factories and fixtures aligned on 768.

Related: #2878

Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Co-authored-by: Automata <automata@shikanime.studio>
Change-Id: I6c0d8f6c87d4a7e236ce27089181dc2c6a6a6964
@shikanime
shikanime requested a review from a team as a code owner October 19, 2026 14:30
@github-actions github-actions Bot added the built label Oct 19, 2026

@StephaneTrebel StephaneTrebel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La migration des valeurs existantes est correcte, mais il manque la migration du défaut SQL vers 768 : l’historique rejoué ne correspond donc plus au schéma Prisma (constat inline). Les 110 tests ciblés et le lint ciblé passent ; la CI est verte, SonarQube annonce 0 nouvelle issue, et aucun fil antérieur n’est ouvert. Ledger #2878 : 3/5 critères démontrés (migration des données, fixtures, lint/tests), défaut partiellement corrigé (création via Prisma régénéré à 768, défaut PostgreSQL encore à 896), et critère de gel de apps/server non satisfait : les modifications de cet arbre restent un blocage de périmètre à arbitrer explicitement, malgré le mirroring annoncé ; #2646 couvre également ce défaut de permissions.

The replay-hooks migration only realigned existing rows; the column
DEFAULT 896 installed by 20240723135420_dso survived, so databases
built from the migration history kept the permissive default. Add the
ALTER TABLE ... SET DEFAULT 768 to the migration, mirrored in both
prisma trees, so replayed history matches the declared schema.

Design: ALTER TABLE before the row UPDATE; same statement in
apps/server (frozen tree mirror).

Related: #2878

Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Co-authored-by: Automata <automata@shikanime.studio>
Change-Id: I7a41b8c2e9d3f5a6b8c1d2e3f4a5b6c7d8e9f0a1
@shikanime

Copy link
Copy Markdown
Member Author

Suivi du round de revue : d3af424 ajoute ALTER TABLE "Project" ALTER COLUMN "everyonePerms" SET DEFAULT 768 en tête de 20261019120000_drop_replay_hooks_from_everyone_perms, mirroiré dans les deux arbres. Rejeu intégral de l'historique (75 migrations) sur PostgreSQL 16.15 vierge : column_default = 768, INSERT sans everyonePerms = 768, second rejeu no-op. Fil résolu, revue re-demandée.

@cloud-pi-native-sonarqube

Copy link
Copy Markdown

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants