Skip to content
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

fix: verify correct permission names based on OpenAPI schema #142

Merged
merged 193 commits into from
Nov 1, 2023
Merged

Conversation

octokitbot
Copy link
Collaborator

@octokitbot octokitbot commented Oct 26, 2022

BREAKING CHANGE: several permissions have been renamed to match GitHub's OpenAPI spec. It's really just a fix, but in order to avoid friction we decided to release a breaking change for this one.

I found new changes on https://docs.github.com/en/rest/reference/permissions-required-for-github-apps/ and thought I'd let you know about it 👋🤖

I can't tell if the changes include fixes, features, breaking changes or just cache updates, you'll have to figure that out on yourself and adapt the commit messages accordingly to trigger the right release, see our commit message conventions.

@octokitbot octokitbot added the Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR label Oct 26, 2022
Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

Something's not right, the new route should have been added. I guess it's the line break in the HTML

@kfcampbell
Copy link
Member

@gr2m is this indicative of an error upstream we can report somewhere?

@gr2m
Copy link
Contributor

gr2m commented Oct 26, 2022

@gr2m is this indicative of an error upstream we can report somewhere?

I looked into it and I don't think so. It looks like the way the HTML is rendered is independent of how the route was added in its source file.

I think we should address this case on our side.

@gr2m gr2m self-assigned this Oct 28, 2022
@gr2m
Copy link
Contributor

gr2m commented Oct 28, 2022

Okay there were bigger changes that happened here, like title changes.

I think it's time we utilze the schema now that the we have a complete schema for app-permissions in the OpenAPI spec now. We can get the names of the permissions out of that and be sure that they match, and then parse the contents of the page and assign the routes to the respective permission.

Comment on lines 17 to 31
const MISSING_SCHEMA_PERMISSIONS = [
"codespaces",
"dependabot_secrets",
"email_addresses",
"followers",
"git_ssh_keys",
"gpg_keys",
"interaction_limits",
"organization_events",
"organization_webhooks",
"profile",
"repository_webhooks",
"self_hosted_runners",
"starring",
];
Copy link
Contributor

Choose a reason for hiding this comment

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

@kfcampbell @nickfloyd can you please look up the real names of these permissions and also reach out to the OpenAPI team and let them know that these permissions are missing in the schema at components/schemas/app-permissions

We can ship the PR as is and remove these later, or add our own mapping until the OpenAPI spec is updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @gr2m will do... thanks for the head's up!

Copy link
Member

Choose a reason for hiding this comment

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

Updating here: I talked to the Apps team and they're receptive of a PR internally to add these permissions.

@gr2m
Copy link
Contributor

gr2m commented Oct 28, 2022

It looks like our parse app permissions where quite incorrect for a while.

Instead of just parsing titles form https://docs.github.com/en/rest/overview/permissions-required-for-github-apps and assuming they are the correct permission names used by GitHub, we now load the OpenAPI spec and utilize the app-permission schema component in there. I added a mapping where some titles are different from the permission names used internally, but also found several permissions that are listed in the docs but not in the schema.

@gr2m gr2m changed the title 🤖📯 App permissions changed fix: verify correct permission names based on OpenAPI scheema Oct 28, 2022
@gr2m gr2m changed the title fix: verify correct permission names based on OpenAPI scheema fix: verify correct permission names based on OpenAPI schema Oct 28, 2022
generated/api.github.com.json Outdated Show resolved Hide resolved
Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

I think we should get these fixed otherwise this would be a additional breaking changes.

meta is actually metadata so one might say there are breaking changes anyway, but really they are just fixes as meta has never been correct in the first place

@@ -208,13 +212,33 @@
"POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest"
]
},
"codespaces": {
Copy link
Contributor

Choose a reason for hiding this comment

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

removes codespaces because it's not defined in OpenAPI schema and I'm not sure if this is the correct name

"DELETE /user/interaction-limits",
"PUT /user/interaction-limits"
]
},
Copy link
Contributor

Choose a reason for hiding this comment

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

removes all the above because they are not defined in OpenAPI schema and I'm not sure if this is the correct name

"url": "https://docs.github.com/en/free-pro-team@latest/rest/reference/permissions-required-for-github-apps/#permission-on-keys",
"read": ["GET /user/keys", "GET /user/keys/{key_id}"],
"write": ["DELETE /user/keys/{key_id}", "POST /user/keys"]
},
Copy link
Contributor

Choose a reason for hiding this comment

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

there are likely different permissions for git_ssh_keys and gpg_keys but we need to verify or get the OpenAPI schema updated

"POST /orgs/{org}/hooks",
"POST /orgs/{org}/hooks/{hook_id}/pings"
]
},
Copy link
Contributor

Choose a reason for hiding this comment

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

both missing in OpenAPI schema

"DELETE /orgs/{org}/blocks/{username}",
"PUT /orgs/{org}/blocks/{username}"
]
},
Copy link
Contributor

Choose a reason for hiding this comment

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

missing in OpenAPI schema

"PATCH /repos/{owner}/{repo}/hooks/{hook_id}",
"POST /repos/{owner}/{repo}/hooks"
]
},
Copy link
Contributor

Choose a reason for hiding this comment

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

missing in OpenAPI schema

"POST /orgs/{org}/actions/runners/{runner_id}/labels",
"PUT /orgs/{org}/actions/runners/{runner_id}/labels"
]
},
Copy link
Contributor

Choose a reason for hiding this comment

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

@nickfloyd nickfloyd self-assigned this Nov 2, 2022
@kfcampbell
Copy link
Member

This is a long-running issue that we've all probably lost context for (I know I have). @gr2m / @nickfloyd, would you both be interested in doing a zoom call sometime to sort this PR out?

@gr2m
Copy link
Contributor

gr2m commented Oct 17, 2023

Next step is still to update the OpenAPI spec:
https://github.com/octokit/app-permissions/pull/142/files?show-viewed-files=true&file-filters%5B%5D=#r1008542042
could one of you look into that?

and look through my comments on updates to the generated/api.github.com.json file. I don't think we need a zoom call at this point?

@nickfloyd nickfloyd removed the Status: Blocked Some technical or requirement is blocking the issue label Nov 1, 2023
Copy link
Contributor

@nickfloyd nickfloyd left a comment

Choose a reason for hiding this comment

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

I manually looked at / verified the changes in the GitHub docs for the changes mentioned - not sure if there is any more validation need here.

@nickfloyd nickfloyd requested review from gr2m and kfcampbell November 1, 2023 18:35
Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

let's go 🎉

@nickfloyd nickfloyd merged commit a91488b into main Nov 1, 2023
4 checks passed
@nickfloyd nickfloyd deleted the update branch November 1, 2023 18:45
Copy link
Contributor

github-actions bot commented Nov 1, 2023

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants