-
Notifications
You must be signed in to change notification settings - Fork 27
Validate repository org-ownership before storage record creation #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate repository org-ownership before storage record creation #328
Conversation
…ord creation Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
Signed-off-by: Meredith Lancaster <malancas@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds validation to ensure that storage records are only created for repositories owned by organizations, not individual users. The storage record feature is organization-only, so this validation prevents unnecessary API calls and potential errors when running in user-owned repositories.
Changes:
- Added a
repoOwnerIsOrghelper function that uses the GitHub REST API to check repository ownership type - Modified attestation flow to skip storage record creation for user-owned repositories
- Added comprehensive test coverage for the new validation logic
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/attest.ts | Implements organization ownership check before storage record creation and adds repoOwnerIsOrg helper function |
| tests/main.test.ts | Adds test coverage for the new organization check and verifies storage records aren't created for user-owned repos |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Validate that a repository is owned by an organization before attempting to create a storage record. Storage records can only be created on behalf of artifacts generated in repositories owned by organizations. The feature is not supported for repositories owned by users.
There does not seem to be a reliable way of fetching the repository owner type from the GitHub context provided in the
@actions/github. We can reliable check whether a repository is owned by an organization or user with the get repository endpoint. The response must return the nestedowner.typefield, which must be either "User" or "Organization".