Skip to content

Harden Dependabot policy evaluation when Dependency Graph enrichment fails - #206

Merged
felickz merged 15 commits into
mainfrom
copilot/bug-fix-dependabot-alert-exception
Aug 23, 2026
Merged

Harden Dependabot policy evaluation when Dependency Graph enrichment fails#206
felickz merged 15 commits into
mainfrom
copilot/bug-fix-dependabot-alert-exception

Conversation

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Dependabot checks could abort with a 400 path during action execution, which prevented expected alert reporting in repositories with active vulnerability alerts. This change keeps evaluation running even when dependency enrichment is unavailable.

  • Problem scope

    • checkDependabot assumed Dependency Graph data was always retrievable and always mappable by purl, causing alert processing to stop in failure/miss scenarios.
  • Behavior change in Dependabot flow

    • Wrap depgraph.getDependencies() with GHASToolkitError handling.
    • On dependency graph failure, continue evaluating Dependabot alerts instead of aborting the check.
    • When findPurl(alert.purl) has no match, continue and evaluate against fallback names derived from alert.purl.
  • Policy matching fallback

    • If enrichment is unavailable, policy names input now uses:
      • alert.purl
      • alert.purl (versionless fallback slot)
  • Regression coverage

    • Added focused tests for:
      • Dependency Graph API 400 during Dependabot evaluation.
      • Missing dependency match for an alert purl.
try:
    dependencies = depgraph.getDependencies()
except GHASToolkitError:
    dependencies = None

dependency = dependencies.findPurl(alert.purl) if dependencies else None
names = [
    dependency.fullname if dependency else alert.purl,
    dependency.getPurl(version=False) if dependency else alert.purl,
]

Copilot AI lite review requested due to automatic review settings August 18, 2026 22:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 18, 2026 22:39
Copilot AI changed the title [WIP] Fix exception when dependabot alerts are found during action execution Harden Dependabot policy evaluation when Dependency Graph enrichment fails Aug 18, 2026
Copilot AI requested a review from felickz August 18, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread ghascompliance/checks.py
@felickz
felickz requested a balanced review from Copilot August 18, 2026 22:41
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread ghascompliance/checks.py Outdated
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 18, 2026 22:44
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (1)

ghascompliance/checks.py:249

  • The missing-match fallback is not reachable for a non-empty real dependency graph: Dependencies.findPurl() currently uses the tautology dep.fullname == dep.fullname (vendor/ghastoolkit/supplychain/dependencies.py:269), so it returns the first dependency even when alert.purl does not match. This can evaluate the alert against an unrelated package instead of the new fallback. Correct the findPurl comparison and cover this path with a real Dependencies collection rather than mocking findPurl.
            # Find the dependency from the graph
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings August 18, 2026 22:47
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 19, 2026 04:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread ghascompliance/checks.py Outdated
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 19, 2026 04:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@felickz

felickz commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

…dabot-alert-exception

# Conflicts:
#	ghascompliance/checks.py
#	tests/test_checks.py

Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 19, 2026 05:14
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
@felickz
felickz marked this pull request as ready for review August 19, 2026 05:15
@felickz
felickz requested a review from a team as a code owner August 19, 2026 05:15
@felickz
felickz requested a review from adrienpessu August 19, 2026 05:15
Copilot AI and others added 2 commits August 19, 2026 05:15
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread ghascompliance/checks.py
from ghastoolkit import (
GitHub,
CodeScanning,
Dependency,
Copilot AI review requested due to automatic review settings August 19, 2026 05:17
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>

Copilot AI commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts in 264a7f5 and pushed follow-up validation/review cleanup through 38b2e75.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

ghascompliance/checks.py:299

  • The lookup assumes Dependabot ecosystem names are identical to Dependency Graph PURL types. For example, the alert adapter produces pkg:pip/... (vendor/ghastoolkit/octokit/dependabot.py:345), while SPDX Python dependencies use the canonical pkg:pypi/...; both this PURL comparison and the manager/fullname fallback therefore miss a real Python dependency. This also affects ecosystems such as Go/golang, RubyGems/gem, and Rust/cargo, causing package-name conditions to receive only the fallback alert PURL. Normalize Dependabot ecosystem names to their PURL type aliases before matching and add representative coverage.
                        if unquote(dep.getPurl(version=False)).lower() == alert_purl
                        or (
                            (dep.manager or "").lower() == alert_manager
                            and unquote(dep.fullname).lower() == alert_fullname

ghascompliance/checks.py:258

  • GHASToolkitError.status is optional, and getDependencies() can raise one without a status (for example, for an unsupported GHES version). This warning then reports status None and discards the useful exception message. Include err itself so the fallback remains diagnosable while still showing HTTP status codes when available.
                        f"Dependency Graph API request failed with status {err.status}; processing Dependabot alerts without dependency enrichment"
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@felickz
felickz merged commit 3930133 into main Aug 23, 2026
17 checks passed
@felickz
felickz deleted the copilot/bug-fix-dependabot-alert-exception branch August 23, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Got exception when dependabot alerts were found in repo during action execution

3 participants