-
Notifications
You must be signed in to change notification settings - Fork 28
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
Prevent Unauthorized Users from creating issues in devpool #1330
Prevent Unauthorized Users from creating issues in devpool #1330
Conversation
@jordan-ae tests have failed If it's not possible to delete issues via a github cli script and we must rely on closing issues then you will have to verify that those closed issues are not affecting the statistics calculations. I don't think the I see that all of your issues have been closed in your forked |
I can delete issues from my It should be possible to write a script which performs this programmatically. Flags exist to delete without confirmation so no need to handle command-line inputs. You could fetch all issues, filter those that aren't auth'd and loop all urls deleting each with an |
@Keyrxng i attempt to do do several times during the day unsuccessfully. I'll try again first thing tomorrow morning |
EDIT: My mistake, I thought for a sec the original spec was a separate cron job from |
@Keyrxng I've given deleting issues a try again and still not been able to do so programmatically. The flag to delete without confirmation doesn't bypass github's restriction. Here's the authorization error that keeps popping up. I've bumped up my bot permission to have
|
@jordan-ae I'm not certain but it's likely your token/permissions. If that's the standard runner token that's being used it won't have admin rights to the org, you may have to pass a custom token. I'd have went the way of writing it in TS personally as I'd find it easier to debug but that's just my preference.
It's not your bot token that's being used I don't think it looks like it's the standard runner/repo token. Have you tried it with a PAT which has admin rights to the org where the issues exist? |
I guess it can be either a step in the workflow or included in the Typescript logic. I'd prefer it built with TS but I wouldn't prevent merging for that reason. Whatever way you choose to handle it, you need to consider the fact that other contributors after forking the devpool and running your workflow will automatically have all issues deleted which would make life difficult for future development. So this should be handled elegantly similar to how we did with spam links. |
@rndquu can you delete the two issues created from jordans bot? |
issue_title=$(echo "$issue" | jq -r '.title') | ||
author_association=$(echo "$issue" | jq -r '.authorAssociation') | ||
|
||
if [[ ! " ${AUTHORIZED_ORG_IDS[@]} " =~ " ${issue_author_login} " && "$author_association" != "OWNER" ]]; then |
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.
I assume this is only for bots. I suppose thats fine because humans shouldn't open issues here anyways.
.github/workflows/sync-issues.yml
Outdated
- name: Delete Unauthorized Issues | ||
run: bash ./scripts/delete-unauthorized-issues.sh | ||
env: | ||
GH_TOKEN: ${{ secrets.PAT }} |
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.
Please don't do this with having to add an extra secret PAT when we already have a bot auth token from the previous step. Use the bot auth and I can merge this in.
- name: Get GitHub App token
uses: tibdex/[email protected]
id: get_installation_token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
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.
Also can you confirm that this script works? I'm pretty sure the default environment variable name is GITHUB_TOKEN
?
I am assuming that the bot auth token acts the same as a PAT so it should work but technically this is untested. |
Resolves #31
This pull request introduces enhancements preventing unauthorized bots from creating issues in the devpool-directory repository. Specifically, it implements a mechanism to detect and close issues created by entities that are not authorized, based on their association with our approved GitHub organizations.
Key Changes:
Authorization Check for Issue Creation:
Issue Closure for Unauthorized Attempts:
Workflow Testing:
Conducted a workflow QA run to test the closing of unauthorized issues:
Workflow QA Run
Closed Unauthorized Issue
To make this workflow run possible, I temporarily disabled the check for unauthorized users when creating an issue. Under normal circumstances, this check should prevent unauthorized bots from creating issues altogether.