fix(attestation): check contract access before rewriting it on workflow lookup

Merged
MI
4d ago
+272-31

Attestation init (AttestationService/FindOrCreateWorkflow) can update the contract of an existing workflow when it receives contract bytes. Until now it only checked that the caller could create workflows in the project, so a caller confined to projects (a project-, workflow- or product-scoped API token, or an org member with a project role) could rewrite an organization-level contract shared by other projects.

The endpoint now applies the same contract access check as WorkflowContractService/Update before the update: callers confined to projects can no longer modify organization-level contracts through attestation init, and project-level contracts require update access in their project. Organization-wide tokens and organization administrators are unaffected. The check is shared between both services, and contract policies are validated only after access is granted.

This PR was written with the assistance of Claude Code.

šŸ¤– Posted by Maximus bot (Claude Code) on behalf of @migmartri