bytelyst-devops-tools/github_access_scripts/README.md

2.2 KiB

GitHub Access Scripts

This directory contains scripts to check user access to GitHub repositories.

Setup

  1. Create accounts.json: Before running the scripts, you need to create an accounts.json file in the root of this project. This file should contain an array of GitHub accounts, each with a username and a personal access token (PAT).

    Example accounts.json:

    [
      {
        "user": "your_github_username",
        "token": "your_personal_access_token"
      },
      {
        "user": "another_github_username",
        "token": "another_personal_access_token"
      }
    ]
    
  2. Permissions: The personal access tokens require the repo scope to read repository information and collaborator lists.

Security Warning: Storing personal access tokens in a plaintext file is a security risk. If this file is ever exposed, your accounts could be compromised. For better security, consider using environment variables or a dedicated secrets management tool to handle these credentials.

Usage

Make sure the scripts are executable before running them:

chmod +x github_access_scripts/check_repo_access.sh
chmod +x github_access_scripts/list_user_repos.sh

check_repo_access.sh

This script checks if a specific user has collaborator access to a single, specified repository.

Command:

./github_access_scripts/check_repo_access.sh <GITHUB_USER_NAME> <REPO_FULL_NAME>

Example:

./github_access_scripts/check_repo_access.sh DARKenergem saravanakumardb/vv-note-mcp-agent-intern-naman

list_user_repos.sh

This script attempts to list all repositories a given user has access to, by scanning through the repositories of the accounts listed in accounts.json.

Note: This script has limitations. It only checks for access on repositories that the authenticated users (from accounts.json) are members of. It may not find all repositories a user has access to if they have access to repos outside of those organizations/users. For checking access to a specific repository, check_repo_access.sh is more reliable.

Command:

./github_access_scripts/list_user_repos.sh <GITHUB_USER_NAME>

Example:

./github_access_scripts/list_user_repos.sh DARKenergem