Skip to content

Add stale backend build check#549

Open
toddtreece wants to merge 3 commits intomainfrom
toddtreece/check-build
Open

Add stale backend build check#549
toddtreece wants to merge 3 commits intomainfrom
toddtreece/check-build

Conversation

@toddtreece
Copy link
Copy Markdown
Member

@toddtreece toddtreece commented Mar 25, 2026

Adds a new gobuildinfo analyzer that validates embedded Go build metadata in backend plugin binaries. The checks catch common issues that indicate a binary was not built correctly for submission:

  • binary-no-build-info: binary is missing Go build metadata (e.g. was stripped)
  • binary-dirty-build: binary was built from an uncommitted working tree (vcs.modified=true)
  • binary-cgo-enabled: binary was built with CGO_ENABLED=1, which is unsupported
  • binary-plugin-id-mismatch: plugin ID embedded via -ldflags doesn't match plugin.json
  • binary-build-info-json-plugin-id-mismatch: SDK buildInfoJSON plugin ID doesn't match plugin.json
  • binary-build-info-json-version-mismatch: SDK buildInfoJSON version doesn't match plugin.json
  • binary-dep-not-in-gomod: a compiled-in dependency is absent from the submitted go.mod
  • binary-dep-gomod-version-mismatch: a compiled-in dependency is at a different version than declared in go.mod

@toddtreece toddtreece requested review from a team as code owners March 25, 2026 13:13
@toddtreece toddtreece requested review from academo, s4kh and wbrowne March 25, 2026 13:13
@toddtreece toddtreece self-assigned this Mar 25, 2026
@toddtreece toddtreece moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team Mar 25, 2026
@toddtreece toddtreece marked this pull request as draft March 25, 2026 13:13
}

if hasBackend && (!ok || sourceCodeDir == "") {
pass.ReportResult(
Copy link
Copy Markdown
Collaborator

@academo academo Mar 25, 2026

Choose a reason for hiding this comment

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

no need to add this. the source code analyzer already warns of this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

is it clear that it would also impact other checks like this one?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it basically stops all other validators from running. so it is pretty obvious things didn't run but we can't make it an error because of some plugins special cases.

pass.AnalyzerName,
binaryDirtyBuild,
fmt.Sprintf("%s: built from a dirty working tree", binaryName),
"The binary was built with uncommitted changes (vcs.modified=true). Binaries submitted for signing should be built from a clean git working tree.",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a nice check but I suspect we are going to have people asking about this. This works perfect for CI-pipelines but I suspect people that like to submit from zips created in their machines will constantly hit this.

IMO we should keep this but add an entry in the documentation of what this actually means, why we need it and how to fix it and link it here.

pass.ReportResult(
pass.AnalyzerName,
binaryCGOEnabled,
fmt.Sprintf("%s: built with CGO_ENABLED=1", binaryName),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we have genuine cases where CGO_ENABLED=1 is a valid option? I had the idea we don't allow cgo in plugins. if that's the case we can turn this into an error.

Copy link
Copy Markdown
Member Author

@toddtreece toddtreece Mar 25, 2026

Choose a reason for hiding this comment

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

i wasn't sure if it was allowed in some cases. i can change to error

@toddtreece toddtreece marked this pull request as ready for review March 25, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔬 In review

Development

Successfully merging this pull request may close these issues.

2 participants