This tool is designed to analyze GitHub repositories and check if critical security configurations, such as Security Policies, Dependabot Alerts, and Code Scanning, are enabled. Additionally, it allows you to create a GitHub issue with the analysis report to help collaborators track and address missing security configurations.
- Security Policy: Checks if the repository has a
SECURITY.mdfile to provide guidelines for reporting vulnerabilities. - Dependabot Alerts: Verifies if Dependabot alerts are enabled for the repository.
- Code Scanning: Checks if GitHub Advanced Security's code scanning is enabled.
- GitHub Issue Creation: Optionally creates a GitHub issue with the analysis report and actionable recommendations.
- Python 3.12 or higher installed on your machine.
- A GitHub Personal Access Token (PAT) with the necessary permissions:
repo(for private repositories).read:security_events(for accessing security alerts).write:issues(to create issues in repositories).
-
Clone the Repository:
git clone https://github.com/your-username/gitsecure.git cd gitsecure -
Install Dependencies:
Use Poetry to manage dependencies:
poetry install
-
Set Up Environment Variables: Create a
.envfile in the project directory with the following content:GITHUB_TOKEN='your_personal_access_token'
To analyze a repository, use the gitsecure command:
poetry run gitsecure --repourl https://github.com/owner/repoTo automatically create a GitHub issue with the analysis report, use the --create-issue flag:
poetry run gitsecure --repourl https://github.com/owner/repo --create-issue--repourlor-r: The URL of the GitHub repository to analyze.--create-issue: Creates a GitHub issue in the analyzed repository with the security analysis and recommendations.
When you run the gitsecure tool with the --create-issue flag, you will see output similar to the following:
poetry run gitsecure --repourl https://github.com/AlishChhetri/gitsecure --create-issueOutput:
╭──────────────────────────────────────────────────────────╮
│ Repository: AlishChhetri/gitsecure │
╰──────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────╮
│ GitHub Security Compliance │
│ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓ │
│ ┃ Feature ┃ Status ┃ │
│ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩ │
│ │ Security Policy │ ✗ │ │
│ ├──────────────────────────────────┼─────────────┤ │
│ │ Dependabot Alerts │ ✗ │ │
│ ├──────────────────────────────────┼─────────────┤ │
│ │ Code Scanning │ ✗ │ │
│ └──────────────────────────────────┴─────────────┘ │
╰──────────────────────────────────────────────────────────╯
╭──────────────────── Recommendations ─────────────────────╮
│ - Add a SECURITY.md file. │
│ - Enable Dependabot alerts. │
│ - Enable code scanning. │
╰──────────────────────────────────────────────────────────╯
[bold green]GitHub Issue created successfully:[/] https://github.com/AlishChhetri/gitsecure/issues/1
The tool provides three main sections in its output:
-
Repository Panel: Displays the repository owner and name for context.
-
Security Compliance Table:
Feature Status Security Policy ✓ or ✗ Dependabot Alerts ✓ or ✗ Code Scanning ✓ or ✗ - ✓: The feature is enabled or exists.
- ✗: The feature is missing or not enabled.
-
Recommendations Panel: Lists actions you should take if certain features are not enabled:
- Add a SECURITY.md file.: Guidance to add aSECURITY.mdfile.- Enable Dependabot alerts.: Instructions to enable Dependabot alerts.- Enable code scanning.: Steps to enable GitHub's code scanning feature.
-
GitHub Issue Creation: If the
--create-issueflag is used, the tool creates a GitHub issue in the repository with:- Detailed analysis.
- Benefits of enabling the missing features.
- Steps to enable these features, with links to GitHub documentation.
-
Add a SECURITY.md File:
- Why Enable: A
SECURITY.mdfile provides contributors with clear instructions on how to report vulnerabilities responsibly. - How to Enable:
- Go to your repository on GitHub.
- Navigate to the "Security" section from the navigation bar.
- Under "Policy", click "Set up a Security Policy" to create a
SECURITY.mdfile.
- Documentation: GitHub Security Policies
- Why Enable: A
-
Enable Dependabot Alerts:
- Why Enable: Dependabot helps you automatically identify and fix vulnerabilities in your dependencies.
- How to Enable:
- Go to your repository on GitHub.
- Navigate to the "Security" section from the navigation bar.
- Enable Dependabot Alerts under the "Dependency Graph" section.
- Documentation: GitHub Dependabot Alerts
-
Enable Code Scanning:
- Why Enable: Code scanning automatically analyzes your code for security vulnerabilities.
- How to Enable:
- Go to your repository on GitHub.
- Navigate to the "Security" section from the navigation bar.
- Under "Code Scanning Alerts", click "Set up code scanning".
- Choose CodeQL Analysis or integrate a custom scanning tool.
- Documentation: GitHub Code Scanning
This project is licensed under the MIT License. See the LICENSE file for details.