pkg/aaparser: support parsing version like "3.0.0-beta1"#41518
pkg/aaparser: support parsing version like "3.0.0-beta1"#41518tianon merged 1 commit intomoby:masterfrom
Conversation
Fix moby#41517 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
|
Will this be merged soon? |
| version := words[len(words)-1] | ||
|
|
||
| // trim "-beta1" suffix from version="3.0.0-beta1" if exists | ||
| version = strings.SplitN(version, "-", 2)[0] |
There was a problem hiding this comment.
@alexmurray this is pretty similar to what you applied in Ubuntu (~ one month ago 😅) -- is there a specific reason you'd decided to also trim ~... in addition to/after -...? 🙏
For reference (slash to jog your memory), here's the patch you ended up with:
Description: Handle apparmor versions like 3.0.0-beta1 appropriately
Author: Alex Murray <alex.murray@canonical.com>
--- a/components/engine/pkg/aaparser/aaparser.go
+++ b/components/engine/pkg/aaparser/aaparser.go
@@ -55,6 +55,8 @@ func parseVersion(output string) (int, e
lines := strings.SplitN(output, "\n", 2)
words := strings.Split(lines[0], " ")
version := words[len(words)-1]
+ version = strings.SplitN(version, "-", 2)[0]
+ version = strings.SplitN(version, "~", 2)[0]
// split by major minor version
v := strings.Split(version, ".")cc @mwhudson
There was a problem hiding this comment.
The upstream AppArmor maintainer mentioned that sometimes they have used a tilde ~ in the past and so it would be more future proof to include this as well.
There was a problem hiding this comment.
Perfect, thank you! Found a good example in https://gitlab.com/apparmor/apparmor/-/commit/bca67d3d27d219d11ce8c9cc70612bd637f88c10 (and will be sending a follow-up PR to include that other half shortly). 👍 ❤️
Fix #41517