Skip to content

feat(package): pin GitHub refs to commit SHAs before package scans - #56

Merged
Sahilb315 merged 3 commits into
mainfrom
claude/safedep-github-ref-resolution-fj4w17
Sep 2, 2026
Merged

feat(package): pin GitHub refs to commit SHAs before package scans#56
Sahilb315 merged 3 commits into
mainfrom
claude/safedep-github-ref-resolution-fj4w17

Conversation

@abhisek

@abhisek abhisek commented Sep 2, 2026

Copy link
Copy Markdown
Member

Why

safedep package scan run pkg:github/owner/repo@main sent main as the version. A branch or tag moves, so the scan and its idempotency key drifted away from the code that was reviewed. vet already pins refs in its malware enricher. The CLI now does the same.

What

  • Every GitHub target (github_actions and github_repository) is resolved to the commit SHA its ref points to. This applies to the pkg:github/... PURL, a GitHub URL and the explicit triple, in run, get, show and the list filter, so all four name the same immutable version.
  • A full SHA passes through without a lookup. A GitHub URL without /tree/<ref> resolves to the head of the default branch.
  • App.GitHub() builds the client from the same GITHUB_TOKEN, GITHUB_CLIENT_ID/GITHUB_CLIENT_SECRET and GITHUB_BASE_URL/GITHUB_UPLOAD_URL variables vet reads. Commands pass a lazy resolver as a one-method interface, so the client is built only on the first GitHub target and --scan-id lookups never touch it. Tests use a fake and prove that non-GitHub targets never call it.
  • The resolution message goes through tui.Info on stderr, so --output json stays clean.
  • Docs for run, get, show and list describe the resolution and the GITHUB_TOKEN rate-limit note.

Dependency

Uses GithubClient.ResolveCommitSHA and IsCommitSHA from safedep/dry#154, now merged. go.mod pins dry to the main commit that carries it. The dry bump also pulls a newer API SDK, so the jfrog fake threat intel client gains the new GetCampaignPackageReports RPC to keep satisfying the interface.

Verification

  • go test ./... passes.
  • golangci-lint run reports 0 issues.
  • Convention tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_016cyGZqVsNaGBCzrof9qtDc

`safedep package scan run pkg:github/owner/repo@main` sent `main` as the
version. A branch or tag moves, so the scan and its idempotency key drifted
away from the code that was reviewed. Resolve every GitHub target to the
commit SHA it points to, in `run`, `get`, `show` and the `list` filter, so
all four commands name the same immutable version. A full SHA passes
through without a lookup. A GitHub URL without a ref resolves to the head
of the default branch.

The resolver is `adapters.GithubClient.ResolveCommitSHA` from dry, built in
`App.GitHub()` from the same GITHUB_* variables vet reads. Commands accept
it as a one-method interface so tests use a fake and prove that non-GitHub
targets never touch the network.

The dry bump also pulls a newer API SDK. The jfrog fake threat intel client
gains the new RPC so it still satisfies the interface.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016cyGZqVsNaGBCzrof9qtDc
@safedep

safedep Bot commented Sep 2, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

Package Details
Package Malware Vulnerability Risky License Report
icon buf.build/gen/go/safedep/api/grpc/go @ v1.6.2-20260901164227-b6b5c7191208.1
go.mod
ok icon
ok icon
ok icon
🔗
icon buf.build/gen/go/safedep/api/protocolbuffers/go @ v1.36.12-20260901164227-b6b5c7191208.1
go.mod
ok icon
ok icon
ok icon
🔗
icon github.com/safedep/dry @ v0.0.0-20260902191040-800bc36ff686
go.mod
ok icon
ok icon
ok icon
🔗

View complete scan results →

This report is generated by SafeDep GitHub App

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23e913b60a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cmd/packages/get.go Outdated
abhisek and others added 2 commits September 2, 2026 18:56
`get --scan-id` and `show --scan-id` never resolve a target, but the commands
built the GitHub client before the lookup. A bad GITHUB_BASE_URL then failed
a lookup that needs only the control plane. The resolver now builds the
client on the first GitHub target.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016cyGZqVsNaGBCzrof9qtDc
safedep/dry#154 merged. Move the pin from the branch commit to main head.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016cyGZqVsNaGBCzrof9qtDc
@Sahilb315
Sahilb315 merged commit b8635ac into main Sep 2, 2026
6 checks passed
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.

2 participants