fix(binary): correct traefik version detection on big-endian arches - #5281
Open
mayanksekhar wants to merge 1 commit into
Open
mayanksekhar wants to merge 1 commit into
mayanksekhar wants to merge 1 commit into
Conversation
The traefik-binary classifier regex required a NUL byte or replacement character immediately before the version string. On some architectures (e.g. s390x), the real version string in the binary has no such prefix, so the classifier instead matched an earlier, unrelated NUL-prefixed numeric string elsewhere in the binary (e.g. '2.7.0' from an unrelated printf-style format constant), producing an incorrect version. This adds an additional pattern, tried first via MatchAny, that matches version strings terminated by two NUL bytes without requiring a NUL prefix. The original pattern remains as a fallback for older traefik binaries (e.g. v1.x) that use single-NUL termination. Fixes anchore#4980 Signed-off-by: Mayank Sekhar <mayankshekharsingh@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4980 (partially covers the s390x false-positive; arm/v6 was also broken but the root cause and fix are the same).
The traefik-binary classifier regex required a NUL byte or replacement character immediately before the version string. On some architectures (e.g. s390x), the real version string in the binary has no such prefix, so the classifier instead matched an earlier, unrelated NUL-prefixed numeric string elsewhere in the binary (e.g. '2.7.0' from an unrelated printf-style format constant), producing an incorrect version.
This adds an additional pattern, tried first via MatchAny, that matches version strings terminated by two NUL bytes without requiring a NUL prefix. The original pattern remains as a fallback for older traefik binaries (e.g. v1.x) that use single-NUL termination.
The bug
The traefik-binary classifier's regex required a NUL byte or Unicode replacement character immediately before the version string. On some architectures (observed on s390x), the real version string has no such prefix, so the classifier instead matched an earlier, unrelated NUL-prefixed numeric string elsewhere in the binary (e.g.
2.7.0from an unrelated printf style format constant) producing a wrong, stale version regardless of the actual traefik version.The fix
Added a second pattern, tried first via
MatchAny, that matches version strings terminated by two NUL bytes without requiring any prefix.MatchAnystops at the first matcher that finds anything, so this new pattern takes precedence when it applies, while the original single-NUL pattern remains as a fallback for older traefik binaries (v1.x) that use single-NUL termination.Verification
traefik:3.6.8(s390x) andtraefik:v2.11.1(arm/v6) binaries from the images referenced in the original issue and confirmed the previous regex mismatched on s390x while the new one correctly resolves both.traefiktest subset passes (7/7), including the pre-existing v1.7.34/2.9.6/2.10.7/3.0.4/3.6.5 cases confirming no regression.juliatest failures were confirmed to exist identically on a cleanmaincheckout (unrelated to this change).Type of change
Fix Merge
Checklist
Issue references
#4980