bytelyst-devops-tools/github_access_scripts/README.md

90 lines
3.3 KiB
Markdown

# GitHub Access Scripts
This directory contains scripts to check user access to GitHub repositories.
## Setup
1. **Create `accounts.json`:** Before running the scripts, create a local `accounts.json` file in the repo root from the provided template:
```bash
cp accounts.example.json accounts.json
```
Then fill it with the GitHub usernames and personal access tokens you want to use for scanning.
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. Keep `accounts.json` local only and never commit it. The repo now provides `accounts.example.json` as the shareable template.
## Usage
Make sure the scripts are executable before running them:
```bash
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:**
```bash
./github_access_scripts/check_repo_access.sh <GITHUB_USER_NAME> <REPO_FULL_NAME>
```
**Example:**
```bash
./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:**
```bash
./github_access_scripts/list_user_repos.sh <GITHUB_USER_NAME>
```
## GitHub Repository Scanners
This directory (`github_repo_scanners`) contains scripts for more advanced repository scanning and data extraction.
### `create_user_repo_lists.sh`
This script scans all accounts in `accounts.json` and creates a JSON file for each user containing a list of repositories they have access to.
**Command:**
```bash
./github_repo_scanners/create_user_repo_lists.sh <path_to_accounts.json>
```
**Example:**
```bash
./github_repo_scanners/create_user_repo_lists.sh accounts.json
```
### `create_contributor_repo_lists.sh`
This script scans all accounts in `accounts.json`, finds all contributors to their repositories, and creates a JSON file for each contributor listing the repositories they have contributed to.
**Command:**
```bash
./github_repo_scanners/create_contributor_repo_lists.sh <path_to_accounts.json>
```
**Example:**
```bash
./github_repo_scanners/create_contributor_repo_lists.sh accounts.json
```
> **Note on File Visibility:** In some environments, tools like `list_directory` or `read_file` within certain CLI agents might experience caching or synchronization issues, leading to files not appearing immediately after creation, even if the underlying shell commands confirm their existence. If you encounter such issues, direct shell commands (`ls`, `cat`) might provide more accurate results.
**Example:**
```bash
./github_access_scripts/list_user_repos.sh DARKenergem
```