Skip to content

feat(diff): TreeLoadOptions — configurable GOPROXY and module name hint#24

Merged
svczero merged 1 commit into
mainfrom
feat/tree-load-options
May 24, 2026
Merged

feat(diff): TreeLoadOptions — configurable GOPROXY and module name hint#24
svczero merged 1 commit into
mainfrom
feat/tree-load-options

Conversation

@svczero
Copy link
Copy Markdown
Contributor

@svczero svczero commented May 24, 2026

Summary

  • Adds FingerprintTreeWithOptions and TreeLoadOptions to pkg/diff/fingerprinter.go
  • TreeLoadOptions.Proxy: overrides GOPROXY while keeping all other hardening intact (zero value keeps the secure "off" default — no behaviour change for existing callers)
  • TreeLoadOptions.ModuleNameHint: replaces synthetic.local/anonymous in the overlay go.mod for pre-modules-era trees, allowing same-module sub-package imports to resolve correctly
  • hardenedEnvWithProxy: shared env builder eliminating duplication with GetHardenedEnv
  • FingerprintTree and FingerprintTreeAdvanced refactored onto the new shared fingerprintTreeInternal path — identical behaviour

Motivation

The bench harness for the commercial pilot needs to analyse arbitrary open-source commits, including ones from repos whose module dependencies are not yet in GOMODCACHE. Without a way to configure GOPROXY, 26/28 parse failures in the pilot corpus are stuck at broken-dependency / other-package-load-error (module lookup disabled by GOPROXY=off). The product's CI scanning use case correctly uses GOPROXY=off; this adds the escape hatch for callers that have already decided network access is safe.

Test plan

  • go test ./pkg/diff/... passes
  • FingerprintTree / FingerprintTreeAdvanced call fingerprintTreeInternal with zero opts — output identical to before
  • FingerprintTreeWithOptions with Proxy: "https://proxy.golang.org,direct" resolves deps not yet in GOMODCACHE
  • TreeLoadOptions{} (zero value) behaves identically to FingerprintTree

🤖 Generated with Claude Code

…name hint

Adds FingerprintTreeWithOptions and TreeLoadOptions so callers can
override GOPROXY (e.g. to allow downloading missing dependencies from a
proxy) and supply a real module name hint for pre-modules-era trees.

The secure default (GOPROXY=off) is unchanged for FingerprintTree and
FingerprintTreeAdvanced — existing callers are unaffected.

- TreeLoadOptions.Proxy: overrides GOPROXY while keeping all other
  hardening (CGO_ENABLED=0, GOFLAGS=-mod=readonly, GOWORK=off, etc.)
- TreeLoadOptions.ModuleNameHint: replaces "synthetic.local/anonymous"
  in the overlay go.mod so pre-module imports resolve correctly
- hardenedEnvWithProxy: shared env builder used by both the zero-opts
  path and the options path (eliminates duplication with GetHardenedEnv)
- FingerprintTree/FingerprintTreeAdvanced: refactored onto the shared
  fingerprintTreeInternal path; behaviour is identical to before

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@svczero svczero merged commit de79499 into main May 24, 2026
1 of 2 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.

1 participant