Skip to content

feat: CDN registry generator for Go third-party packages#647

Open
shivasurya wants to merge 1 commit intoshiva/pr-06-golang-thirdpartyfrom
shiva/pr-07-golang-thirdparty
Open

feat: CDN registry generator for Go third-party packages#647
shivasurya wants to merge 1 commit intoshiva/pr-06-golang-thirdpartyfrom
shiva/pr-07-golang-thirdparty

Conversation

@shivasurya
Copy link
Copy Markdown
Owner

Summary

  • Adds ExtractSinglePackage(packageDir, importPath string) (*Package, error) to tools/internal/goextract — reuses the existing go/ast extraction pipeline for a single directory (third-party module cache path from go mod download -json)
  • Adds tools/generate_go_thirdparty_registry.go CLI tool (build tag: cpf_generate_thirdparty_registry) that downloads modules, extracts exported APIs, writes per-package JSON + manifest.json with sha256 checksums — produces CDN content consumed by GoThirdPartyRegistryRemote from PR-06
  • Adds tools/top1000.txt with Tier 1 (~30 security-relevant packages): web frameworks, ORM/DB drivers, HTTP clients, auth/crypto, logging, cloud SDKs
  • Module path encoding (slashes → underscores) is consistent with PR-06's encodeModulePath
  • Tool continues on per-package failures (skip + log, no abort) and sorts manifest alphabetically for deterministic output

Test plan

  • go test ./tools/internal/goextract/ — all existing + 9 new ExtractSinglePackage tests pass
  • go test -tags cpf_generate_thirdparty_registry ./tools/ — 16 CLI helper tests (readPackageList, encodeModulePath, downloadModule with injected runner, end-to-end pipeline)
  • go test ./... — full suite clean
  • golangci-lint run ./tools/internal/goextract/ — zero issues
  • golangci-lint run --build-tags cpf_generate_thirdparty_registry ./tools/ — zero issues
  • Checksum format "sha256:" + hex matches PR-06 loader verification

🤖 Generated with Claude Code

…CLI tool

Extends tools/internal/goextract with ExtractSinglePackage for single-directory
extraction, and adds a CLI tool that downloads modules via `go mod download -json`
and produces CDN-ready JSON files consumed by GoThirdPartyRegistryRemote (PR-06).

Changes:
- ExtractSinglePackage(packageDir, importPath): reuses go/ast pipeline to extract
  exported symbols from a single directory; skips *_test.go files, gracefully
  handles per-file parse errors (cgo, build-constrained syntax)
- generate_go_thirdparty_registry.go: CLI with --packages-file and --output-dir
  flags; downloads modules, extracts metadata, writes {encoded}.json + manifest.json
  with sha256 checksums; continues on per-package failures (skip + log)
- top1000.txt: Tier 1 list of ~30 security-relevant packages (web frameworks,
  ORM/DB, HTTP clients, auth/crypto, logging, cloud SDKs)
- 9 tests for ExtractSinglePackage; 16 tests for CLI helpers (readPackageList,
  encodeModulePath, downloadModule with injected cmdRunner, end-to-end pipeline)
- Module path encoding matches PR-06 convention: slashes → underscores

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shivasurya shivasurya added enhancement New feature or request go Pull requests that update go code labels Apr 5, 2026
@shivasurya shivasurya self-assigned this Apr 5, 2026
@safedep
Copy link
Copy Markdown

safedep bot commented Apr 5, 2026

SafeDep Report Summary

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

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep Github App

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

Code Pathfinder Security Scan

Pass Critical High Medium Low Info

No security issues detected.

Metric Value
Files Scanned 5
Rules 205

Powered by Code Pathfinder

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 5, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.45%. Comparing base (f3bd26c) to head (e51b501).

Files with missing lines Patch % Lines
sast-engine/tools/internal/goextract/extractor.go 86.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           shiva/pr-06-golang-thirdparty     #647   +/-   ##
==============================================================
  Coverage                          84.45%   84.45%           
==============================================================
  Files                                163      163           
  Lines                              23564    23594   +30     
==============================================================
+ Hits                               19900    19926   +26     
- Misses                              2918     2920    +2     
- Partials                             746      748    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant