Skip to content

fix(binary): detect grafana security-patch release versions - #5213

Open
pujitha24 wants to merge 2 commits into
anchore:mainfrom
pujitha24:auto/issue-5059
Open

fix(binary): detect grafana security-patch release versions#5213
pujitha24 wants to merge 2 commits into
anchore:mainfrom
pujitha24:auto/issue-5059

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

Description

Grafana binaries built from "security patch" release tags (e.g. grafana/grafana:11.0.5-security-01, 12.0.0-security-01, and 12.4.3-security-02 on arm/v7) are reported by syft as version UNKNOWN. These binaries embed the version as a standalone Go string constant (e.g. 11.0.5+security-01) with no release- prefix, and on at least the arm/v7 build the release-<version>+security-NN string that does exist nearby is preceded by non-NUL padding bytes, so none of the existing grafana-binary regexes (which all require either a release- prefix preceded by NUL bytes, or other markers like go1.x//usr/local/go/$a) match.

Before:

$ syft -q grafana/grafana:11.0.5-security-01 | grep 'grafana '
github.com/grafana/grafana    UNKNOWN    go-module  (+2 duplicates)

After (verified against the extracted binary via the added unit test, not a live syft run against the image):

github.com/grafana/grafana    11.0.5    go-module

This adds one additional EvidenceMatcher regex alternative to the existing **/grafana classifier in syft/pkg/cataloger/binary/classifiers.go that matches the raw <version>+security-NN constant directly, bounded only by a single NUL byte on each side. This mirrors how the binary actually lays out this string and does not depend on the release- prefix or any other nearby marker, so it also covers the arm/v7 case where that prefix is present but not NUL-padded. No application/API configuration changed.

This does not address the second part of the linked report (arm dev-build images like grafana-oss-dev showing an unrelated 3.39.4 binary version) — that appears to be a separate false-positive match against different embedded data and needs its own investigation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (please discuss with the team first; Syft is 1.0 software and we won't accept breaking changes without going to 2.0)
  • Documentation (updates the documentation)
  • Chore (improve the developer experience, fix a test flake, etc, without changing the visible behavior of Syft)
  • Performance (make Syft run faster or use less memory, without changing visible behavior much)

Checklist

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

Issue references

Fixes #5059

Motivation:
Syft reports grafana binaries built from security-patch tags (e.g.
grafana/grafana:11.0.5-security-01, 12.0.0-security-01, and
12.4.3-security-02 on arm/v7) as version UNKNOWN. These binaries embed
the version as a standalone Go string constant (e.g.
"11.0.5+security-01") with no "release-" prefix, and on at least the
arm/v7 build the "release-<version>+security-NN" string that does
exist nearby is preceded by non-NUL padding bytes, so none of the
existing grafana-binary regexes (which all require either a
"release-" prefix preceded by NUL bytes, or other markers like
"go1.x"/"/usr/local/go"/"$a") match.

Approach:
Add an additional EvidenceMatcher pattern to the "**/grafana"
classifier that matches the raw "<version>+security-NN" constant
directly, bounded only by a single NUL byte on each side. This mirrors
how the binary actually lays out this string and does not depend on
the "release-" prefix or any other nearby marker, so it also covers
the arm/v7 case where that prefix is present but not NUL-padded.

Validation:
Added snippet fixtures (extracted from the real grafana/grafana
security-patch images) and test cases for 11.0.5-security-01 and
12.0.0-security-01 (linux/amd64) and 12.4.3-security-02 (linux/arm),
confirming these match the exact "UNKNOWN version" repro from the
report. Ran:

  go test ./syft/pkg/cataloger/binary/... -run Test_Cataloger_PositiveCases/grafana

All grafana subtests pass. Verified the new tests are a real
regression check by reverting classifiers.go alone and re-running:
the three new subtests fail with "should have 1 item(s), but has 0"
(no package/version detected), confirming they fail before this fix
and pass after it.

Also ran `go build ./...` and `golangci-lint run
./syft/pkg/cataloger/binary/...`, both clean (pre-existing goconst
findings elsewhere in the file are unrelated to this change).
`go generate ./internal/capabilities` produces no diff since no new
classifier or package was added.

This does not address the second part of the report (arm dev-build
images like grafana-oss-dev showing an unrelated "3.39.4" binary
version) -- that appears to be a separate false-positive match against
different embedded data and needs its own investigation.

Report: anchore#5059
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5 (via Claude Code)
@wagoodman
wagoodman enabled auto-merge (squash) August 21, 2026 21:03
The fixture-download tool matches platforms as OS/Architecture only and
never consults the manifest variant field, so linux/arm/v7 can never
match. Use linux/arm, matching the convention already used elsewhere in
this file (e.g. nginx-ingress-controller) for arm/v7 binaries. Fixes the
failing Unit tests CI check on anchore#5213 (refresh-fixtures/build-fixtures
docker pull failure).

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
auto-merge was automatically disabled August 21, 2026 21:39

Head branch was pushed to by a user without write access

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.

Support grafana binary various version

2 participants