Skip to content

feat: derive AgentSuffix from build origin#11341

Open
lidel wants to merge 2 commits into
masterfrom
feat/implicit-fork-agent-suffix
Open

feat: derive AgentSuffix from build origin#11341
lidel wants to merge 2 commits into
masterfrom
feat/implicit-fork-agent-suffix

Conversation

@lidel
Copy link
Copy Markdown
Member

@lidel lidel commented May 28, 2026

Problem

Fork builds announce themselves as plain kubo/<ver>/<commit> over libp2p identify and HTTP user-agent, indistinguishable from upstream. A fork running old code with hand-applied CVE patches looks identical in swarm traces to a current upstream release, sending maintainer debugging down the wrong path. Version.AgentSuffix exists but operators rarely set it.

Fix

When Version.AgentSuffix and --agent-version-suffix are both unset, kubo derives a default from the build origin so forks self-identify.

  • mk/git.mk + cmd/ipfs/Rules.mk inject the normalized git remote get-url origin as a buildOrigin ldflag.
  • ImplicitAgentSuffix in version.go prefers buildOrigin, falls back to debug.ReadBuildInfo().Main.Path for go install; suffixFromForkPath strips known forges (github.com, gitlab.com, codeberg.org, bitbucket.org) and a trailing /kubo.
  • daemon.go plumbs it as the final fallback (Version.AgentSuffix > --agent-version-suffix > implicit).

A make build of github.com/myorg/kubo reports kubo/<ver>/<commit>/myorg; explicit config or CLI flag overrides it.

Fork builds previously announced as plain `kubo/<ver>/<commit>`,
indistinguishable from upstream in ecosystem dashboards. When
`Version.AgentSuffix` and `--agent-version-suffix` are both unset,
kubo now derives a default from the build origin so fork traffic
self-identifies in the swarm.

- mk/git.mk, cmd/ipfs/Rules.mk: normalize `git remote get-url origin`
  to `host/org/repo` and inject as `buildOrigin` ldflag
- version.go: ImplicitAgentSuffix prefers buildOrigin, falls back to
  debug.ReadBuildInfo Main.Path; suffixFromForkPath strips known
  forges (github, gitlab, codeberg, bitbucket) and trailing `/kubo`
- cmd/ipfs/kubo/daemon.go: use as fallback when explicit values empty
- AGENTS.md: state builds must use `make build` so ldflags are set
- docs/config.md: document the implicit-suffix behavior
@lidel lidel added the skip/changelog This change does NOT require a changelog entry label May 28, 2026
@lidel lidel marked this pull request as ready for review May 28, 2026 11:17
@lidel lidel requested a review from a team as a code owner May 28, 2026 11:17
Copy link
Copy Markdown
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

Nice!

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

Labels

skip/changelog This change does NOT require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants