|
| 1 | +name: fix-dependabot-alert |
| 2 | +description: >- |
| 3 | + Picks the highest-severity open Dependabot alert, upgrades the |
| 4 | + vulnerable dependency, verifies tests pass, and opens a pull request. |
| 5 | +triggers: |
| 6 | + - context: |
| 7 | + projects: {} |
| 8 | + manual: {} |
| 9 | +action: |
| 10 | + limits: |
| 11 | + maxParallel: 1 |
| 12 | + maxTotal: 10 |
| 13 | + steps: |
| 14 | + - agent: |
| 15 | + prompt: | |
| 16 | + Query the GitHub Dependabot alerts for this repository using the GitHub CLI: |
| 17 | +
|
| 18 | + gh api repos/{owner}/{repo}/dependabot/alerts \ |
| 19 | + --jq '[.[] | select(.state=="open")] | sort_by(.security_advisory.cvss.score) | reverse | .[0]' |
| 20 | +
|
| 21 | + From the highest-severity open alert, extract: |
| 22 | + 1. Alert number |
| 23 | + 2. Package name and ecosystem |
| 24 | + 3. Vulnerable version range |
| 25 | + 4. Patched version (from `security_advisory.vulnerabilities[].first_patched_version`) |
| 26 | + 5. CVE ID and CVSS score |
| 27 | + 6. Advisory summary |
| 28 | + 7. The manifest file path (e.g. `pom.xml`) |
| 29 | +
|
| 30 | + Read the manifest file to understand how the dependency is declared. |
| 31 | + Determine whether the version is pinned directly or inherited from a parent BOM. |
| 32 | +
|
| 33 | + Do NOT make any code changes yet. |
| 34 | +
|
| 35 | + - agent: |
| 36 | + prompt: | |
| 37 | + Using the alert identified in the previous step: |
| 38 | +
|
| 39 | + 1. Upgrade the vulnerable dependency to the patched version (or newer). |
| 40 | + - If the version is declared in `pom.xml` properties or directly, update it there. |
| 41 | + - If it is inherited from a parent BOM (e.g. Spring Boot parent), check whether |
| 42 | + upgrading the parent resolves the vulnerability. If not, add an explicit |
| 43 | + version override in the `<properties>` or `<dependencyManagement>` section. |
| 44 | + 2. Follow the project's existing conventions for dependency management. |
| 45 | +
|
| 46 | + Do NOT commit or run tests yet. |
| 47 | +
|
| 48 | + - agent: |
| 49 | + prompt: | |
| 50 | + Verify the fix from the previous step: |
| 51 | +
|
| 52 | + 1. Run `./mvnw compile test` to compile and run all tests. |
| 53 | + 2. If compilation or tests fail: |
| 54 | + a. Read the error output carefully. |
| 55 | + b. Identify whether the failure is caused by the upgrade or a pre-existing issue. |
| 56 | + c. If caused by the upgrade, check for breaking API changes and adapt the code. |
| 57 | + d. Rerun `./mvnw compile test`. |
| 58 | + e. Repeat until all tests pass. |
| 59 | + 3. Run `./mvnw dependency:tree -Dincludes=<groupId>:<artifactId>` to confirm |
| 60 | + the vulnerable version is no longer in the dependency tree. |
| 61 | + 4. Once tests pass and the old version is gone, confirm the fix is complete. |
| 62 | +
|
| 63 | + - pullRequest: |
| 64 | + branch: dependabot-fix/ |
| 65 | + title: 'Dependabot-Fix: ' |
| 66 | + description: | |
| 67 | + ## Dependabot Alert |
| 68 | +
|
| 69 | + | Field | Value | |
| 70 | + |-------|-------| |
| 71 | + | **Alert** | [View alert](https://github.com/ona-samples/github-security/security/dependabot/<alert-number>) | |
| 72 | + | **CVE** | `<cve-id>` | |
| 73 | + | **CVSS** | <cvss-score> | |
| 74 | + | **Package** | `<package-name>` | |
| 75 | + | **Vulnerable** | `<vulnerable-version>` | |
| 76 | + | **Fixed** | `<patched-version>` | |
| 77 | + | **Advisory** | <advisory-summary> | |
| 78 | +
|
| 79 | + ## What changed |
| 80 | +
|
| 81 | + <one-or-two-sentence explanation of the dependency upgrade and why it resolves the vulnerability> |
| 82 | +
|
| 83 | + ## Verification |
| 84 | +
|
| 85 | + - [x] `./mvnw compile test` passes |
| 86 | + - [x] `./mvnw dependency:tree` confirms vulnerable version is removed |
| 87 | + - [x] Upgrade is minimal and preserves existing behavior |
0 commit comments