2024-08-26 16:08:50 -05:00
# GitHub Searcher
2024-08-29 06:04:28 -05:00
GitHub Searcher is a command-line tool to search GitHub repositories and users for PoC exploits and CVEs. It supports various search types and can output results in JSON format.
2024-08-26 16:08:50 -05:00
## Features
2024-08-29 06:04:28 -05:00
- Search GitHub repositories by query.
- Search GitHub users by query.
- Search within repository names.
- Retrieve open issues and pull requests for repositories.
- Retrieve file contents for repositories.
- Output results in JSON format.
2024-08-26 16:08:50 -05:00
## Requirements
- Python 3.x
- `PyGithub` library
## Installation
1. Clone the repository:
2024-08-29 06:04:28 -05:00
```sh
git clone https://github.com/yourusername/github_searcher.git
2024-08-26 16:08:50 -05:00
cd github_searcher
```
2. Install the required dependencies:
2024-08-29 06:04:28 -05:00
```sh
2024-08-26 16:08:50 -05:00
pip install PyGithub
```
2024-08-29 06:04:28 -05:00
3. Set the `GITHUB_ACCESS_TOKEN` environment variable with your GitHub access token:
```sh
2024-08-26 16:08:50 -05:00
export GITHUB_ACCESS_TOKEN=your_access_token
```
## Usage
2024-08-29 06:04:28 -05:00
```sh
python github_searcher.py --query QUERY --search_type SEARCH_TYPE [--get_file_contents] [--get_open_issues] [--get_open_pull_requests] [--json]
```
2024-08-26 16:08:50 -05:00
2024-08-29 06:04:28 -05:00
### Arguments
- `--query` : The search query (required).
- `--search_type` : The type of search to perform (required). Choices are:
- `repo` : Search repositories.
- `users` : Search users.
- `in-repo-name` : Search within repository names.
- `--get_file_contents` : Get the contents of repository results (optional).
- `--get_open_issues` : Get the open issues of repository results (optional).
- `--get_open_pull_requests` : Get the open pull requests of repository results (optional).
- `--json` : Output the results in JSON format (optional).
### Examples
1. Search repositories with a query:
```sh
python github_searcher.py --query "machine learning" --search_type repo
```
2. Search users with a query:
```sh
python github_searcher.py --query "john doe" --search_type users
```
3. Search within repository names:
```sh
python github_searcher.py --query "tensorflow" --search_type in-repo-name
```
4. Get open issues and pull requests for repositories:
```sh
python github_searcher.py --query "machine learning" --search_type repo --get_open_issues --get_open_pull_requests
```
5. Output results in JSON format:
```sh
python github_searcher.py --query "machine learning" --search_type repo --json
```
6. Use Docker Compose to search for a specific CVE-ID and output results to a file:
```sh
2025-01-21 10:13:26 -06:00
docker-compose run --rm app python3 /usr/src/app/github_searcher.py --query=CVE-2024-5932 --search_type=in-repo-name --get_open_issues --get_open_pull_requests --get_file_contents --json > cve-2024-5932
```
7. Search for a specific repository by name and get open issues:
```sh
python github_searcher.py --query "torvalds/linux" --search_type in-repo-name --get_open_issues
```
8. Search for a specific repository by name and get open pull requests:
```sh
python github_searcher.py --query "apple/swift" --search_type in-repo-name --get_open_pull_requests
```
9. Search for a specific repository by name and get file contents:
```sh
python github_searcher.py --query "microsoft/vscode" --search_type in-repo-name --get_file_contents
```
10. Search for a specific repository by name and output results in JSON format:
```sh
python github_searcher.py --query "facebook/react" --search_type in-repo-name --json
```
## Output
The output will include the following details based on the flags provided:
- **Repository URL**: The URL of the repository.
- **Open Issues**: A list of open issues with their titles and URLs.
- **Open Pull Requests**: A list of open pull requests with their titles and URLs.
- **File Contents**: A list of file contents with their names, SHAs, sizes, encodings, and URLs.
## License
This project is licensed under the MIT License.