Add Dependabot Alert Dismissal migration support to GEI
This PR adds support for migrating Dependabot alert dismissals in the GitHub Enterprise Importer (GEI), addressing the need to preserve dismissed Dependabot alerts and their dismissal reasons when migrating repositories.
New Features
CLI Command
gh gei migrate-dependabot-alerts- New command to migrate Dependabot alert states and dismissal information- Supports all standard GEI options: source/target org/repo, API URLs, PATs, dry-run mode, verbose logging
- Follows the same pattern as existing
migrate-code-scanning-alertsandmigrate-secret-alertscommands
Alert Matching Strategy
The implementation uses a robust two-tier matching approach:
- Primary: Match by GHSA ID + package name + manifest path
- Fallback: Match by CVE ID + package name + manifest path
This ensures reliable alert matching even when security advisory IDs differ between source and target instances.
Supported Dismissal Reasons
Preserves all standard Dependabot dismissal reasons:
false_positive- Alert is not actually vulnerableinaccurate- Alert is not accuratenot_used- Vulnerable code is not usedno_bandwidth- No time to fix right nowtolerable_risk- Risk is acceptable
State Migration
- Migrates
openanddismissedstates (skipsfixedas it's automatically managed) - Preserves dismissal comments and timestamps
- Comprehensive error handling and logging
- Dry-run mode for testing without making changes
Implementation Details
Core Components
- Models:
DependabotAlert,DependabotAlertDependency,DependabotAlertSecurityAdvisory,DependabotAlertSecurityVulnerability - State Management:
DependabotAlertStatewith validation for states and dismissal reasons - Service:
DependabotAlertServicehandles the migration logic - API Integration: GitHub API methods for retrieving and updating Dependabot alerts
- Factory:
DependabotAlertServiceFactoryfor dependency injection
Error Handling
- Validates alert states and dismissal reasons
- Throws exception if alerts cannot be matched (prevents partial migrations)
- Comprehensive logging of success, skipped, and failed operations
- Graceful handling of non-migratable alert states
Testing
Added 15 comprehensive tests covering:
- DependabotAlertService: 8 tests for core migration logic
- GitHub API integration: 6 tests for API methods and data parsing
- Command interface: 3 tests for CLI argument handling
All existing tests continue to pass (903 total tests).
Example Usage
# Migrate Dependabot alerts with dry-run
gh gei migrate-dependabot-alerts \
--source-org myorg \
--source-repo myrepo \
--target-org neworg \
--target-repo newrepo \
--dry-run
# Migrate between GitHub instances
gh gei migrate-dependabot-alerts \
--source-org myorg \
--source-repo myrepo \
--target-org neworg \
--target-repo newrepo \
--ghes-api-url https://github.mycompany.com/api/v3 \
--github-source-pat $SOURCE_PAT \
--github-target-pat $TARGET_PAT
This resolves the issue for organizations with large numbers of dismissed Dependabot alerts who need to preserve their security review decisions during repository migrations.
Fixes #1286.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.github.com
- Triggering command:
/home/REDACTED/work/gh-gei/gh-gei/src/gei/bin/Debug/net8.0/gei migrate-dependabot-alerts --dry-run --source-org test-org --source-repo test-repo --target-org test-org --target-repo test-repo --github-source-pat dummy --github-target-pat dummy(dns block)http://www.microsoft.com:80/pkiops/crl/Microsoft%20Identity%20Verification%20Root%20Certificate%20Authority%202020.crl
- Triggering command:
dotnet build src/OctoshiftCLI.sln(http block)http://www.microsoft.com:80/pkiops/crl/Microsoft%20Public%20RSA%20Timestamping%20CA%202020.crl
- Triggering command:
dotnet build src/OctoshiftCLI.sln(http block)www.githubstatus.com
- Triggering command:
/home/REDACTED/work/gh-gei/gh-gei/src/gei/bin/Debug/net8.0/gei --help(dns block)- Triggering command:
/home/REDACTED/work/gh-gei/gh-gei/src/gei/bin/Debug/net8.0/gei migrate-dependabot-alerts --help(dns block)- Triggering command:
/home/REDACTED/work/gh-gei/gh-gei/src/gei/bin/Debug/net8.0/gei migrate-dependabot-alerts --dry-run --source-org test-org --source-repo test-repo --target-org test-org --target-repo test-repo --github-source-pat dummy --github-target-pat dummy(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
π‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Unit Test Results
ββ1 filesββββ1 suitesβββ21s β±οΈ 914 testsβ914 β β0 π€β0 β 915 runsββ915 β β0 π€β0 β
Results for commit 0d858757.
:recycle: This comment has been updated with latest results.
dotnet format is returning a number of errors/warnings which need to be fixed up to pass the build
dotnet formatis returning a number of errors/warnings which need to be fixed up to pass the build
Fixed the formatting issues. The problem was missing final newlines in the newly added Dependabot Alert files - applied dotnet format to add the required newlines and fix other formatting issues. Commit 3d315b1.
| Package | Line Rate | Branch Rate | Complexity | Health |
|---|---|---|---|---|
| Octoshift | 88% | 76% | 1550 | β |
| bbs2gh | 82% | 76% | 669 | β |
| gei | 80% | 70% | 646 | β |
| ado2gh | 84% | 78% | 618 | β |
| Summary | 85% (7510 / 8885) | 75% (1781 / 2368) | 3483 | β |