-
Notifications
You must be signed in to change notification settings - Fork 224
Add SBOM-based dependency discovery to gpclean workflow #15028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
838ab9a
9c06c88
7e221f8
4e271a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,6 +38,31 @@ strict: true | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| imports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - shared/mood.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Pre-download SBOM to get accurate dependency information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Download SBOM from GitHub Dependency Graph API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "📦 Downloading SBOM from GitHub Dependency Graph API..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Download SBOM using gh CLI (requires contents: read permission) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gh api \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -H "Accept: application/vnd.github+json" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "/repos/${{ github.repository }}/dependency-graph/sbom" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > /tmp/sbom.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "✅ SBOM downloaded successfully to /tmp/sbom.json" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Show SBOM summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if command -v jq &> /dev/null; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PACKAGE_COUNT=$(jq '.sbom.packages | length' /tmp/sbom.json 2>/dev/null || echo "unknown") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "📊 SBOM contains ${PACKAGE_COUNT} packages" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+52
to
+64
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Download SBOM using gh CLI (requires contents: read permission) | |
| gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "/repos/${{ github.repository }}/dependency-graph/sbom" \ | |
| > /tmp/sbom.json | |
| echo "✅ SBOM downloaded successfully to /tmp/sbom.json" | |
| # Show SBOM summary | |
| if command -v jq &> /dev/null; then | |
| PACKAGE_COUNT=$(jq '.sbom.packages | length' /tmp/sbom.json 2>/dev/null || echo "unknown") | |
| echo "📊 SBOM contains ${PACKAGE_COUNT} packages" | |
| # Download SBOM using gh CLI (requires contents: read permission). | |
| # If download fails, write an empty SBOM and allow downstream fallback | |
| # (e.g., parsing go.mod directly) to be used instead. | |
| if ! gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| "/repos/${{ github.repository }}/dependency-graph/sbom" \ | |
| > /tmp/sbom.json; then | |
| echo "⚠️ Failed to download SBOM from GitHub Dependency Graph API; falling back to go.mod parsing." | |
| echo '{"sbom":{"packages":[]}}' > /tmp/sbom.json | |
| else | |
| echo "✅ SBOM downloaded successfully to /tmp/sbom.json" | |
| fi | |
| # Show SBOM summary if jq is available and the SBOM is valid/non-empty | |
| if command -v jq &> /dev/null; then | |
| if jq -e '.sbom.packages' /tmp/sbom.json > /dev/null 2>&1; then | |
| PACKAGE_COUNT=$(jq '.sbom.packages | length' /tmp/sbom.json 2>/dev/null || echo "unknown") | |
| echo "📊 SBOM contains ${PACKAGE_COUNT} packages" | |
| else | |
| echo "⚠️ SBOM is invalid or empty; dependency analysis will rely on go.mod parsing if configured." | |
| fi |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The phase title "Download SBOM and Round-Robin Module Selection" is misleading because the SBOM is pre-downloaded in the frontmatter steps section (lines 43-65) before the agent runs. The title should be updated to reflect that the agent uses the pre-downloaded SBOM rather than downloading it.
Suggested title: "Phase 0: Extract Dependencies from SBOM and Round-Robin Module Selection" or "Phase 0: Parse Pre-Downloaded SBOM and Round-Robin Module Selection"
This issue also appears in the following locations of the same file:
- line 86
- line 349
- line 415
See below for a potential fix:
### Phase 0: Extract Dependencies from SBOM and Round-Robin Module Selection
Use the repository's SBOM (Software Bill of Materials) to get accurate dependency information, then select one module to analyze in a round-robin fashion.
1. **Use pre-downloaded SBOM**:
The workflow frontmatter has already downloaded the SBOM from the GitHub Dependency Graph API
and saved it to `/tmp/sbom.json` before this agent runs. Assume this file exists and use it as
the source of truth for dependency information; do not attempt to re-download the SBOM here.
**Note**: The pre-download step relies on the workflow's `contents: read` permission, which is
required to access the dependency graph SBOM API.
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistency in the API endpoint path: the frontmatter step uses /repos/${{ github.repository }}/dependency-graph/sbom (line 56) with a leading slash, but the agent instructions use repos/${{ github.repository }}/dependency-graph/sbom (line 89) without a leading slash.
While both formats may work with gh api, they should be consistent. The leading slash format is more explicit and aligns with REST API conventions. Update line 89 to include the leading slash for consistency.
| gh api "repos/${{ github.repository }}/dependency-graph/sbom" \ | |
| gh api "/repos/${{ github.repository }}/dependency-graph/sbom" \ |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The instruction to "Focus on direct dependencies (not dev dependencies or build tools)" may be misleading. The GitHub Dependency Graph SBOM includes all dependencies (both direct and transitive), and there's no standardized way to distinguish direct from transitive dependencies in the SPDX SBOM format using just the purl field.
The instruction should clarify how to identify direct dependencies. Options:
- Use the SBOM's relationship data if available (check
sbom.packages[].dependenciesor relationship fields) - Cross-reference with
go.modto identify direct dependencies - Remove this filtering requirement and process all Go dependencies from the SBOM
Additionally, Go doesn't have the concept of "dev dependencies" like npm does, so that part of the instruction should be removed or clarified.
| - Focus on direct dependencies (not dev dependencies or build tools) | |
| - Include all Go dependencies listed in the SBOM. The SBOM may contain both direct and transitive dependencies; if you need to restrict to direct dependencies, use SBOM relationship data (e.g., `dependencies` fields) or cross-reference with `go.mod`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot use /tmp/gh-aw/agent/