Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit d8fa7ac

Browse files
tianonthaJeztah
authored andcommitted
Also trim "~..." from AppArmor versions
Signed-off-by: Tianon Gravi <admwiggin@gmail.com> (cherry picked from commit 654cad4d9dc4e87d72beb110032b61d4dfc963e4) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 88eec2e811d620fe88b4859dee64d064fae37356 Component: engine
1 parent 0a1553c commit d8fa7ac

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

components/engine/pkg/aaparser/aaparser.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ func parseVersion(output string) (int, error) {
5858

5959
// trim "-beta1" suffix from version="3.0.0-beta1" if exists
6060
version = strings.SplitN(version, "-", 2)[0]
61+
// also trim "~..." suffix used historically (https://gitlab.com/apparmor/apparmor/-/commit/bca67d3d27d219d11ce8c9cc70612bd637f88c10)
62+
version = strings.SplitN(version, "~", 2)[0]
6163

6264
// split by major minor version
6365
v := strings.Split(version, ".")

components/engine/pkg/aaparser/aaparser_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ Copyright 2009-2012 Canonical Ltd.
4343
`,
4444
version: 205000,
4545
},
46+
{
47+
output: `AppArmor parser version 2.2.0~rc2
48+
Copyright (C) 1999-2008 Novell Inc.
49+
Copyright 2009-2012 Canonical Ltd.
50+
51+
`,
52+
version: 202000,
53+
},
4654
{
4755
output: `AppArmor parser version 2.9.95
4856
Copyright (C) 1999-2008 Novell Inc.

0 commit comments

Comments
 (0)