This repository was archived by the owner on Oct 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
components/engine/pkg/aaparser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ func parseVersion(output string) (int, error) {
5656 words := strings .Split (lines [0 ], " " )
5757 version := words [len (words )- 1 ]
5858
59+ // trim "-beta1" suffix from version="3.0.0-beta1" if exists
60+ 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 ]
63+
5964 // split by major minor version
6065 v := strings .Split (version , "." )
6166 if len (v ) == 0 || len (v ) > 3 {
Original file line number Diff line number Diff 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
4856Copyright (C) 1999-2008 Novell Inc.
@@ -59,6 +67,20 @@ Copyright 2009-2012 Canonical Ltd.
5967` ,
6068 version : 314159 ,
6169 },
70+ {
71+ output : `AppArmor parser version 3.0.0-beta1
72+ Copyright (C) 1999-2008 Novell Inc.
73+ Copyright 2009-2018 Canonical Ltd.
74+ ` ,
75+ version : 300000 ,
76+ },
77+ {
78+ output : `AppArmor parser version 3.0.0-beta1-foo-bar
79+ Copyright (C) 1999-2008 Novell Inc.
80+ Copyright 2009-2018 Canonical Ltd.
81+ ` ,
82+ version : 300000 ,
83+ },
6284 }
6385
6486 for _ , v := range versions {
You can’t perform that action at this time.
0 commit comments